地图探索修改
parent
b3a7c9838f
commit
6db6e061a5
|
@ -4,7 +4,7 @@ int int mut,int#int,2
|
|||
2 3 1#5#3
|
||||
3 3 1#2#3
|
||||
4 1 1#101016#101112
|
||||
5 1 1#102022#102065
|
||||
5 1 1#102022#102061
|
||||
6 2 1503#1
|
||||
7 3 1#3#3
|
||||
8 3 1#4#3
|
||||
|
|
|
@ -44,8 +44,7 @@ public class MapPointConfig implements BaseConfig{
|
|||
private int initialEventId;
|
||||
|
||||
/**
|
||||
* 消耗行动力
|
||||
* 1:移动消耗行动力,触发事件不消耗 2:移动不消耗,触发事件消耗
|
||||
* 触发事件消耗行动力
|
||||
*/
|
||||
private int confused;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ public class Cell extends MongoBase {
|
|||
|
||||
private int eventId;
|
||||
|
||||
private boolean isCostStep;
|
||||
|
||||
public Cell() {
|
||||
}
|
||||
|
||||
|
@ -42,4 +44,12 @@ public class Cell extends MongoBase {
|
|||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public boolean isCostStep() {
|
||||
return isCostStep;
|
||||
}
|
||||
|
||||
public void setCostStep(boolean costStep) {
|
||||
updateString("isCostStep", isCostStep);
|
||||
isCostStep = costStep;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,16 +242,20 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int leftStep = mapManager.getTotalStep() - cells.size();
|
||||
if (leftStep <= 0) {
|
||||
leftStep = 0;
|
||||
resetMapInfo(user, false);
|
||||
LOGGER.info("updateMap() uid=>{}, leftStep=>{}", uid, leftStep);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder().build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
return;
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
int moveConfused = scMapConfig.getMoveConfused();
|
||||
if (moveConfused > 0) {
|
||||
int leftStep = mapManager.getTotalStep() - cells.size() * moveConfused;
|
||||
if (leftStep <= 0) {
|
||||
leftStep = 0;
|
||||
resetMapInfo(user, false);
|
||||
LOGGER.info("updateMap() uid=>{}, leftStep=>{}", uid, leftStep);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder().build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
return;
|
||||
}
|
||||
mapManager.setTotalStep(leftStep);
|
||||
}
|
||||
mapManager.setTotalStep(leftStep);
|
||||
Cell cell = mapManager.getMapInfo().get(curXY);
|
||||
if (cell == null) {
|
||||
cell = mapManager.getMapInfo().get(triggerXY);
|
||||
|
@ -279,6 +283,7 @@ public class MapLogic {
|
|||
* @param optionId
|
||||
*/
|
||||
public void updateEvent(ISession session, int eventId, int optionId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
LOGGER.info("updateEvent() client param eventId=>{} optionId=>{}", eventId, optionId);
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
|
@ -338,14 +343,15 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
// 2:移动不消耗,触发事件消耗
|
||||
// if (mapPointConfig.getConfuced() == 2) {
|
||||
// if (mapManager.getTotalStep() < ) {
|
||||
// LOGGER.info("sOptionConfig == null=>{}", optionId);
|
||||
// MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// 触发消耗
|
||||
if (mapPointConfig.getConfused() > 0 && !cell.isCostStep()) {
|
||||
if (mapManager.getTotalStep() < mapPointConfig.getConfused()) {
|
||||
LOGGER.info("sOptionConfig step not enough leftStep=>{} needStep=>{}", mapManager.getTotalStep(), mapPointConfig.getConfused());
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
mapManager.setTotalStep(mapManager.getTotalStep() - mapPointConfig.getConfused());
|
||||
}
|
||||
int behaviorType = sOptionConfig.getBehaviorType();
|
||||
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
|
||||
BaseBehavior baseBehavior = baseBehaviorMap.get(behaviorType);
|
||||
|
@ -359,7 +365,7 @@ public class MapLogic {
|
|||
}
|
||||
}
|
||||
int jumpType = sOptionConfig.getJumpType();
|
||||
int nextPoint = 0;
|
||||
int nextEventId = 0;
|
||||
int[][] jumpTypeValues = sOptionConfig.getJumpTypeValues();
|
||||
switch (jumpType) {
|
||||
// 1 无条件跳转,对应事件点
|
||||
|
@ -367,7 +373,7 @@ public class MapLogic {
|
|||
case 1:
|
||||
case 5:
|
||||
case 6:{
|
||||
nextPoint = jumpTypeValues[0][0];
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
break;
|
||||
}
|
||||
// 2 权重跳转,1001#1002|0.2#0.8
|
||||
|
@ -376,9 +382,9 @@ public class MapLogic {
|
|||
case 9:{
|
||||
int ranom = MathUtils.randomInt(100) + 1;
|
||||
if (ranom >= jumpTypeValues[1][0]) {
|
||||
nextPoint = jumpTypeValues[0][0];
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
} else {
|
||||
nextPoint = jumpTypeValues[0][1];
|
||||
nextEventId = jumpTypeValues[0][1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -392,16 +398,12 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
nextPoint = getNextPoint(user, mapManager, jumpTypeValues, sOptionAddConditions);
|
||||
nextEventId = getNextPoint(user, mapManager, jumpTypeValues, sOptionAddConditions);
|
||||
break;
|
||||
}
|
||||
// 4 不跳转,关闭界面
|
||||
case 4:{
|
||||
nextPoint = cell.getEventId();
|
||||
break;
|
||||
}
|
||||
case 11:{
|
||||
nextPoint = cell.getEventId();
|
||||
nextEventId = cell.getEventId();
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
|
@ -415,8 +417,9 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
// 检测该事件点是否已被销毁
|
||||
if (cell != null) {
|
||||
cell.setEventId(nextPoint);
|
||||
if (cell != null && nextEventId != 0) {
|
||||
cell.setCostStep(true);
|
||||
cell.setEventId(nextEventId);
|
||||
mapManager.addOrUpdateCell(mapManager.getCurXY(), cell);
|
||||
}
|
||||
if (behaviorType == EventType.dun && eventUpdateResponse.getMissionCount() > 0) {
|
||||
|
@ -443,37 +446,84 @@ public class MapLogic {
|
|||
.addAllEventBehaviorValues(eventBehaviorValuesList)
|
||||
.build();
|
||||
eventUpdateResponse.setEventBehaviorCommon(eventBehaviorCommon);
|
||||
eventUpdateResponse.setEventId(nextPoint);
|
||||
eventUpdateResponse.setEventId(nextEventId);
|
||||
eventUpdateResponse.setLeftStep(mapManager.getTotalStep());
|
||||
if (dropBuilder != null) {
|
||||
eventUpdateResponse.setDrop(dropBuilder);
|
||||
}
|
||||
LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextPoint=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
||||
cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextPoint, 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);
|
||||
}
|
||||
|
||||
private int getNextPoint(User user, MapManager mapManager, int[][] jumpTypeValues, SOptionAddCondition sOptionAddConditions) {
|
||||
int nextPoint = 0;
|
||||
int nextEventId = 0;
|
||||
switch (sOptionAddConditions.getType()) {
|
||||
// 1 完成事件点,即进度100%
|
||||
case 1:{
|
||||
int doneEvent = sOptionAddConditions.getValues()[0][0];
|
||||
for (Cell cell1 : mapManager.getMapInfo().values()) {
|
||||
if (cell1.getPointId() == doneEvent) {
|
||||
if (cell1.getEventId() >= sOptionAddConditions.getValues()[0][1]) {
|
||||
nextPoint = jumpTypeValues[0][0];
|
||||
int condition = sOptionAddConditions.getValues()[0][0];
|
||||
// 0或 1和
|
||||
if (condition == 1) {
|
||||
Set<Integer> flags = new HashSet<>();
|
||||
int rand = 0;
|
||||
for (int i = 1; i < sOptionAddConditions.getValues()[0].length; i++) {
|
||||
rand++;
|
||||
int eventId = sOptionAddConditions.getValues()[0][i];
|
||||
i++;
|
||||
for (Cell cell1 : mapManager.getMapInfo().values()) {
|
||||
if (cell1.getPointId() == eventId) {
|
||||
if (cell1.getEventId() >= sOptionAddConditions.getValues()[0][i]) {
|
||||
flags.add(i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (flags.size() > 0 && flags.size() >= rand) {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
} else {
|
||||
Set<Integer> flags = new HashSet<>();
|
||||
for (int i = 1; i < sOptionAddConditions.getValues()[0].length; i++) {
|
||||
int eventId = sOptionAddConditions.getValues()[0][i];
|
||||
i++;
|
||||
for (Cell cell1 : mapManager.getMapInfo().values()) {
|
||||
if (cell1.getPointId() == eventId) {
|
||||
if (cell1.getEventId() >= sOptionAddConditions.getValues()[0][i]) {
|
||||
flags.add(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flags.size() > 0) {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 2 物品数量
|
||||
case 2:{
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
int[][] values = sOptionAddConditions.getValues();
|
||||
for (int i = 0; i < values[0].length; i++) {
|
||||
itemMap.put(values[0][i], values[0][i++]);
|
||||
}
|
||||
boolean b = ItemUtil.checkCost(user, itemMap);
|
||||
if (b) {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 3 角色属性
|
||||
case 3:{
|
||||
int[][] values = sOptionAddConditions.getValues();
|
||||
// 1: 全队 0: 最高
|
||||
if (values[0][0] == 1) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 完成某个任务的第几步
|
||||
|
@ -481,23 +531,23 @@ public class MapLogic {
|
|||
Set<Integer> finishMissions = user.getMissionManager().getFinishMissions();
|
||||
Set<Integer> takeRewardMissions = user.getMissionManager().getTakeRewardMissions();
|
||||
if (finishMissions.contains(sOptionAddConditions.getValues()[0][0]) || takeRewardMissions.contains(sOptionAddConditions.getValues()[0][0])) {
|
||||
nextPoint = jumpTypeValues[0][0];
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
if (nextPoint == 0) {
|
||||
if (nextEventId == 0) {
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(sOptionAddConditions.getValues()[0][0]);
|
||||
if (mission == null || mission.getMissionStep() < jumpTypeValues[0][1]) {
|
||||
nextPoint = jumpTypeValues[0][1];
|
||||
nextEventId = jumpTypeValues[0][1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
nextPoint = jumpTypeValues[0][1];
|
||||
nextEventId = jumpTypeValues[0][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nextPoint;
|
||||
return nextEventId;
|
||||
}
|
||||
|
||||
public CommonProto.Mission getMission(Mission mission) {
|
||||
|
@ -548,6 +598,7 @@ public class MapLogic {
|
|||
mapManager.setWalkCells(new HashSet<>());
|
||||
mapManager.setCurXY(0);
|
||||
mapManager.setCurMapId(0);
|
||||
mapManager.setTotalStep(0);
|
||||
if (needTemporaryItem) {
|
||||
TemporaryItems temporaryItems = mapManager.getTemporaryItems();
|
||||
if (temporaryItems != null) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void updateCrossMapInfos(int key, CrossMapCell crossMapCell) throws Exception {
|
||||
updateString("mapInfo." + key, crossMapCell);
|
||||
updateString("crossMapInfos." + key, crossMapCell);
|
||||
crossMapInfos.put(key, crossMapCell);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ public class BehaviorUtil {
|
|||
if (mapPointConfig.getRefresh() == 3) {
|
||||
crossMapCell.getPermanents().add(needDistoryPointId);
|
||||
}
|
||||
mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapCell);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkCost(User user, Map<Integer, Integer> itemMap) {
|
||||
public static boolean checkCost(User user, Map<Integer, Integer> itemMap) {
|
||||
if (itemMap == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue