任务可领取
parent
6db6e061a5
commit
b40c61d92d
|
@ -2,11 +2,11 @@ package com.ljsd.jieling.handler.map;
|
||||||
|
|
||||||
import com.ljsd.jieling.config.*;
|
import com.ljsd.jieling.config.*;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.db.redis.RedisKey;
|
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
|
||||||
import com.ljsd.jieling.handler.map.behavior.BaseBehavior;
|
import com.ljsd.jieling.handler.map.behavior.BaseBehavior;
|
||||||
import com.ljsd.jieling.handler.mission.Mission;
|
import com.ljsd.jieling.handler.mission.Mission;
|
||||||
import com.ljsd.jieling.logic.dao.*;
|
import com.ljsd.jieling.logic.dao.Hero;
|
||||||
|
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||||
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
@ -283,7 +283,6 @@ public class MapLogic {
|
||||||
* @param optionId
|
* @param optionId
|
||||||
*/
|
*/
|
||||||
public void updateEvent(ISession session, int eventId, int optionId, MessageTypeProto.MessageType messageType) throws Exception {
|
public void updateEvent(ISession session, int eventId, int optionId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||||
LOGGER.info("updateEvent() client param eventId=>{} optionId=>{}", eventId, optionId);
|
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
MapManager mapManager = user.getMapManager();
|
MapManager mapManager = user.getMapManager();
|
||||||
|
@ -451,8 +450,8 @@ public class MapLogic {
|
||||||
if (dropBuilder != null) {
|
if (dropBuilder != null) {
|
||||||
eventUpdateResponse.setDrop(dropBuilder);
|
eventUpdateResponse.setDrop(dropBuilder);
|
||||||
}
|
}
|
||||||
LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
// LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
||||||
cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon);
|
// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon);
|
||||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
|
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class BehaviorUtil {
|
||||||
public static boolean updateMission(User user, int missionId, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception{
|
public static boolean updateMission(User user, int missionId, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception{
|
||||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||||
Mission mission = doingMissions.get(missionId);
|
Mission mission = doingMissions.get(missionId);
|
||||||
if (mission == null) {
|
if (mission == null || !mission.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class DestroyMissionBehavior extends BaseBehavior {
|
||||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||||
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
||||||
if (mission == null) {
|
if (mission == null || !mission.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class MonitorMissionBehavior extends BaseBehavior {
|
||||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||||
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
||||||
if (mission == null) {
|
if (mission == null || !mission.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class OpenMissionBehavior extends BaseBehavior {
|
||||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||||
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
||||||
if (mission == null) {
|
if (mission == null || !mission.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class UseItemMissionBehavior extends BaseBehavior {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean checkCost = ItemUtil.itemCost(user, behaviorTypeValues);
|
boolean checkCost = ItemUtil.itemCost(user, behaviorTypeValues);
|
||||||
if (!checkCost) {
|
if (!checkCost || !mission.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class Mission extends MongoBase {
|
||||||
|
|
||||||
private String missionInfo;
|
private String missionInfo;
|
||||||
|
|
||||||
|
private boolean isOpen;
|
||||||
|
|
||||||
// pointId, eventId
|
// pointId, eventId
|
||||||
private Map<Integer, Integer> mapPoints = new ConcurrentHashMap<>();
|
private Map<Integer, Integer> mapPoints = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -63,4 +65,12 @@ public class Mission extends MongoBase {
|
||||||
this.mapPoints.put(pointId, eventId);
|
this.mapPoints.put(pointId, eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOpen() {
|
||||||
|
return isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean open) {
|
||||||
|
updateString("open", open);
|
||||||
|
isOpen = open;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,4 +147,19 @@ public class MissionLogic {
|
||||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), takeMissionResponse, true);
|
MessageUtil.sendMessage(session, 1, messageType.getNumber(), takeMissionResponse, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void openMission(ISession session, int missionId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||||
|
User user = UserManager.getUser(session.getUid());
|
||||||
|
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||||
|
if (!doingMissions.containsKey(missionId)) {
|
||||||
|
LOGGER.info("openMission uid=>{}, not this misson missionId=>{}", session.getUid(), missionId);
|
||||||
|
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Mission mission = doingMissions.get(missionId);
|
||||||
|
mission.setOpen(true);
|
||||||
|
user.getMissionManager().updateOneDoingMissions(missionId, mission);
|
||||||
|
MessageUtil.sendErrorResponse(session, 1, messageType.getNumber(), "");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ljsd.jieling.handler.mission;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import com.ljsd.jieling.protocols.MissionInfoProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class OpenMissionRequestHandler extends BaseHandler {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.MISSION_OPEN_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
byte[] message = netData.parseClientProtoNetData();
|
||||||
|
MissionInfoProto.OpenMissionRequest openMissionRequest = MissionInfoProto.OpenMissionRequest.parseFrom(message);
|
||||||
|
int missionId = openMissionRequest.getMissionId();
|
||||||
|
MissionLogic.getInstance().openMission(iSession, missionId, MessageTypeProto.MessageType.MISSION_OPEN_RESPONSE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,6 +83,7 @@ public class UserManager {
|
||||||
Mission mission = new Mission();
|
Mission mission = new Mission();
|
||||||
mission.setMissionId(1);
|
mission.setMissionId(1);
|
||||||
mission.setMissionStep(0);
|
mission.setMissionStep(0);
|
||||||
|
mission.setOpen(true);
|
||||||
missionManager.getDoingMissions().put(mission.getMissionId(), mission);
|
missionManager.getDoingMissions().put(mission.getMissionId(), mission);
|
||||||
MapManager mapManager = user.getMapManager();
|
MapManager mapManager = user.getMapManager();
|
||||||
//TODO
|
//TODO
|
||||||
|
|
Loading…
Reference in New Issue