From 8d9b8e1ff84152d88d2a27fd86b15f27bc8ae3bd Mon Sep 17 00:00:00 2001 From: jiahuiwen <1024696487@qq.com> Date: Sat, 23 Mar 2019 17:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/EventType.java | 2 + .../ljsd/jieling/handler/map/MapLogic.java | 51 +++++++++---------- .../handler/map/behavior/BehaviorUtil.java | 24 +++++++++ .../map/behavior/DestroyPointBehavior.java | 3 -- .../map/behavior/MonitorMissionBehavior.java | 12 +---- .../map/behavior/TwentyFiveBehavior.java | 25 +++++++++ 6 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/TwentyFiveBehavior.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java index d0dbfd705..08c864601 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java @@ -53,6 +53,7 @@ public class EventType { * 行为参数:任务id#地图id#坐标(不输入地图id和坐标而输入0代表回主城) * 20 战斗并销毁指定地图点 * + * 25 完成任务往下推一步,销毁当前地图点,服务器跳转地图点到指定状态,客户端不读取新事件, 任务id#地图点id#新事件id * 26 接受任务,可直接做的任务 * 27 开启新任务,此任务需要激活 */ @@ -75,6 +76,7 @@ public class EventType { public static final int monitorMissionAndMove = 19; public static final int destroyPointAnd = 20; + public static final int twentyFive = 25; public static final int openAppointMission = 26; public static final int openNotDoMission = 27; 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 ea564c56f..d37a1facd 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 @@ -107,18 +107,18 @@ public class MapLogic { if (mapId > mapManager.getCurMapId()) { return; } - SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId); - if (energy < scMapConfig.getEnergyConfused()) { - LOGGER.info("enterMap() uid=>{} energy=>{} need=>{} energy not enough ", uid, energy, scMapConfig.getEnergyConfused()); - MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); - return; - } - int leftEnergy = energy - scMapConfig.getEnergyConfused(); - user.getPlayerInfoManager().setEnergy(leftEnergy); - if (mapId != mapManager.getCurMapId()) { - initMap(mapManager, user); - user.setMapManager(mapManager); - } +// SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId); +// if (energy < scMapConfig.getEnergyConfused()) { +// LOGGER.info("enterMap() uid=>{} energy=>{} need=>{} energy not enough ", uid, energy, scMapConfig.getEnergyConfused()); +// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); +// return; +// } +// int leftEnergy = energy - scMapConfig.getEnergyConfused(); +// user.getPlayerInfoManager().setEnergy(leftEnergy); +// if (mapId != mapManager.getCurMapId()) { +// initMap(mapManager, user); +// user.setMapManager(mapManager); +// } } List cells = new ArrayList<>(mapManager.getMapInfo().size()); for (Map.Entry entry : mapManager.getMapInfo().entrySet()) { @@ -230,6 +230,7 @@ public class MapLogic { public void updateMap(ISession session, int curXY, int triggerXY, List cells, MessageTypeProto.MessageType messageType) throws Exception { + LOGGER.info("updateMap() curXY=>{},triggerXY=>{}", curXY, triggerXY); if (triggerXY != curXY) { boolean isConnect = CellUtil.checkIsNextCell(curXY, triggerXY); if (!isConnect) { @@ -270,14 +271,11 @@ public class MapLogic { } mapManager.setTotalStep(leftStep); } - Cell cell = mapManager.getMapInfo().get(curXY); + Cell cell = mapManager.getMapInfo().get(triggerXY); if (cell == null) { - cell = mapManager.getMapInfo().get(triggerXY); - if (cell == null) { - LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY); - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); - return; - } + LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY); + MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), ""); + return; } mapManager.setTriggerXY(triggerXY); mapManager.addWalkCells(new HashSet<>(cells)); @@ -305,14 +303,11 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } - Cell cell = mapManager.getMapInfo().get(mapManager.getCurXY()); + Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); if (cell == null) { - cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); - if (cell == null) { - LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY()); - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); - return; - } + LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY()); + MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), ""); + return; } int bigEventId = cell.getEventId(); if (eventId != bigEventId) { @@ -464,8 +459,8 @@ public class MapLogic { if (dropBuilder != null) { eventUpdateResponse.setDrop(dropBuilder); } -// 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); + 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); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); } 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 450bd4bad..24af85f34 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 @@ -167,4 +167,28 @@ public class BehaviorUtil { } return true; } + + /** + * 销毁当前点 + * @param user + */ + public static void destoryCurPoint(User user) { + Map mapInfo = user.getMapManager().getMapInfo(); + mapInfo.remove(user.getMapManager().getCurXY()); + } + + /** + * 改变其他点eventId + * @param user + * @throws Exception + */ + public static void changeOtherPoint(User user, int pointId, int eventId) throws Exception { + Map mapInfo = user.getMapManager().getMapInfo(); + for (Cell cell : mapInfo.values()) { + if (cell.getPointId() == pointId) { + cell.setEventId(eventId); + } + } + } + } 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 a3749a282..c31709bb1 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 @@ -1,13 +1,10 @@ package com.ljsd.jieling.handler.map.behavior; -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 org.springframework.stereotype.Component; -import java.util.Map; - @Component public class DestroyPointBehavior extends BaseBehavior { @Override diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionBehavior.java index eccdc7a65..1a1b4aa03 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/MonitorMissionBehavior.java @@ -21,16 +21,6 @@ public class MonitorMissionBehavior 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); - } - return true; + return BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/TwentyFiveBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/TwentyFiveBehavior.java new file mode 100644 index 000000000..8570ad6b7 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/TwentyFiveBehavior.java @@ -0,0 +1,25 @@ +package com.ljsd.jieling.handler.map.behavior; + +import com.ljsd.jieling.handler.map.EventType; +import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.protocols.MapInfoProto; +import org.springframework.stereotype.Component; + +@Component +public class TwentyFiveBehavior extends BaseBehavior { + @Override + public int getBehaviorType() { + return EventType.twentyFive; + } + + @Override + public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { + boolean flag = BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse); + if (!flag) { + return flag; + } + BehaviorUtil.destoryCurPoint(user); + BehaviorUtil.changeOtherPoint(user, behaviorTypeValues[0][1], behaviorTypeValues[0][2]); + return true; + } +}