diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java index eef8d9235..4fbb0057e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java @@ -48,6 +48,8 @@ public class MapPointConfig implements BaseConfig{ */ private int confuced; + private int position; + @Override public void init() throws Exception { scMapEventMap = STableManager.getConfig(MapPointConfig.class); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 2371adcf1..0c8942c6a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -207,21 +207,7 @@ public class MapLogic { Map newMap = new HashMap<>(); Map spicelMap = new HashMap<>(); Random random = new Random(); - CrossMapCell crossMapCell1 = mapManager.getCrossMapInfos().get(mapManager.getCurMapId()); - Set missions = new HashSet<>(); - if (crossMapCell1 != null) { - Map doingMissions = user.getMissionManager().getDoingMissions(); - for (Integer doingMissionId : crossMapCell1.getMissionIds()) { - if (doingMissions.containsKey(doingMissionId)) { - Mission mission = doingMissions.get(doingMissionId); - missions.add(mission); - for (Map.Entry missionEntry : mission.getMissionInfos().entrySet()) { - newMap.put(missionEntry.getKey(), missionEntry.getValue()); - } - } - } - } - CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(mapManager.getCurMapId()); + CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId()); for (Map.Entry entry : scMap.entrySet()) { SCMap scMap1 = entry.getValue(); // 必出现的事件点 @@ -265,13 +251,6 @@ public class MapLogic { initialEventId = eventId; } } - // 任务触发的事件点 - for (Mission mission : missions) { - if (mission.getMapPoints().containsKey(mapPointConfig.getId())) { - Cell cellValue = new Cell(xy, mission.getMapPoints().get(mapPointConfig.getId()), mapPointConfig.getId()); - newMap.put(xy, cellValue); - } - } Cell cellValue = new Cell(xy, initialEventId, mapPointConfig.getId()); if (mapPointConfig.getStyle() == EventType.enter) { mapManager.setCurXY(xy); @@ -547,14 +526,6 @@ public class MapLogic { updateMapMission(mapManager,EventType.updateEvent, targetEventId,0); updateMapMission(mapManager,EventType.updateEvent, pointId,0); - if (behaviorType == EventType.dun && eventUpdateResponse.getMissionCount() > 0) { - for (CommonProto.Mission missionProto : eventUpdateResponse.getMissionList()) { - Mission mission = user.getMissionManager().getDoingMissions().get(missionProto.getItemId()); - if (mission != null && cell != null) { - mission.updateMapPoints(cell.getPointId(), cell.getEventId()); - } - } - } CommonProto.Drop.Builder dropBuilder = null; if (sOptionConfig.getReward().length > 0) { dropBuilder = ItemUtil.drop(user, sOptionConfig.getReward(), 1, 1); @@ -766,23 +737,11 @@ public class MapLogic { public CommonProto.Mission getMission(Mission mission) { CommonProto.Mission openMission; - StringBuilder state = null; - String states = ""; - if (mission.getMissionInfos() != null && !mission.getMissionInfos().isEmpty()) { - state = new StringBuilder(); - for (Map.Entry cellEntry : mission.getMissionInfos().entrySet()) { - state.append(cellEntry.getKey()); - state.append("#"); - state.append(cellEntry.getValue().getPointId()); - state.append("|"); - } - states = state.toString().substring(0, state.toString().length() - 1); - } openMission = CommonProto.Mission.newBuilder() .setItemId(mission.getMissionId()) .setMissionStep(mission.getMissionStep()) .setIsOpen(mission.isOpen()) - .setState(states) + .setState("") .build(); return openMission; } @@ -980,7 +939,7 @@ public class MapLogic { fightEndResponse.addAllMission(eventUpdateResponse.getMissionList()); } if (destoryId != 0) { - BehaviorUtil.destoryPoint(user, destoryId); + BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), destoryId); } if (destoryXY != 0) { BehaviorUtil.destoryApointXY(user, destoryXY); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java index 87df4c4e1..e4aba9704 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java @@ -33,7 +33,7 @@ public class BehaviorUtil { * @param user * @throws Exception */ - public static void destoryPoint(User user, int needDistoryPointId) throws Exception { + public static void destoryPoint(User user, int mapId, int needDistoryPointId) throws Exception { MapManager mapManager = user.getMapManager(); Map mapInfo = mapManager.getMapInfo(); Set needDelete = new HashSet<>(); @@ -42,13 +42,12 @@ public class BehaviorUtil { needDelete.add(entry.getKey()); } } - Map doingMissions = user.getMissionManager().getDoingMissions(); - for (Map.Entry entry : doingMissions.entrySet()) { - Mission mission = entry.getValue(); - Map missionInfos = mission.getMissionInfos(); + CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(mapId); + if (crossMapCell != null) { + Map behaviorTriggers = crossMapCell.getBehaviorTriggers(); for (Integer xy : needDelete) { - if (missionInfos.containsKey(xy)){ - mission.removeMissionInfos(xy); + if (behaviorTriggers.containsKey(xy)) { + behaviorTriggers.remove(xy); } } } @@ -56,7 +55,6 @@ public class BehaviorUtil { mapInfo.remove(xy); } mapManager.setMapInfo(mapInfo); - addRefreshInfo(needDistoryPointId, mapManager, mapManager.getCurMapId()); } @@ -93,6 +91,7 @@ public class BehaviorUtil { Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); crossMapCell.getBehaviorTriggers().put(xy,cellValue); mapManager.updateCrossMapInfos(mapId, crossMapCell); + mapManager.addOrUpdateCell(xy, cellValue); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointBehavior.java index 8bc58b1b5..1ac44fdf8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointBehavior.java @@ -14,7 +14,7 @@ public class DestroyPointBehavior extends BaseBehavior { @Override public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { - BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][0]); + BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][0]); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DunBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DunBehavior.java index 32281e0d3..3dae26d9b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DunBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DunBehavior.java @@ -63,22 +63,17 @@ public class DunBehavior extends BaseBehavior { if (i >= 1000) { break; } + // 开新事件 + BehaviorUtil.addBehaviorInfo(mapManager.getCurMapId(), mapManager, mapPointConfig.getId(), x, y); } mapManager.getMapInfo().putAll(newDunEvents); Mission mission = new Mission(); mission.setMissionId(behaviorTypeValues[0][0]); mission.setMissionStep(0); - mission.getMissionInfos().putAll(newDunEvents); mission.setMissionInfo(mapManager.getCurXY() + "#" + behaviorTypeValues[0][2]); user.getMissionManager().updateOneDoingMissions(behaviorTypeValues[0][0], mission); CommonProto.Mission missionProto = MapLogic.getInstance().getMission(mission); eventUpdateResponse.addMission(missionProto); - CrossMapCell crossMapInfo = mapManager.getCrossMapInfos().get(mapManager.getCurMapId()); - if (crossMapInfo == null) { - crossMapInfo = new CrossMapCell(); - } - crossMapInfo.getMissionIds().add(behaviorTypeValues[0][0]); - mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapInfo); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionAndDestroyPointBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionAndDestroyPointBehavior.java index 0afe46713..49fd83817 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionAndDestroyPointBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionAndDestroyPointBehavior.java @@ -1,18 +1,10 @@ package com.ljsd.jieling.handler.map.behavior; -import com.ljsd.jieling.config.MapPointConfig; -import com.ljsd.jieling.handler.map.Cell; -import com.ljsd.jieling.handler.map.CrossMapCell; import com.ljsd.jieling.handler.map.EventType; -import com.ljsd.jieling.handler.map.MapLogic; -import com.ljsd.jieling.handler.mission.Mission; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.protocols.MapInfoProto; -import com.ljsd.jieling.util.CellUtil; import org.springframework.stereotype.Component; -import java.util.Map; - @Component public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior { @Override @@ -25,32 +17,10 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior { // 1#101011|101#13#18#101012|101#12#13#101009 BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse); // 销毁事件点 - BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]); - // 开新事件 新事件需要和任务绑定 - Map doingMissions = user.getMissionManager().getDoingMissions(); - Mission mission = doingMissions.get(behaviorTypeValues[0][0]); + BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][1]); + // 开新事件 for (int j = 1; j < behaviorTypeValues.length; j++) { - if (user.getMapManager().getCurMapId() == behaviorTypeValues[j][0]) { - for (int i = 1; i < behaviorTypeValues.length; i++) { - int x = behaviorTypeValues[i][1]; - int y = behaviorTypeValues[i][2]; - int xy = CellUtil.xy2Pos(x, y); - MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[i][3]); - Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); - user.getMapManager().addOrUpdateCell(xy, cellValue); - if (mission != null) { - mission.updateMissionInfos(xy, cellValue); - mission.updateMapPoints(cellValue.getPointId(), cellValue.getEventId()); - CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(user.getMapManager().getCurMapId()); - if (crossMapCell == null) { - crossMapCell = new CrossMapCell(); - } - crossMapCell.getMissionIds().add(behaviorTypeValues[0][0]); - } - } - } else { - BehaviorUtil.addBehaviorInfo(behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0], behaviorTypeValues[j][1], behaviorTypeValues[j][2]); - } + BehaviorUtil.addBehaviorInfo(behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0], behaviorTypeValues[j][1], behaviorTypeValues[j][2]); } return true; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/OpenMissionBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/OpenMissionBehavior.java index cc34d4a10..5857aa99f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/OpenMissionBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/OpenMissionBehavior.java @@ -1,11 +1,8 @@ package com.ljsd.jieling.handler.map.behavior; -import com.ljsd.jieling.config.MapPointConfig; -import com.ljsd.jieling.handler.map.Cell; import com.ljsd.jieling.handler.map.EventType; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.protocols.MapInfoProto; -import com.ljsd.jieling.util.CellUtil; import org.springframework.stereotype.Component; @Component @@ -19,16 +16,7 @@ public class OpenMissionBehavior extends BaseBehavior { public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse); // 开新事件 - if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][0]) { - int x = behaviorTypeValues[1][1]; - int y = behaviorTypeValues[1][2]; - int xy = CellUtil.xy2Pos(x, y); - MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[1][3]); - Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); - user.getMapManager().addOrUpdateCell(xy, cellValue); - } else { - BehaviorUtil.addBehaviorInfo(behaviorTypeValues[1][3], user.getMapManager(), behaviorTypeValues[1][0], behaviorTypeValues[1][1], behaviorTypeValues[1][2]); - } + BehaviorUtil.addBehaviorInfo(behaviorTypeValues[1][3], user.getMapManager(), behaviorTypeValues[1][0], behaviorTypeValues[1][1], behaviorTypeValues[1][2]); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/ThirtyBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/ThirtyBehavior.java index c770c06ba..d362323d7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/ThirtyBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/ThirtyBehavior.java @@ -1,13 +1,8 @@ package com.ljsd.jieling.handler.map.behavior; -import com.ljsd.jieling.config.MapPointConfig; -import com.ljsd.jieling.handler.map.Cell; import com.ljsd.jieling.handler.map.EventType; -import com.ljsd.jieling.handler.map.MapLogic; -import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.protocols.MapInfoProto; -import com.ljsd.jieling.util.CellUtil; import org.springframework.stereotype.Component; @Component @@ -19,20 +14,7 @@ public class ThirtyBehavior extends BaseBehavior { @Override public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { - MapManager mapManager = user.getMapManager(); - if (mapManager.getCurMapId() == behaviorTypeValues[0][0]) { - for (int i = 0; i < behaviorTypeValues.length; i++) { - int x = behaviorTypeValues[i][1]; - int y = behaviorTypeValues[i][2]; - int xy = CellUtil.xy2Pos(x, y); - MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[i][3]); - Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); - mapManager.addOrUpdateCell(xy, cellValue); - } - return true; - } else { - BehaviorUtil.addBehaviorInfo(behaviorTypeValues[0][3], user.getMapManager(), behaviorTypeValues[0][0], behaviorTypeValues[0][1], behaviorTypeValues[0][2]); - } + BehaviorUtil.addBehaviorInfo(behaviorTypeValues[0][3], user.getMapManager(), behaviorTypeValues[0][0], behaviorTypeValues[0][1], behaviorTypeValues[0][2]); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/UseItemAndDestroyBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/UseItemAndDestroyBehavior.java index 1b3cc3103..d51fbd88a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/UseItemAndDestroyBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/UseItemAndDestroyBehavior.java @@ -19,7 +19,7 @@ public class UseItemAndDestroyBehavior extends BaseBehavior { if (!isEnough) { return isEnough; } - BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][2]); + BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][2]); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/Mission.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/Mission.java index 27bb09e93..0842fe47a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/Mission.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/Mission.java @@ -1,10 +1,6 @@ package com.ljsd.jieling.handler.mission; import com.ljsd.common.mogodb.MongoBase; -import com.ljsd.jieling.handler.map.Cell; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; public class Mission extends MongoBase { @@ -16,12 +12,6 @@ public class Mission extends MongoBase { private boolean isOpen; - // pointId, eventId - private Map mapPoints = new ConcurrentHashMap<>(); - - // 地图坐标,事件点 - private Map missionInfos = new ConcurrentHashMap<>(); - public int getMissionId() { return missionId; } @@ -38,20 +28,6 @@ public class Mission extends MongoBase { this.missionStep = missionStep; } - public Map getMissionInfos() { - return missionInfos; - } - - public void updateMissionInfos(int xy, Cell cell) throws Exception { - updateString("missionInfos." + xy, cell); - this.missionInfos.put(xy, cell); - } - - public void removeMissionInfos(int xy) throws Exception { - removeString(getMongoKey() + ".missionInfos." + xy); - this.missionInfos.remove(xy); - } - public String getMissionInfo() { return missionInfo; } @@ -61,15 +37,6 @@ public class Mission extends MongoBase { this.missionInfo = missionInfo; } - public Map getMapPoints() { - return mapPoints; - } - - public void updateMapPoints(int pointId, int eventId) throws Exception { - updateString("mapPoints." + pointId, eventId); - this.mapPoints.put(pointId, eventId); - } - public boolean isOpen() { return isOpen; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/MissionLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/MissionLogic.java index 563fff853..2f606cf60 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/MissionLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/mission/MissionLogic.java @@ -1,9 +1,8 @@ package com.ljsd.jieling.handler.mission; import com.ljsd.jieling.config.SMissionEventsConfig; -import com.ljsd.jieling.handler.map.Cell; -import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.MessageTypeProto; @@ -44,23 +43,12 @@ public class MissionLogic { Set finishMissions = missionManager.getFinishMissions(); MissionInfoProto.MissionGetAllResponse.Builder missionGetAllResponse = MissionInfoProto.MissionGetAllResponse.newBuilder(); for (Mission doingMission : doingMissions.values()) { - StringBuilder state = new StringBuilder(); - String states = ""; - if (!doingMission.getMissionInfos().isEmpty()) { - for (Map.Entry cellEntry : doingMission.getMissionInfos().entrySet()) { - state.append(cellEntry.getKey()); - state.append("#"); - state.append(cellEntry.getValue().getPointId()); - state.append("|"); - } - states = state.toString().substring(0, state.toString().length() - 1); - } CommonProto.Mission mission = CommonProto.Mission .newBuilder() .setMissionStep(doingMission.getMissionStep()) .setItemId(doingMission.getMissionId()) .setIsOpen(doingMission.isOpen()) - .setState(states) + .setState("") .build(); missionGetAllResponse.addMissions(mission); } @@ -95,13 +83,6 @@ public class MissionLogic { public CheckMissionReturn checkMission(Mission mission, User user) throws Exception { SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(mission.getMissionId()); mission.setMissionStep(mission.getMissionStep() + 1); - Map missionInfos = mission.getMissionInfos(); - int curXY = user.getMapManager().getCurXY(); - if (missionInfos.containsKey(curXY)) { - Cell cell = missionInfos.get(curXY); - cell.setEventId(-1); - mission.updateMissionInfos(curXY, cell); - } CheckMissionReturn checkMissionReturn = new CheckMissionReturn(); if (mission.getMissionStep() >= sMissionEventsConfig.getMissionNum()) { if (mission.getMissionInfo() != null) {