diff --git a/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java b/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java index e31e37b58..7967ad3f8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java @@ -60,6 +60,11 @@ public class RedisKey { * sub_key */ public static final String NEED_DESORY_ID = "NEED_DESORY_ID"; + /** + * 需要销毁的坐标 + * sub_key + */ + public static final String NEED_DESORY_XY = "NEED_DESORY_XY"; /** * 过期事件 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 da04e9eaa..ead5a7fb8 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 @@ -523,10 +523,8 @@ public class MapLogic { } } } - String key = RedisKey.getKey(RedisKey.FIGHT, user.getId() , false); - Map valueMap = RedisUtil.getInstence().hmget(key); CommonProto.Drop.Builder dropBuilder = null; - if (valueMap == null || valueMap.isEmpty()) { + if (sOptionConfig.getReward().length > 0) { dropBuilder = ItemUtil.drop(user, sOptionConfig.getReward(), 1, 1); } List eventBehaviorValuesList = new ArrayList<>(); @@ -549,8 +547,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=>{} {} sOptionConfig.getReward()=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(), +// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon,eventUpdateResponse.getDrop(), sOptionConfig.getReward()); saveRefreshInfo(pointId, mapManager, mapPointConfig, nextEventId); updateMapMission(mapManager,EventType.updateEvent,pointId,0); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); @@ -795,7 +793,7 @@ public class MapLogic { } String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false); String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey); - int groupId; + int groupId, destoryXY = 0; String missionId = "0", destroyId = "0"; if (fightReady != null) { String[] split = fightReady.split("#"); @@ -815,9 +813,10 @@ public class MapLogic { return; } groupId = option[0]; + destoryXY = mapManager.getTriggerXY(); } FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder(); - BehaviorUtil.getFightInfo(user, groupId, fightStartResponse, missionId, destroyId); + BehaviorUtil.getFightInfo(user, groupId, fightStartResponse, missionId, destroyId, destoryXY); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true); } @@ -838,7 +837,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "此战斗已结算过!"); return; } - int seed = Integer.parseInt((String)valueMap.get(RedisKey.FIGHT_SEED)); int monsterGroupId = Integer.parseInt((String)valueMap.get(RedisKey.FIGHT_GROUPID)); CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder(); @@ -869,7 +867,6 @@ public class MapLogic { for (int i = 1; i < checkResult.length; i++) { remainHp.add(checkResult[i]); } - //校验结果码 1:胜利 int resultCode = checkResult[0]; if (resultCode == -1){ @@ -904,6 +901,7 @@ public class MapLogic { fightEndResponse.build(); int missionId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_MISSION_ID)); int destoryId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_DESORY_ID)); + int destoryXY = Integer.parseInt((String)valueMap.get(RedisKey.NEED_DESORY_XY)); if (missionId != 0) { MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder(); BehaviorUtil.updateMission(user, missionId, eventUpdateResponse); @@ -912,10 +910,12 @@ public class MapLogic { if (destoryId != 0) { BehaviorUtil.distoryPoint(user, destoryId); } + if (destoryXY != 0) { + BehaviorUtil.distoryApointXY(user, destoryXY); + } updateMapMission(user.getMapManager(),EventType.fightEvent,0,monsterGroupId); +// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} drop=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getDrop()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.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 968bfb3ed..c5adf1f49 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 @@ -69,6 +69,19 @@ public class BehaviorUtil { } + /** + * 销毁指定事件点坐标 + * @param user + * @throws Exception + */ + public static void distoryApointXY(User user, int destoryXY) throws Exception { + MapManager mapManager = user.getMapManager(); + Map mapInfo = mapManager.getMapInfo(); + mapInfo.remove(destoryXY); + mapManager.setMapInfo(mapInfo); + } + + public static void fightReady(String uid, String readyInfo) { String key = RedisKey.getKey(RedisKey.FIGHT_READY, uid, false); RedisUtil.getInstence().set(key, readyInfo, RedisKey.EXPIRE_TIME); @@ -81,7 +94,7 @@ public class BehaviorUtil { * @param fightStartRespons * @throws Exception */ - public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String missionId, String destoryId) throws Exception { + public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String missionId, String destoryId, int destoryXY) throws Exception { MapManager mapManager = user.getMapManager(); int teamId = mapManager.getTeamId(); @@ -139,6 +152,7 @@ public class BehaviorUtil { fightInfo.put(RedisKey.FIGHT_GROUPID, Integer.toString(groupId)); fightInfo.put(RedisKey.NEED_MISSION_ID, missionId); fightInfo.put(RedisKey.NEED_DESORY_ID, destoryId); + fightInfo.put(RedisKey.NEED_DESORY_XY, Integer.toString(destoryXY)); RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointAndBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointAndBehavior.java index b726810b0..d88474323 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointAndBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/DestroyPointAndBehavior.java @@ -14,9 +14,9 @@ public class DestroyPointAndBehavior extends BaseBehavior { @Override public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { - BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][1]); - // TODO 监视地图 - + // 怪物组id#任务id#需要销毁事件id + String readyInfo = Integer.toString(behaviorTypeValues[0][1]) + "#" + 0 + "#" + behaviorTypeValues[0][1]; + BehaviorUtil.fightReady(user.getId(), readyInfo); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/FightAndDestroyPointBehavior.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/FightAndDestroyPointBehavior.java index 0053e5811..7425545df 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/FightAndDestroyPointBehavior.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/FightAndDestroyPointBehavior.java @@ -14,6 +14,7 @@ public class FightAndDestroyPointBehavior extends BaseBehavior { @Override public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { + // 怪物组id#任务id#需要销毁事件id String readyInfo = Integer.toString(behaviorTypeValues[0][1]) + "#" + Integer.toString(behaviorTypeValues[0][0]) + "#" + behaviorTypeValues[0][2]; BehaviorUtil.fightReady(user.getId(), readyInfo); // 放在战斗胜利后