diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/CrossMapCell.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/CrossMapCell.java index 572cb2763..4e3ab3d53 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/CrossMapCell.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/CrossMapCell.java @@ -10,19 +10,19 @@ public class CrossMapCell { // missionId 存在某个地图的任务 private Set missionIds = new HashSet<>(); // 每日刷新 - private Set dayRefreshs = new HashSet<>(); + private Map dayRefreshs = new ConcurrentHashMap<>(); // 一次性事件 - private Set permanents = new HashSet<>(); + private Map permanents = new ConcurrentHashMap<>(); public Set getMissionIds() { return missionIds; } - public Set getDayRefreshs() { + public Map getDayRefreshs() { return dayRefreshs; } - public Set getPermanents() { + public Map getPermanents() { return permanents; } } 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 efafed04f..c0e3a51e6 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 @@ -190,11 +190,22 @@ public class MapLogic { LOGGER.info("====initMap()====mapPointConfig == null======>{}", scMap1.getEvent()); continue; } - if (crossMapCell != null && crossMapCell.getDayRefreshs().contains(mapPointConfig.getId())) { - continue; + int initialEventId = mapPointConfig.getInitialEventId(); + if (crossMapCell != null && crossMapCell.getDayRefreshs().containsKey(mapPointConfig.getId())) { + int eventId = crossMapCell.getDayRefreshs().get(mapPointConfig.getId()); + if (eventId == -1) { + continue; + } else { + initialEventId = eventId; + } } - if (crossMapCell != null && crossMapCell.getPermanents().contains(mapPointConfig.getId())) { - continue; + if (crossMapCell != null && crossMapCell.getPermanents().containsKey(mapPointConfig.getId())) { + int eventId = crossMapCell.getPermanents().get(mapPointConfig.getId()); + if (eventId == -1) { + continue; + } else { + initialEventId = eventId; + } } for (Mission mission : missions) { if (mission.getMapPoints().containsKey(mapPointConfig.getId())) { @@ -206,7 +217,7 @@ public class MapLogic { break; } } - Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); + Cell cellValue = new Cell(xy, initialEventId, mapPointConfig.getId()); if (mapPointConfig.getStyle() == EventType.enter) { mapManager.setCurXY(xy); } @@ -461,9 +472,36 @@ public class MapLogic { } // 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); + saveRefreshInfo(optionId, mapManager, mapPointConfig, nextEventId); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); } + public void saveRefreshInfo(int optionId, MapManager mapManager, MapPointConfig mapPointConfig, int nextEventId) throws Exception { + CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId()); + if (crossMapCell == null) { + crossMapCell = new CrossMapCell(); + } + if (mapPointConfig.getRefresh() == 1) { + if (crossMapCell.getDayRefreshs().containsKey(optionId)) { + int saveEventId = crossMapCell.getDayRefreshs().get(optionId); + if (saveEventId == -1) { + return; + } + } + crossMapCell.getDayRefreshs().put(optionId, nextEventId); + } + if (mapPointConfig.getRefresh() == 3) { + if (crossMapCell.getPermanents().containsKey(optionId)) { + int saveEventId = crossMapCell.getPermanents().get(optionId); + if (saveEventId == -1) { + return; + } + } + crossMapCell.getPermanents().put(optionId, nextEventId); + } + mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapCell); + } + private int getNextPoint(User user, MapManager mapManager, int[][] jumpTypeValues, SOptionAddCondition sOptionAddConditions) { int nextEventId = 0; switch (sOptionAddConditions.getType()) { 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 db3e1307e..6febf68aa 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 @@ -1,9 +1,7 @@ package com.ljsd.jieling.handler.map.behavior; -import com.google.gson.Gson; import com.googlecode.protobuf.format.JsonFormat; import com.ljsd.jieling.config.MapPointConfig; -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.Cell; @@ -13,19 +11,14 @@ import com.ljsd.jieling.handler.map.MapManager; 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.OnlineUserManager; import com.ljsd.jieling.logic.dao.Hero; import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.hero.HeroLogic; -import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.FightInfoProto; import com.ljsd.jieling.protocols.MapInfoProto; -import com.ljsd.jieling.protocols.MessageTypeProto; -import com.ljsd.jieling.util.CBean2Proto; import com.ljsd.jieling.util.MonsterUtil; -import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,10 +59,10 @@ public class BehaviorUtil { crossMapCell = new CrossMapCell(); } if (mapPointConfig.getRefresh() == 1) { - crossMapCell.getDayRefreshs().add(needDistoryPointId); + crossMapCell.getDayRefreshs().put(needDistoryPointId, -1); } if (mapPointConfig.getRefresh() == 3) { - crossMapCell.getPermanents().add(needDistoryPointId); + crossMapCell.getPermanents().put(needDistoryPointId, -1); } mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapCell); }