活动预告
parent
867f81836a
commit
a82d645499
|
|
@ -0,0 +1,28 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/12/13
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class ActivityPrepareHandler extends BaseHandler<PlayerInfoProto.NextActivityRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.NEXT_ACTIVITY_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.NextActivityRequest proto) throws Exception {
|
||||
int activityId = proto.getActivityId();
|
||||
ActivityLogic.getInstance().getNextActivityId(iSession,activityId, MessageTypeProto.MessageType.NEXT_ACTIVITY_RESPONSE);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1153,17 +1153,19 @@ public class ActivityLogic {
|
|||
return objects.length>0;
|
||||
}
|
||||
}
|
||||
public void getNextActivityId(User user) throws Exception {
|
||||
List<SGlobalActivity> sGlobalActivities = SGlobalActivity.sGlobalActivityMapByType.get(ActivityType.LIMIT_RANDOM_CARD);
|
||||
public void getNextActivityId(ISession session, int activityId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int type = SGlobalActivity.getsGlobalActivityMap().get(activityId).getType();
|
||||
List<SGlobalActivity> sGlobalActivities = SGlobalActivity.sGlobalActivityMapByType.get(type);
|
||||
if(sGlobalActivities.isEmpty()){
|
||||
return;
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
Function<SGlobalActivity,Integer> function = v->(int)ToolsUtil.getTimeLong(v.getStartTimeLong(),v.getEndTimeLong(),v.getTime(),user.getPlayerInfoManager().getCreateTime(),1);
|
||||
Stream<SGlobalActivity> stream = sGlobalActivities.stream().sorted(Comparator.comparing(function))
|
||||
.filter(v->ToolsUtil.getTimeLong(v.getStartTimeLong(), v.getEndTimeLong(), v.getTime(), user.getPlayerInfoManager().getCreateTime(), 1) > TimeUtils.now());
|
||||
List<SGlobalActivity> collect = stream.collect(Collectors.toList());
|
||||
if(collect.isEmpty()){
|
||||
return;
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
int id = collect.get(0).getId();
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
|
|
@ -1171,7 +1173,9 @@ public class ActivityLogic {
|
|||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
long startTime = ToolsUtil.getTimeLong(sGlobalActivity.getStartTimeLong(),sGlobalActivity.getEndTimeLong(),sGlobalActivity.getTime(),user.getPlayerInfoManager().getCreateTime(),1);
|
||||
PlayerInfoProto.NextActivityResponse response = PlayerInfoProto.NextActivityResponse.newBuilder().setId(id).setTime((int)(startTime/1000)).build();
|
||||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,13 @@ public class LimitRandomCardActivity extends AbstractActivity {
|
|||
if(! (event instanceof RandomCardEvent) ){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RandomCardEvent cardEvent =(RandomCardEvent) event;
|
||||
if(cardEvent.getType()!=3){
|
||||
return;
|
||||
}
|
||||
if(UserManager.getUser(cardEvent.getUid()).getActivityManager().getActivityMissionMap().get(id)==null){
|
||||
return;
|
||||
}
|
||||
AbstractRank randomRank= RankContext.getRankEnum(RankEnum.RANDOM_CARD_RANK.getType());
|
||||
int scoreById = Double.valueOf(randomRank.getScoreById(((RandomCardEvent) event).getUid())).intValue();
|
||||
if(scoreById==-1){
|
||||
|
|
|
|||
Loading…
Reference in New Issue