地图探索
parent
a17ef696d3
commit
66b7367e4d
|
|
@ -1,50 +0,0 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "MapConfig")
|
||||
public class SCMapConfig implements BaseConfig {
|
||||
public static Map<Integer, SCMapConfig> sCMapSize;
|
||||
private int id;
|
||||
private String info;
|
||||
private int[] size; // 0:行 1列
|
||||
private int moveConfused; //地图上的行动力消耗
|
||||
private int energyConfused; //妖灵师精力消耗
|
||||
private int[] openRule; //开启条件
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sCMapSize = STableManager.getConfig(SCMapConfig.class);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public static Map<Integer, SCMapConfig> getsCMapSize() {
|
||||
return sCMapSize;
|
||||
}
|
||||
|
||||
public int[] getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getMoveConfused() {
|
||||
return moveConfused;
|
||||
}
|
||||
|
||||
public int getEnergyConfused() {
|
||||
return energyConfused;
|
||||
}
|
||||
|
||||
public int[] getOpenRule() {
|
||||
return openRule;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "ChallengeConfig")
|
||||
public class SChallengeConfig implements BaseConfig {
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sChallengeConfigs = STableManager.getConfig(SChallengeConfig.class);
|
||||
}
|
||||
|
||||
public static Map<Integer, SChallengeConfig> sChallengeConfigs;
|
||||
|
||||
private int id;
|
||||
|
||||
private int mapId;
|
||||
|
||||
private int[][] openRule;
|
||||
|
||||
private int mapTime;
|
||||
|
||||
private int[] reviveTime;
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getMapId() {
|
||||
return mapId;
|
||||
}
|
||||
|
||||
public int[][] getOpenRule() {
|
||||
return openRule;
|
||||
}
|
||||
|
||||
public int getMapTime() {
|
||||
return mapTime;
|
||||
}
|
||||
|
||||
public int[] getReviveTime() {
|
||||
return reviveTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "ChallengeMapConfig")
|
||||
public class SChallengeMapConfig implements BaseConfig{
|
||||
|
||||
public static Map<Integer, SChallengeMapConfig> integerSChallengeMapConfigMap;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
integerSChallengeMapConfigMap = STableManager.getConfig(SChallengeMapConfig.class);
|
||||
}
|
||||
|
||||
private int mapId;
|
||||
|
||||
private int missionId;
|
||||
|
||||
private int[] size;
|
||||
|
||||
public int getMapId() {
|
||||
return mapId;
|
||||
}
|
||||
|
||||
public int getMissionId() {
|
||||
return missionId;
|
||||
}
|
||||
|
||||
public int[] getSize() {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
@ -92,34 +92,32 @@ public class GMRequestHandler extends BaseHandler{
|
|||
}
|
||||
break;
|
||||
case GlobalGm.OPEN_MAP:
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(100 + prarm1);
|
||||
Set<Integer> missionIds = new HashSet<>();
|
||||
MapManager mapManager = cUser.getMapManager();
|
||||
if (scMapConfig != null) {
|
||||
for (int i = 1; i <= prarm1; i++) {
|
||||
int mapId = 100 + i;
|
||||
SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(mapId);
|
||||
if (crossMap.getOpenRule() != null && crossMap.getOpenRule().length > 0) {
|
||||
missionIds.add(crossMap.getOpenRule()[0]);
|
||||
}
|
||||
initFininshMapMission(mapManager,mapId);
|
||||
}
|
||||
}
|
||||
cUser.getPlayerInfoManager().setMapId(scMapConfig.getId());
|
||||
SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(scMapConfig.getId() + 1);
|
||||
if (crossMap == null || crossMap.getOpenRule().length == 0) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, Mission> doingMissions = cUser.getMissionManager().getDoingMissions();
|
||||
for (Integer key : doingMissions.keySet()) {
|
||||
cUser.getMissionManager().removeDoingMissions(key);
|
||||
}
|
||||
Mission mission = new Mission();
|
||||
mission.setMissionId(crossMap.getOpenRule()[0]);
|
||||
mission.setMissionStep(0);
|
||||
mission.setOpen(false);
|
||||
cUser.getMissionManager().updateOneDoingMissions(crossMap.getOpenRule()[0], mission);
|
||||
cUser.getMissionManager().updateFinishMissions(missionIds);
|
||||
// SChallengeMapConfig scMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(100 + prarm1);
|
||||
// Set<Integer> missionIds = new HashSet<>();
|
||||
// MapManager mapManager = cUser.getMapManager();
|
||||
// if (scMapConfig != null) {
|
||||
// for (int i = 1; i <= prarm1; i++) {
|
||||
// int mapId = 100 + i;
|
||||
// SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(mapId);
|
||||
// if (crossMap.getOpenRule() != null && crossMap.getOpenRule().length > 0) {
|
||||
// missionIds.add(crossMap.getOpenRule()[0]);
|
||||
// }
|
||||
// initFininshMapMission(mapManager,mapId);
|
||||
// }
|
||||
// }
|
||||
// cUser.getPlayerInfoManager().setMapId(scMapConfig.getId());
|
||||
// SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(scMapConfig.getId() + 1);
|
||||
// if (crossMap == null || crossMap.getOpenRule().length == 0) {
|
||||
// return;
|
||||
// }
|
||||
// Map<Integer, Mission> doingMissions = cUser.getMissionManager().getDoingMissions();
|
||||
// for (Integer key : doingMissions.keySet()) {
|
||||
// cUser.getMissionManager().removeDoingMissions(key);
|
||||
// }
|
||||
// Mission mission = new Mission();
|
||||
// mission.setMissionId(crossMap.getOpenRule()[0]);
|
||||
// mission.setMissionStep(0);
|
||||
// cUser.getMissionManager().updateOneDoingMissions(crossMap.getOpenRule()[0], mission);
|
||||
break;
|
||||
case GlobalGm.ONE_KEY_ITEM_OR_HERO:{
|
||||
//道具
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
|
@ -47,11 +45,6 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
// 需要隔天刷新的字段统一在这里处理
|
||||
if (TimeUtils.isOverTime(0, user.getLoginTime())) {
|
||||
user.setLoginTime(TimeUtils.now());
|
||||
// 地图刷新
|
||||
MapLogic.getInstance().refreshMapInfo(user);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CrossMapCell {
|
||||
|
||||
// missionId 存在某个地图的任务
|
||||
private Set<Integer> missionIds = new HashSet<>();
|
||||
// 每日刷新
|
||||
private Map<Integer, Integer> dayRefreshs = new ConcurrentHashMap<>();
|
||||
// 一次性事件
|
||||
private Map<Integer, Integer> permanents = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<Integer, Cell> behaviorTriggers = new ConcurrentHashMap<>();
|
||||
|
||||
public Set<Integer> getMissionIds() {
|
||||
return missionIds;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getDayRefreshs() {
|
||||
return dayRefreshs;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
|
||||
public Map<Integer, Cell> getBehaviorTriggers() {
|
||||
return behaviorTriggers;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,11 @@ package com.ljsd.jieling.handler.map;
|
|||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.config.*;
|
||||
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.behavior.BaseBehavior;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.handler.mission.CheckMissionReturn;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
|
|
@ -67,7 +67,6 @@ public class MapLogic {
|
|||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
int energy = mapManager.getEnergy();
|
||||
if (teamId == 0) {
|
||||
LOGGER.info("enterMap() uid=>{} teamId =>{} ", uid, teamId);
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
|
|
@ -75,8 +74,7 @@ public class MapLogic {
|
|||
}
|
||||
// 初始序章地图
|
||||
if (user.getPlayerInfoManager().getMapId() == 0) {
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(100);
|
||||
String error = initTeamInfo(teamId, uid, user, mapManager, scMapConfig.getMoveConfused());
|
||||
String error = initTeamInfo(teamId, uid, user, mapManager);
|
||||
if (!error.isEmpty()){
|
||||
LOGGER.info("enterMap() uid=>{} error =>{} ", uid, error);
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
|
|
@ -95,21 +93,21 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId);
|
||||
if (scMapConfig == null || scMapConfig.getOpenRule() == null || scMapConfig.getOpenRule().length == 0) {
|
||||
LOGGER.info("enterMap() uid=>{} mapId=>{}, scMapConfig.getOpenRule()=>{}", uid, mapId, scMapConfig == null ? "" : scMapConfig.getOpenRule());
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int missionId = scMapConfig.getOpenRule()[0];
|
||||
if (!user.getMissionManager().getFinishMissions().contains(missionId) && !user.getMissionManager().getTakeRewardMissions().contains(missionId)) {
|
||||
Mission mission = user.getMissionManager().getDoingMissions().get(missionId);
|
||||
if (mission == null || mission.getMissionStep() < scMapConfig.getOpenRule()[1]) {
|
||||
LOGGER.info("enterMap() uid=>{} map not open == missionId =>{} step=>{}", uid, missionId, mission == null ? 0 : mission.getMissionStep());
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要完成任务:" + (scMapConfig == null ? "" : scMapConfig.getOpenRule()[0] + "#" + scMapConfig.getOpenRule()[1]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
SChallengeMapConfig scMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(mapId);
|
||||
// if (scMapConfig == null || scMapConfig.getOpenRule() == null || scMapConfig.getOpenRule().length == 0) {
|
||||
// LOGGER.info("enterMap() uid=>{} mapId=>{}, scMapConfig.getOpenRule()=>{}", uid, mapId, scMapConfig == null ? "" : scMapConfig.getOpenRule());
|
||||
// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
// return;
|
||||
// }
|
||||
// int missionId = scMapConfig.getOpenRule()[0];
|
||||
// if (!user.getMissionManager().getTakeRewardMissions().contains(missionId)) {
|
||||
// Mission mission = user.getMissionManager().getDoingMissions().get(missionId);
|
||||
// if (mission == null || mission.getMissionStep() < scMapConfig.getOpenRule()[1]) {
|
||||
// LOGGER.info("enterMap() uid=>{} map not open == missionId =>{} step=>{}", uid, missionId, mission == null ? 0 : mission.getMissionStep());
|
||||
// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要完成任务:" + (scMapConfig == null ? "" : scMapConfig.getOpenRule()[0] + "#" + scMapConfig.getOpenRule()[1]));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
if (user.getPlayerInfoManager().getMapId() < mapId) {
|
||||
user.getPlayerInfoManager().setMapId(mapId);
|
||||
}
|
||||
|
|
@ -118,20 +116,12 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (energy < scMapConfig.getEnergyConfused()) {
|
||||
LOGGER.info("enterMap() uid=>{} energy=>{} need=>{} energy not enough ", uid, energy, scMapConfig.getEnergyConfused());
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "精力不足!");
|
||||
return;
|
||||
}
|
||||
String error = initTeamInfo(teamId, uid, user, mapManager, scMapConfig.getMoveConfused());
|
||||
String error = initTeamInfo(teamId, uid, user, mapManager);
|
||||
if (!error.isEmpty()){
|
||||
LOGGER.info("enterMap() uid=>{} error =>{} ", uid, error);
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int leftEnergy = energy - scMapConfig.getEnergyConfused();
|
||||
mapManager.setEnergy(leftEnergy);
|
||||
mapManager.setCurMapId(mapId);
|
||||
initMap(mapManager, user);
|
||||
user.setMapManager(mapManager);
|
||||
|
|
@ -151,8 +141,9 @@ public class MapLogic {
|
|||
CommonProto.FoodBuffer foodBuffer = CBean2Proto.getFoodBuffer(buffEntry.getKey(), buffEntry.getValue());
|
||||
mapEnterResponse.addFoodBuffers(foodBuffer);
|
||||
}
|
||||
mapEnterResponse.setMissions(getMission(mapManager.getMission()));
|
||||
mapEnterResponse.addAllMapList(cells);
|
||||
mapEnterResponse.setLeftStep(mapManager.getTotalStep());
|
||||
mapEnterResponse.setLeftTime(getLeftTime(mapManager));
|
||||
mapEnterResponse.setCurXY(mapManager.getCurXY());
|
||||
mapEnterResponse.addAllWakeCells(mapManager.getWalkCells() == null ? new ArrayList<>() : mapManager.getWalkCells());
|
||||
if (mapManager.getTemporaryItems() != null) {
|
||||
|
|
@ -161,12 +152,11 @@ public class MapLogic {
|
|||
MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse.build(), true);
|
||||
}
|
||||
|
||||
private String initTeamInfo(int teamId, int uid, User user, MapManager mapManager, int moveUse) throws Exception {
|
||||
private String initTeamInfo(int teamId, int uid, User user, MapManager mapManager) throws Exception {
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) {
|
||||
return "阵容不存在";
|
||||
}
|
||||
int totalStep = 0;
|
||||
List<String> heroes = new ArrayList<>(teamPosHeroInfos.size());
|
||||
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
|
||||
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
|
||||
|
|
@ -176,7 +166,6 @@ public class MapLogic {
|
|||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
|
||||
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
|
||||
hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId()));
|
||||
totalStep += HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.ACTION_POWER_RORMULA_TYPE);
|
||||
heroes.add(heroInfo.getHeroId());
|
||||
}
|
||||
if (heroes.size() != teamPosHeroInfos.size()) {
|
||||
|
|
@ -184,7 +173,6 @@ public class MapLogic {
|
|||
return "阵容有误";
|
||||
}
|
||||
mapManager.setTeamId(teamId);
|
||||
mapManager.setTotalStep(totalStep + moveUse * 5);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +195,6 @@ public class MapLogic {
|
|||
Map<Integer, Cell> newMap = new HashMap<>();
|
||||
Map<Integer, Cell> spicelMap = new HashMap<>();
|
||||
Random random = new Random();
|
||||
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId());
|
||||
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
|
||||
SCMap scMap1 = entry.getValue();
|
||||
// 必出现的事件点
|
||||
|
|
@ -232,26 +219,7 @@ public class MapLogic {
|
|||
LOGGER.info("====initMap()====mapPointConfig == null======>{}", scMap1.getEvent());
|
||||
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().containsKey(mapPointConfig.getId())) {
|
||||
int eventId = crossMapCell.getPermanents().get(mapPointConfig.getId());
|
||||
if (eventId == -1) {
|
||||
continue;
|
||||
} else {
|
||||
initialEventId = eventId;
|
||||
}
|
||||
}
|
||||
Cell cellValue = new Cell(xy, initialEventId, mapPointConfig.getId());
|
||||
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
|
||||
if (mapPointConfig.getStyle() == EventType.enter) {
|
||||
mapManager.setCurXY(xy);
|
||||
}
|
||||
|
|
@ -261,59 +229,35 @@ public class MapLogic {
|
|||
newMap.put(xy, cellValue);
|
||||
}
|
||||
}
|
||||
if (crossMapCell != null) {
|
||||
for (Map.Entry<Integer, Cell> entry : crossMapCell.getBehaviorTriggers().entrySet()) {
|
||||
if (entry.getValue() == null || entry.getValue().getEventId() == -1) {
|
||||
continue;
|
||||
}
|
||||
newMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
if (user.getPlayerInfoManager().getMapId() == 100) {
|
||||
SGameSetting sGameSetting = SGameSetting.getGameSetting();
|
||||
int xy = CellUtil.xy2Pos(sGameSetting.getBornPosition()[0], sGameSetting.getBornPosition()[1]);
|
||||
mapManager.setCurXY(xy);
|
||||
}
|
||||
SChallengeMapConfig challengeMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(mapManager.getCurMapId());
|
||||
Mission mission = new Mission();
|
||||
mission.setMissionId(challengeMapConfig.getMissionId());
|
||||
mission.setMissionStep(0);
|
||||
mapManager.setMission(mission);
|
||||
mapManager.setMapInfo(newMap);
|
||||
mapManager.setTypeEight(spicelMap);
|
||||
initMapMission(mapManager);
|
||||
}
|
||||
|
||||
public boolean updateMapByOnlyConsumeActionPower(ISession session, int curXY,int triggerXY, List<Integer> cells,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
if(triggerXY == -1000){
|
||||
public boolean updateMapByOnlyConsumeActionPower(ISession session, int curXY, int triggerXY, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
if (triggerXY == -1000) {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
if( null == scMapConfig ){
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
mapManager.setTotalStep(leftStep);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder().build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
return true;
|
||||
}
|
||||
updateMapMission(mapManager,EventType.updateEvent,MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue(),cells.size() * moveConfused);
|
||||
mapManager.setTotalStep(leftStep);
|
||||
mapManager.addWalkCells(new HashSet<>(cells));
|
||||
mapManager.setCurXY(curXY);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder()
|
||||
.setLeftStep(mapManager.getTotalStep())
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
}
|
||||
mapManager.addWalkCells(new HashSet<>(cells));
|
||||
mapManager.setCurXY(curXY);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder()
|
||||
.setLeftTime(getLeftTime(mapManager))
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -338,8 +282,8 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
if (mapManager.getTotalStep() <= 0) {
|
||||
LOGGER.info("updateMap() uid=>{}, no step=>{}", uid, mapManager.getTotalStep());
|
||||
if (getLeftTime(mapManager) <= 0) {
|
||||
LOGGER.info("updateMap() uid=>{}, no step=>{}", uid, getLeftTime(mapManager));
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
|
|
@ -348,22 +292,6 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
|
||||
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;
|
||||
updateMapMission(mapManager,EventType.updateEvent,MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue(),cells.size() * moveConfused);
|
||||
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;
|
||||
}
|
||||
updateMapMission(mapManager,EventType.updateEvent,MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue(),cells.size() * moveConfused);
|
||||
mapManager.setTotalStep(leftStep);
|
||||
}
|
||||
Cell cell = mapManager.getMapInfo().get(triggerXY);
|
||||
if (cell == null) {
|
||||
cell = mapManager.getMapInfo().get(curXY);
|
||||
|
|
@ -378,7 +306,7 @@ public class MapLogic {
|
|||
mapManager.setCurXY(curXY);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder()
|
||||
.setEventId(cell.getEventId())
|
||||
.setLeftStep(mapManager.getTotalStep())
|
||||
.setLeftTime(getLeftTime(mapManager))
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
|
||||
}
|
||||
|
|
@ -448,6 +376,11 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
if (getLeftTime(mapManager) <= 0) {
|
||||
LOGGER.info("mapManager.getLeftTime() <= 0 =>{}", getLeftTime(mapManager));
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int behaviorType = sOptionConfig.getBehaviorType();
|
||||
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
|
||||
BaseBehavior baseBehavior = baseBehaviorMap.get(behaviorType);
|
||||
|
|
@ -546,55 +479,16 @@ public class MapLogic {
|
|||
.build();
|
||||
eventUpdateResponse.setEventBehaviorCommon(eventBehaviorCommon);
|
||||
eventUpdateResponse.setEventId(nextEventId);
|
||||
eventUpdateResponse.setLeftStep(mapManager.getTotalStep());
|
||||
eventUpdateResponse.setLeftTime(getLeftTime(mapManager));
|
||||
if (dropBuilder != null) {
|
||||
eventUpdateResponse.setDrop(dropBuilder);
|
||||
}
|
||||
// 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(mapManager.getCurMapId(), mapManager, mapPointConfig, cell);
|
||||
LOGGER.info("updatEvent() uid=>{},nextEventId={},eventId={}", uid, nextEventId, cell == null ? 0 : cell.getEventId());
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
|
||||
}
|
||||
|
||||
public void saveRefreshInfo(int mapId, MapManager mapManager, MapPointConfig mapPointConfig, Cell cell) throws Exception {
|
||||
int nextEventId = -1;
|
||||
if (cell != null) {
|
||||
nextEventId = cell.getEventId();
|
||||
}
|
||||
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapId);
|
||||
if (crossMapCell == null) {
|
||||
crossMapCell = new CrossMapCell();
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 1) {
|
||||
if (crossMapCell.getDayRefreshs().containsKey(mapPointConfig.getId())) {
|
||||
int saveEventId = crossMapCell.getDayRefreshs().get(mapPointConfig.getId());
|
||||
if (saveEventId == -1) {
|
||||
return;
|
||||
}
|
||||
if (saveEventId == nextEventId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
crossMapCell.getDayRefreshs().put(mapPointConfig.getId(), nextEventId);
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 3) {
|
||||
if (crossMapCell.getPermanents().containsKey(mapPointConfig.getId())) {
|
||||
int saveEventId = crossMapCell.getPermanents().get(mapPointConfig.getId());
|
||||
if (saveEventId == -1) {
|
||||
return;
|
||||
}
|
||||
if (saveEventId == nextEventId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
crossMapCell.getPermanents().put(mapPointConfig.getId(), nextEventId);
|
||||
}
|
||||
if (cell != null && crossMapCell.getBehaviorTriggers().containsKey(mapManager.getTriggerXY())) {
|
||||
crossMapCell.getBehaviorTriggers().put(mapManager.getTriggerXY(), cell);
|
||||
}
|
||||
mapManager.updateCrossMapInfos(mapId, crossMapCell);
|
||||
}
|
||||
|
||||
private int getNextPoint(User user, MapManager mapManager, int[][] jumpTypeValues, SOptionAddCondition sOptionAddConditions) {
|
||||
int nextEventId = 0;
|
||||
|
|
@ -691,27 +585,18 @@ public class MapLogic {
|
|||
return jumpTypeValues[0][1];
|
||||
}
|
||||
// 完成某个任务的第几步
|
||||
case 4:{
|
||||
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])) {
|
||||
case 4: {
|
||||
Mission mission = user.getMapManager().getMission();
|
||||
if (mission == null || mission.getMissionStep() < sOptionAddConditions.getValues()[0][1]) {
|
||||
nextEventId = jumpTypeValues[0][1];
|
||||
} else {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
if (nextEventId == 0) {
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(sOptionAddConditions.getValues()[0][0]);
|
||||
if (mission == null || mission.getMissionStep() < sOptionAddConditions.getValues()[0][1]) {
|
||||
nextEventId = jumpTypeValues[0][1];
|
||||
} else {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 当前是否处于某个任务的第几步,逻辑参数(0处于1不处于)#任务id#任务步数|…
|
||||
case 6:{
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(sOptionAddConditions.getValues()[0][1]);
|
||||
Mission mission = user.getMapManager().getMission();
|
||||
if (sOptionAddConditions.getValues()[0][0] == 0) {
|
||||
if (mission != null && mission.getMissionStep() == sOptionAddConditions.getValues()[0][2]) {
|
||||
nextEventId = jumpTypeValues[0][0];
|
||||
|
|
@ -740,7 +625,6 @@ public class MapLogic {
|
|||
openMission = CommonProto.Mission.newBuilder()
|
||||
.setItemId(mission.getMissionId())
|
||||
.setMissionStep(mission.getMissionStep())
|
||||
.setIsOpen(mission.isOpen())
|
||||
.setState("")
|
||||
.build();
|
||||
return openMission;
|
||||
|
|
@ -778,7 +662,7 @@ public class MapLogic {
|
|||
mapManager.setWalkCells(new HashSet<>());
|
||||
mapManager.setCurXY(0);
|
||||
mapManager.setCurMapId(0);
|
||||
mapManager.setTotalStep(0);
|
||||
mapManager.setStartExporeTime(0);
|
||||
mapManager.setTriggerXY(0);
|
||||
mapManager.setFoodBufferMap(new HashMap<>());
|
||||
TemporaryItems temporaryItems = mapManager.getTemporaryItems();
|
||||
|
|
@ -904,7 +788,7 @@ public class MapLogic {
|
|||
return;
|
||||
}else if(resultCode == 0){
|
||||
// 失败处理
|
||||
resetMapInfo(user,true);
|
||||
// resetMapInfo(user,true);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
FightInfoProto.FightEndResponse fightEndResponse = FightInfoProto.FightEndResponse
|
||||
.newBuilder()
|
||||
|
|
@ -959,17 +843,6 @@ public class MapLogic {
|
|||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 隔天刷新
|
||||
* @param user
|
||||
*/
|
||||
public void refreshMapInfo(User user) {
|
||||
Map<Integer, CrossMapCell> crossMapInfos = user.getMapManager().getCrossMapInfos();
|
||||
for (CrossMapCell crossMapCell : crossMapInfos.values()) {
|
||||
crossMapCell.getDayRefreshs().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initMapMission( MapManager mapManager){
|
||||
int mapId = mapManager.getCurMapId();
|
||||
|
|
@ -1024,9 +897,7 @@ public class MapLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//updateEvent optionalConfig获取
|
||||
if(eventType == EventType.updateEvent){
|
||||
if(logic == eventId){
|
||||
|
|
@ -1056,11 +927,8 @@ public class MapLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//todo 战斗结束处理
|
||||
if(eventType == EventType.fightEvent){
|
||||
if(logic == MapMissionType.KILL_BOSS.getMissionTypeValue()){
|
||||
|
|
@ -1161,4 +1029,55 @@ public class MapLogic {
|
|||
MapInfoProto.TakeMapBoxResponse build = MapInfoProto.TakeMapBoxResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
|
||||
public int getLeftTime(MapManager mapManager) {
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
|
||||
int useTime = (int) ((TimeUtils.now() - mapManager.getStartExporeTime()) / 1000);
|
||||
if (useTime >= sChallengeConfig.getMapTime()) {
|
||||
// resetMapInfo();
|
||||
return 0;
|
||||
} else {
|
||||
return sChallengeConfig.getMapTime() - useTime;
|
||||
}
|
||||
}
|
||||
|
||||
public CheckMissionReturn checkMission(Mission mission, User user) throws Exception {
|
||||
SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(mission.getMissionId());
|
||||
mission.setMissionStep(mission.getMissionStep() + 1);
|
||||
CheckMissionReturn checkMissionReturn = new CheckMissionReturn();
|
||||
if (mission.getMissionStep() >= sMissionEventsConfig.getMissionNum()) {
|
||||
if (mission.getMissionInfo() != null) {
|
||||
checkMissionReturn.newEventId = mission.getMissionInfo();
|
||||
}
|
||||
int[] reward = {sMissionEventsConfig.getReward()};
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, 1, 0);
|
||||
checkMissionReturn.drop = drop;
|
||||
} else {
|
||||
user.getMapManager().setMission(mission);
|
||||
}
|
||||
checkMissionReturn.missions.add(mission);
|
||||
return checkMissionReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始探索(开始计时)
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void startExplorte(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager.getMapInfo() == null) {
|
||||
LOGGER.info("mapManager.getMapInfo() == null");
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
mapManager.setStartExporeTime(TimeUtils.now());
|
||||
MapInfoProto.MapStartExploreResponse mapStartExploreResponse = MapInfoProto.MapStartExploreResponse.newBuilder()
|
||||
.setLeftTime(getLeftTime(mapManager))
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapStartExploreResponse, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SAccomplishmentConfig;
|
||||
import com.ljsd.jieling.config.SGameSetting;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
|
|
@ -31,12 +32,8 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private Set<Integer> walkCells;
|
||||
|
||||
private int totalStep;
|
||||
|
||||
private TemporaryItems temporaryItems;
|
||||
|
||||
private Map<Integer, CrossMapCell> crossMapInfos = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<Integer,Integer> foodBufferMap = new HashMap<>();
|
||||
|
||||
private Map<Integer, MapMission> allMissionProgress = new ConcurrentHashMap<>();
|
||||
|
|
@ -45,6 +42,12 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private int lastUpdateEnergyTime;
|
||||
|
||||
private long startExporeTime;
|
||||
|
||||
private boolean missionIsFinish;
|
||||
|
||||
private Mission mission;
|
||||
|
||||
public MapManager() {
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
|
@ -54,15 +57,6 @@ public class MapManager extends MongoBase {
|
|||
return mapInfo;
|
||||
}
|
||||
|
||||
public Map<Integer, CrossMapCell> getCrossMapInfos() {
|
||||
return crossMapInfos;
|
||||
}
|
||||
|
||||
public void updateCrossMapInfos(int key, CrossMapCell crossMapCell) throws Exception {
|
||||
updateString("crossMapInfos." + key, crossMapCell);
|
||||
crossMapInfos.put(key, crossMapCell);
|
||||
}
|
||||
|
||||
public int getCurMapId() {
|
||||
return curMapId;
|
||||
}
|
||||
|
|
@ -137,15 +131,6 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
}
|
||||
|
||||
public int getTotalStep() {
|
||||
return totalStep;
|
||||
}
|
||||
|
||||
public void setTotalStep(int totalStep) throws Exception {
|
||||
updateString( "totalStep", totalStep);
|
||||
this.totalStep = totalStep;
|
||||
}
|
||||
|
||||
public int getTriggerXY() {
|
||||
return triggerXY;
|
||||
}
|
||||
|
|
@ -254,4 +239,31 @@ public class MapManager extends MongoBase {
|
|||
updateString("foodBufferMap", foodBufferMap);
|
||||
this.foodBufferMap = foodBufferMap;
|
||||
}
|
||||
|
||||
public long getStartExporeTime() {
|
||||
return startExporeTime;
|
||||
}
|
||||
|
||||
public void setStartExporeTime(long startExporeTime) {
|
||||
updateString("startExporeTime", startExporeTime);
|
||||
this.startExporeTime = startExporeTime;
|
||||
}
|
||||
|
||||
public boolean isMissionIsFinish() {
|
||||
return missionIsFinish;
|
||||
}
|
||||
|
||||
public void setMissionIsFinish(boolean missionIsFinish) {
|
||||
updateString("missionIsFinish", missionIsFinish);
|
||||
this.missionIsFinish = missionIsFinish;
|
||||
}
|
||||
|
||||
public Mission getMission() {
|
||||
return mission;
|
||||
}
|
||||
|
||||
public void setMission(Mission mission) {
|
||||
updateString("mission", mission);
|
||||
this.mission = mission;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
|
|
@ -7,14 +7,16 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MissionGetAllRequestHandler extends BaseHandler {
|
||||
public class MapStartExploreRequestHandler extends BaseHandler{
|
||||
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.MISSION_GET_ALL_REQUEST;
|
||||
return MessageTypeProto.MessageType.MAP_START_EXPLORE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
MissionLogic.getInstance().getAllMissions(iSession, MessageTypeProto.MessageType.MISSION_GET_ALL_RESPONSE);
|
||||
MapLogic.getInstance().startExplorte(iSession, MessageTypeProto.MessageType.MAP_START_EXPLORE_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,10 @@ import com.ljsd.jieling.config.MapPointConfig;
|
|||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.CrossMapCell;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
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.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
|
@ -42,55 +40,17 @@ public class BehaviorUtil {
|
|||
needDelete.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(mapId);
|
||||
if (crossMapCell != null) {
|
||||
Map<Integer, Cell> behaviorTriggers = crossMapCell.getBehaviorTriggers();
|
||||
for (Integer xy : needDelete) {
|
||||
if (behaviorTriggers.containsKey(xy)) {
|
||||
behaviorTriggers.remove(xy);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Integer xy : needDelete) {
|
||||
mapInfo.remove(xy);
|
||||
}
|
||||
mapManager.setMapInfo(mapInfo);
|
||||
addRefreshInfo(needDistoryPointId, mapManager, mapManager.getCurMapId());
|
||||
}
|
||||
|
||||
public static void addRefreshInfo(int needDistoryPointId, MapManager mapManager, int mapId) throws Exception {
|
||||
MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(needDistoryPointId);
|
||||
/**
|
||||
* 事件点的刷新规则
|
||||
* 1 每日刷新
|
||||
* 2 探索刷新(不用处理)
|
||||
* 3 一次性
|
||||
*/
|
||||
if (mapPointConfig.getRefresh() == 1 || mapPointConfig.getRefresh() == 3) {
|
||||
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapId);
|
||||
if (crossMapCell == null) {
|
||||
crossMapCell = new CrossMapCell();
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 1) {
|
||||
crossMapCell.getDayRefreshs().put(needDistoryPointId, -1);
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 3) {
|
||||
crossMapCell.getPermanents().put(needDistoryPointId, -1);
|
||||
}
|
||||
mapManager.updateCrossMapInfos(mapId, crossMapCell);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addBehaviorInfo(int needDistoryPointId, MapManager mapManager, int mapId, int x, int y) throws Exception {
|
||||
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapId);
|
||||
if (crossMapCell == null) {
|
||||
crossMapCell = new CrossMapCell();
|
||||
}
|
||||
int xy = CellUtil.xy2Pos(x, y);
|
||||
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(needDistoryPointId);
|
||||
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
|
||||
crossMapCell.getBehaviorTriggers().put(xy,cellValue);
|
||||
mapManager.updateCrossMapInfos(mapId, crossMapCell);
|
||||
mapManager.addOrUpdateCell(xy, cellValue);
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +67,6 @@ public class BehaviorUtil {
|
|||
if (cell != null) {
|
||||
cell.setEventId(-1);
|
||||
mapManager.addOrUpdateCell(destoryXY, cell);
|
||||
addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -204,12 +163,11 @@ public class BehaviorUtil {
|
|||
* 更新任务
|
||||
*/
|
||||
public static boolean updateMission(User user, int missionId, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception{
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(missionId);
|
||||
if (mission == null || !mission.isOpen()) {
|
||||
Mission mission = user.getMapManager().getMission();
|
||||
if (mission == null) {
|
||||
return false;
|
||||
}
|
||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||
CheckMissionReturn checkMissionReturn = MapLogic.getInstance().checkMission(mission, user);
|
||||
for (Mission missions : checkMissionReturn.missions) {
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(missions);
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
|
|
@ -228,7 +186,6 @@ public class BehaviorUtil {
|
|||
if (cell != null) {
|
||||
cell.setEventId(-1);
|
||||
mapManager.addOrUpdateCell(cell.getCellId(), cell);
|
||||
addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.ljsd.jieling.handler.map.EventType;
|
|||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
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.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
|
|
@ -21,12 +20,11 @@ public class DestroyMissionBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
||||
if (mission == null || !mission.isOpen()) {
|
||||
Mission mission = user.getMapManager().getMission();
|
||||
if (mission == null) {
|
||||
return false;
|
||||
}
|
||||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||
CheckMissionReturn checkMissionReturn = MapLogic.getInstance().checkMission(mission, user);
|
||||
BehaviorUtil.destoryCurPoint(user);
|
||||
for (Mission cmission : checkMissionReturn.missions){
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(cmission);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,10 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.config.MapPointConfig;
|
||||
import com.ljsd.jieling.config.SCMapConfig;
|
||||
import com.ljsd.jieling.handler.map.*;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
import com.ljsd.jieling.handler.mission.MissionLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.util.CellUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@Component
|
||||
public class DunBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
|
@ -24,56 +14,57 @@ public class DunBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
boolean hasMission = MissionLogic.getInstance().hasMission(user, behaviorTypeValues[0][0]);
|
||||
if (hasMission) {
|
||||
return false;
|
||||
}
|
||||
MapManager mapManager = user.getMapManager();
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
int[] mapSize = scMapConfig.getSize();
|
||||
Map<Integer, Cell> newDunEvents = new HashMap<>();
|
||||
Map<Integer, MapPointConfig> newDunEventIds = new HashMap<>();
|
||||
int i = 0;
|
||||
Random random = new Random();
|
||||
while (newDunEventIds.size() < 3) {
|
||||
int randomIndex = random.nextInt(behaviorTypeValues[0].length - 3) + 3;
|
||||
int newDunEventId = behaviorTypeValues[0][randomIndex];
|
||||
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(newDunEventId);
|
||||
newDunEventIds.put(newDunEventIds.size(), mapPointConfig);
|
||||
i++;
|
||||
if (i >= 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newDunEventIds.size() < 3) {
|
||||
return false;
|
||||
}
|
||||
i = 0;
|
||||
while (newDunEvents.size() < 3) {
|
||||
int x = random.nextInt(mapSize[0]) + 1;
|
||||
int y = random.nextInt(mapSize[1]) + 1;
|
||||
int xy = CellUtil.xy2Pos(x, y);
|
||||
if (mapManager.getMapInfo().containsKey(xy)) {
|
||||
continue;
|
||||
}
|
||||
MapPointConfig mapPointConfig = newDunEventIds.get(newDunEvents.size());
|
||||
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
|
||||
newDunEvents.put(xy, cellValue);
|
||||
i++;
|
||||
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.setMissionInfo(mapManager.getCurXY() + "#" + behaviorTypeValues[0][2]);
|
||||
user.getMissionManager().updateOneDoingMissions(behaviorTypeValues[0][0], mission);
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(mission);
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
return true;
|
||||
// boolean hasMission = MissionLogic.getInstance().hasMission(user, behaviorTypeValues[0][0]);
|
||||
// if (hasMission) {
|
||||
// return false;
|
||||
// }
|
||||
// MapManager mapManager = user.getMapManager();
|
||||
// SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
// int[] mapSize = scMapConfig.getSize();
|
||||
// Map<Integer, Cell> newDunEvents = new HashMap<>();
|
||||
// Map<Integer, MapPointConfig> newDunEventIds = new HashMap<>();
|
||||
// int i = 0;
|
||||
// Random random = new Random();
|
||||
// while (newDunEventIds.size() < 3) {
|
||||
// int randomIndex = random.nextInt(behaviorTypeValues[0].length - 3) + 3;
|
||||
// int newDunEventId = behaviorTypeValues[0][randomIndex];
|
||||
// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(newDunEventId);
|
||||
// newDunEventIds.put(newDunEventIds.size(), mapPointConfig);
|
||||
// i++;
|
||||
// if (i >= 1000) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (newDunEventIds.size() < 3) {
|
||||
// return false;
|
||||
// }
|
||||
// i = 0;
|
||||
// while (newDunEvents.size() < 3) {
|
||||
// int x = random.nextInt(mapSize[0]) + 1;
|
||||
// int y = random.nextInt(mapSize[1]) + 1;
|
||||
// int xy = CellUtil.xy2Pos(x, y);
|
||||
// if (mapManager.getMapInfo().containsKey(xy)) {
|
||||
// continue;
|
||||
// }
|
||||
// MapPointConfig mapPointConfig = newDunEventIds.get(newDunEvents.size());
|
||||
// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
|
||||
// newDunEvents.put(xy, cellValue);
|
||||
// i++;
|
||||
// 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.setMissionInfo(mapManager.getCurXY() + "#" + behaviorTypeValues[0][2]);
|
||||
// user.getMissionManager().updateOneDoingMissions(behaviorTypeValues[0][0], mission);
|
||||
// CommonProto.Mission missionProto = MapLogic.getInstance().getMission(mission);
|
||||
// eventUpdateResponse.addMission(missionProto);
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.handler.map.EventType;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
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.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class MonitorMissionBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
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.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class OpenAppointMissionBehavior extends BaseBehavior {
|
||||
@Override
|
||||
public int getBehaviorType() {
|
||||
return EventType.openAppointMission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
Mission mission = new Mission();
|
||||
mission.setMissionId(behaviorTypeValues[0][0]);
|
||||
mission.setMissionStep(0);
|
||||
mission.setOpen(true);
|
||||
mission.setMissionInfo(user.getMapManager().getCurMapId() + "#" + behaviorTypeValues[0][0]);
|
||||
user.getMissionManager().updateOneDoingMissions(behaviorTypeValues[0][0], mission);
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(mission);
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
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.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class OpenNotDoMissionBehavior extends BaseBehavior {
|
||||
@Override
|
||||
public int getBehaviorType() {
|
||||
return EventType.openNotDoMission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
Mission mission = new Mission();
|
||||
mission.setMissionId(behaviorTypeValues[0][0]);
|
||||
mission.setMissionStep(0);
|
||||
mission.setOpen(false);
|
||||
mission.setMissionInfo(user.getMapManager().getCurMapId() + "#" + behaviorTypeValues[0][0]);
|
||||
user.getMissionManager().updateOneDoingMissions(behaviorTypeValues[0][0], mission);
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(mission);
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
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.handler.map.MapMissionType;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UseStepBehavior extends BaseBehavior {
|
||||
@Override
|
||||
public int getBehaviorType() {
|
||||
return EventType.twentyEight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
int totalStep = mapManager.getTotalStep();
|
||||
if (totalStep < behaviorTypeValues[0][0]) {
|
||||
return false;
|
||||
}
|
||||
mapManager.setTotalStep(totalStep - behaviorTypeValues[0][0]);
|
||||
MapLogic.getInstance().updateMapMission(mapManager,EventType.updateEvent, MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue(),behaviorTypeValues[0][0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckMissionReturn {
|
||||
public String newEventId;
|
||||
public List<Mission> missions = new ArrayList<>();
|
||||
public CommonProto.Drop.Builder drop;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ public class Mission extends MongoBase {
|
|||
|
||||
private String missionInfo;
|
||||
|
||||
private boolean isOpen;
|
||||
|
||||
public int getMissionId() {
|
||||
return missionId;
|
||||
}
|
||||
|
|
@ -37,12 +35,4 @@ public class Mission extends MongoBase {
|
|||
this.missionInfo = missionInfo;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
updateString("open", open);
|
||||
isOpen = open;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,139 +0,0 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
|
||||
import com.ljsd.jieling.config.SMissionEventsConfig;
|
||||
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;
|
||||
import com.ljsd.jieling.protocols.MissionInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class MissionLogic {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MissionLogic.class);
|
||||
|
||||
private MissionLogic() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MissionLogic getInstance() {
|
||||
return MissionLogic.Instance.instance;
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static MissionLogic instance = new MissionLogic();
|
||||
}
|
||||
|
||||
public void getAllMissions(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MissionManager missionManager = user.getMissionManager();
|
||||
Map<Integer, Mission> doingMissions = missionManager.getDoingMissions();
|
||||
Set<Integer> finishMissions = missionManager.getFinishMissions();
|
||||
MissionInfoProto.MissionGetAllResponse.Builder missionGetAllResponse = MissionInfoProto.MissionGetAllResponse.newBuilder();
|
||||
for (Mission doingMission : doingMissions.values()) {
|
||||
CommonProto.Mission mission = CommonProto.Mission
|
||||
.newBuilder()
|
||||
.setMissionStep(doingMission.getMissionStep())
|
||||
.setItemId(doingMission.getMissionId())
|
||||
.setIsOpen(doingMission.isOpen())
|
||||
.setState("")
|
||||
.build();
|
||||
missionGetAllResponse.addMissions(mission);
|
||||
}
|
||||
for (int finishMission : finishMissions) {
|
||||
SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(finishMission);
|
||||
CommonProto.Mission mission = CommonProto.Mission
|
||||
.newBuilder()
|
||||
.setMissionStep(sMissionEventsConfig.getMissionNum())
|
||||
.setItemId(finishMission)
|
||||
.setIsOpen(true)
|
||||
.setState("")
|
||||
.build();
|
||||
missionGetAllResponse.addMissions(mission);
|
||||
}
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), missionGetAllResponse.build(), true);
|
||||
}
|
||||
|
||||
public boolean hasMission(User user, int missionId) {
|
||||
MissionManager missionManager = user.getMissionManager();
|
||||
if (missionManager.getTakeRewardMissions().contains(missionId)){
|
||||
return true;
|
||||
}
|
||||
if (missionManager.getDoingMissions().containsKey(missionId)) {
|
||||
return true;
|
||||
}
|
||||
if (missionManager.getTakeRewardMissions().contains(missionId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CheckMissionReturn checkMission(Mission mission, User user) throws Exception {
|
||||
SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(mission.getMissionId());
|
||||
mission.setMissionStep(mission.getMissionStep() + 1);
|
||||
CheckMissionReturn checkMissionReturn = new CheckMissionReturn();
|
||||
if (mission.getMissionStep() >= sMissionEventsConfig.getMissionNum()) {
|
||||
if (mission.getMissionInfo() != null) {
|
||||
checkMissionReturn.newEventId = mission.getMissionInfo();
|
||||
}
|
||||
user.getMissionManager().removeDoingMissions(mission.getMissionId());
|
||||
Set<Integer> finishMissions = user.getMissionManager().getFinishMissions();
|
||||
finishMissions.add(mission.getMissionId());
|
||||
user.getMissionManager().updateFinishMissions(finishMissions);
|
||||
mission.setOpen(true);
|
||||
} else {
|
||||
user.getMissionManager().updateOneDoingMissions(mission.getMissionId(), mission);
|
||||
}
|
||||
checkMissionReturn.missions.add(mission);
|
||||
return checkMissionReturn;
|
||||
}
|
||||
|
||||
|
||||
public void takeMissionReward(ISession session, int missionId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
Set<Integer> finishMissions = user.getMissionManager().getFinishMissions();
|
||||
if (!finishMissions.contains(missionId)) {
|
||||
return;
|
||||
}
|
||||
finishMissions.remove(missionId);
|
||||
user.getMissionManager().updateFinishMissions(finishMissions);
|
||||
user.getMissionManager().addTakeRewardMissions(missionId);
|
||||
SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(missionId);
|
||||
int[] reward = {sMissionEventsConfig.getReward()};
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, 1, 0);
|
||||
MissionInfoProto.TakeMissionResponse takeMissionResponse =
|
||||
MissionInfoProto.TakeMissionResponse
|
||||
.newBuilder()
|
||||
.setDrop(drop)
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), takeMissionResponse, true);
|
||||
}
|
||||
|
||||
|
||||
public void openMission(ISession session, int missionId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
if (!doingMissions.containsKey(missionId)) {
|
||||
LOGGER.info("openMission uid=>{}, not this misson missionId=>{}", session.getUid(), missionId);
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
Mission mission = doingMissions.get(missionId);
|
||||
mission.setOpen(true);
|
||||
user.getMissionManager().updateOneDoingMissions(missionId, mission);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MissionManager extends MongoBase {
|
||||
|
||||
private Map<Integer, Mission> doingMissions = new ConcurrentHashMap<>();
|
||||
|
||||
private Set<Integer> finishMissions = Sets.newConcurrentHashSet();
|
||||
|
||||
private Set<Integer> takeRewardMissions = Sets.newConcurrentHashSet();
|
||||
|
||||
|
||||
public MissionManager(){
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, Mission> getDoingMissions() {
|
||||
return doingMissions;
|
||||
}
|
||||
|
||||
public Set<Integer> getFinishMissions() {
|
||||
return finishMissions;
|
||||
}
|
||||
|
||||
public Set<Integer> getTakeRewardMissions() {
|
||||
return takeRewardMissions;
|
||||
}
|
||||
|
||||
public void updateOneDoingMissions(int missionId, Mission mission) throws Exception {
|
||||
mission.init(this.getRootId(), getMongoKey() + ".doingMissions." + missionId);
|
||||
this.doingMissions.put(missionId, mission);
|
||||
updateString( "doingMissions." + missionId, mission);
|
||||
}
|
||||
|
||||
public void removeDoingMissions(int missionId) throws Exception {
|
||||
this.doingMissions.remove(missionId);
|
||||
removeString( getMongoKey() + ".doingMissions." + missionId);
|
||||
}
|
||||
|
||||
public void updateFinishMissions(Set<Integer> finishMissions) throws Exception {
|
||||
this.finishMissions = finishMissions;
|
||||
updateString( "finishMissions", finishMissions);
|
||||
}
|
||||
|
||||
public void addTakeRewardMissions(int missionId) throws Exception {
|
||||
takeRewardMissions.add(missionId);
|
||||
updateString( "takeRewardMissions", takeRewardMissions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.MissionInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MissionTakeRewardRequestHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.MISSION_TAKE_REWARD_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MissionInfoProto.TakeMissionRewardRequest takeMissionRewardRequest = MissionInfoProto.TakeMissionRewardRequest.parseFrom(message);
|
||||
int missionId = takeMissionRewardRequest.getMissionId();
|
||||
MissionLogic.getInstance().takeMissionReward(iSession, missionId, MessageTypeProto.MessageType.MISSION_TAKE_REWARD_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.ljsd.jieling.handler.mission;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.MissionInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class OpenMissionRequestHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.MISSION_OPEN_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MissionInfoProto.OpenMissionRequest openMissionRequest = MissionInfoProto.OpenMissionRequest.parseFrom(message);
|
||||
int missionId = openMissionRequest.getMissionId();
|
||||
MissionLogic.getInstance().openMission(iSession, missionId, MessageTypeProto.MessageType.MISSION_OPEN_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,11 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
|
||||
import com.ljsd.jieling.config.SGameSetting;
|
||||
import com.ljsd.jieling.config.SMissionEventsConfig;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
import com.ljsd.jieling.handler.mission.MissionManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -81,14 +76,6 @@ public class UserManager {
|
|||
playerManager.setCreateTime(TimeUtils.now());
|
||||
SGameSetting gameSetting = SGameSetting.getGameSetting();
|
||||
ItemUtil.drop(user,gameSetting.getBornItem());
|
||||
MissionManager missionManager = user.getMissionManager();
|
||||
Mission mission = new Mission();
|
||||
mission.setMissionId(1);
|
||||
mission.setMissionStep(0);
|
||||
mission.setOpen(true);
|
||||
missionManager.getDoingMissions().put(mission.getMissionId(), mission);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
//TODO
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
Map<String, Hero> heroMap = heroManager.getHeroMap();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.ljsd.jieling.logic.dao.root;
|
|||
|
||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.mission.MissionManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
||||
|
|
@ -22,8 +21,6 @@ public class User {
|
|||
|
||||
private MapManager mapManager;
|
||||
|
||||
private MissionManager missionManager;
|
||||
|
||||
private TeamPosManager teamPosManager;
|
||||
|
||||
private MailManager mailManager;
|
||||
|
|
@ -48,7 +45,6 @@ public class User {
|
|||
this.itemManager = new ItemManager();
|
||||
this.heroManager = new HeroManager();
|
||||
this.mapManager = new MapManager();
|
||||
this.missionManager = new MissionManager();
|
||||
this.teamPosManager = new TeamPosManager();
|
||||
this.mailManager = new MailManager();
|
||||
this.equipManager = new EquipManager();
|
||||
|
|
@ -61,7 +57,6 @@ public class User {
|
|||
this.itemManager.init(id, MongoKey.itemManager);
|
||||
this.heroManager.init(id, MongoKey.heroManager);
|
||||
this.mapManager.init(id, MongoKey.mapManager);
|
||||
this.missionManager.init(id, MongoKey.missionManager);
|
||||
this.teamPosManager.init(id, MongoKey.teamPosManager);
|
||||
this.mailManager.init(id, MongoKey.mailManager);
|
||||
this.equipManager.init(id, MongoKey.equipManager);
|
||||
|
|
@ -142,10 +137,6 @@ public class User {
|
|||
return pokemonManager;
|
||||
}
|
||||
|
||||
public MissionManager getMissionManager() {
|
||||
return missionManager;
|
||||
}
|
||||
|
||||
public WorkShopController getWorkShopController() {
|
||||
return workShopController;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,12 +332,12 @@ public class CombatLogic {
|
|||
if(type == GlobalsDef.FOOD_ADDITION_EXPLORE_TYPE){
|
||||
for(int[] effectPara : effectParas){
|
||||
if(effectPara[0] == GlobalsDef.EXPLORE_MAP_ACTION_POWER_RORMULA_TYPE){
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
int totalStep = mapManager.getTotalStep();
|
||||
if (totalStep < scMapConfig.getMoveConfused() * 5) {
|
||||
totalStep = scMapConfig.getMoveConfused() * 5;
|
||||
}
|
||||
mapManager.setTotalStep(totalStep + effectPara[1]);
|
||||
// SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
|
||||
// int totalStep = mapManager.getTotalStep();
|
||||
// if (totalStep < scMapConfig.getMoveConfused() * 5) {
|
||||
// totalStep = scMapConfig.getMoveConfused() * 5;
|
||||
// }
|
||||
// mapManager.setTotalStep(totalStep + effectPara[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue