触发的点 统一保存
parent
baf73f9440
commit
1cc21efa66
|
@ -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);
|
||||
|
|
|
@ -207,21 +207,7 @@ public class MapLogic {
|
|||
Map<Integer, Cell> newMap = new HashMap<>();
|
||||
Map<Integer, Cell> spicelMap = new HashMap<>();
|
||||
Random random = new Random();
|
||||
CrossMapCell crossMapCell1 = mapManager.getCrossMapInfos().get(mapManager.getCurMapId());
|
||||
Set<Mission> missions = new HashSet<>();
|
||||
if (crossMapCell1 != null) {
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
for (Integer doingMissionId : crossMapCell1.getMissionIds()) {
|
||||
if (doingMissions.containsKey(doingMissionId)) {
|
||||
Mission mission = doingMissions.get(doingMissionId);
|
||||
missions.add(mission);
|
||||
for (Map.Entry<Integer, Cell> 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<Integer, SCMap> 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<Integer, Cell> 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);
|
||||
|
|
|
@ -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<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
||||
Set<Integer> needDelete = new HashSet<>();
|
||||
|
@ -42,13 +42,12 @@ public class BehaviorUtil {
|
|||
needDelete.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
for (Map.Entry<Integer, Mission> entry : doingMissions.entrySet()) {
|
||||
Mission mission = entry.getValue();
|
||||
Map<Integer, Cell> missionInfos = mission.getMissionInfos();
|
||||
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(mapId);
|
||||
if (crossMapCell != null) {
|
||||
Map<Integer, Cell> 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Integer, Mission> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Integer, Integer> mapPoints = new ConcurrentHashMap<>();
|
||||
|
||||
// 地图坐标,事件点
|
||||
private Map<Integer, Cell> missionInfos = new ConcurrentHashMap<>();
|
||||
|
||||
public int getMissionId() {
|
||||
return missionId;
|
||||
}
|
||||
|
@ -38,20 +28,6 @@ public class Mission extends MongoBase {
|
|||
this.missionStep = missionStep;
|
||||
}
|
||||
|
||||
public Map<Integer, Cell> 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<Integer, Integer> 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;
|
||||
}
|
||||
|
|
|
@ -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<Integer> 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<Integer, Cell> 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<Integer, Cell> 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) {
|
||||
|
|
Loading…
Reference in New Issue