From 6bd50b34de51871657ec7b9645958e76cc7698a6 Mon Sep 17 00:00:00 2001 From: jiahuiwen <1024696487@qq.com> Date: Mon, 8 Apr 2019 14:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=8C=E4=B8=BA=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=BC=80=E5=90=AF=E5=85=B6=E4=BB=96=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/map/behavior/BehaviorUtil.java | 12 +++---- ...MonitorMissionAndDestroyPointBehavior.java | 34 +++++++++++-------- .../map/behavior/OpenMissionBehavior.java | 20 ++--------- .../handler/map/behavior/ThirtyBehavior.java | 7 +--- 4 files changed, 29 insertions(+), 44 deletions(-) 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 e4ee97e5b..3307eb220 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 @@ -56,10 +56,10 @@ public class BehaviorUtil { } mapManager.setMapInfo(mapInfo); - addRefreshInfo(needDistoryPointId, mapManager); + addRefreshInfo(needDistoryPointId, mapManager, mapManager.getCurMapId()); } - private static void addRefreshInfo(int needDistoryPointId, MapManager mapManager) throws Exception { + public static void addRefreshInfo(int needDistoryPointId, MapManager mapManager, int mapId) throws Exception { MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(needDistoryPointId); /** * 事件点的刷新规则 @@ -68,7 +68,7 @@ public class BehaviorUtil { * 3 一次性 */ if (mapPointConfig.getRefresh() == 1 || mapPointConfig.getRefresh() == 3) { - CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId()); + CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapId); if (crossMapCell == null) { crossMapCell = new CrossMapCell(); } @@ -78,7 +78,7 @@ public class BehaviorUtil { if (mapPointConfig.getRefresh() == 3) { crossMapCell.getPermanents().put(needDistoryPointId, -1); } - mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapCell); + mapManager.updateCrossMapInfos(mapId, crossMapCell); } } @@ -95,7 +95,7 @@ public class BehaviorUtil { if (cell != null) { cell.setEventId(-1); mapManager.addOrUpdateCell(destoryXY, cell); - addRefreshInfo(cell.getPointId(), mapManager); + addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId()); } } @@ -216,7 +216,7 @@ public class BehaviorUtil { if (cell != null) { cell.setEventId(-1); mapManager.addOrUpdateCell(cell.getCellId(), cell); - addRefreshInfo(cell.getPointId(), mapManager); + addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId()); } } 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 e080d7aca..1bb14e64f 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 @@ -28,23 +28,27 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior { // 开新事件 新事件需要和任务绑定 Map doingMissions = user.getMissionManager().getDoingMissions(); Mission mission = doingMissions.get(behaviorTypeValues[0][0]); - if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][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(); + 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]); } - crossMapCell.getMissionIds().add(behaviorTypeValues[0][0]); } + } else { + BehaviorUtil.addRefreshInfo(behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0]); } } 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 5224b931d..4839165b9 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 @@ -3,18 +3,11 @@ 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.mission.CheckMissionReturn; -import com.ljsd.jieling.handler.mission.Mission; -import com.ljsd.jieling.handler.mission.MissionLogic; import com.ljsd.jieling.logic.dao.root.User; -import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.MapInfoProto; import com.ljsd.jieling.util.CellUtil; import org.springframework.stereotype.Component; -import java.util.Map; - @Component public class OpenMissionBehavior extends BaseBehavior { @Override @@ -24,16 +17,7 @@ public class OpenMissionBehavior extends BaseBehavior { @Override public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { - Map doingMissions = user.getMissionManager().getDoingMissions(); - Mission mission = doingMissions.get(behaviorTypeValues[0][0]); - if (mission == null || !mission.isOpen()) { - return false; - } - CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user); - for (Mission cmission : checkMissionReturn.missions){ - CommonProto.Mission missionProto = MapLogic.getInstance().getMission(cmission); - eventUpdateResponse.addMission(missionProto); - } + BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse); // 开新事件 if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][0]) { int x = behaviorTypeValues[1][1]; @@ -42,6 +26,8 @@ public class OpenMissionBehavior extends BaseBehavior { MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[1][3]); Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); user.getMapManager().addOrUpdateCell(xy, cellValue); + } else { + BehaviorUtil.addRefreshInfo(behaviorTypeValues[1][3], user.getMapManager(), behaviorTypeValues[1][0]); } 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 5159bb0c3..997b97c09 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 @@ -30,12 +30,7 @@ public class ThirtyBehavior extends BaseBehavior { } return true; } else { -// Map crossMapInfos = mapManager.getCrossMapInfos(); -// CrossMapCell crossMapCell = crossMapInfos.get(behaviorTypeValues[0][0]); -// if (crossMapCell == null) { -// crossMapCell = new CrossMapCell(); -// } -// crossMapCell.getPermanents().put() + BehaviorUtil.addRefreshInfo(behaviorTypeValues[0][3], user.getMapManager(), behaviorTypeValues[0][0]); } return false; }