地图优化
parent
9c9af49df7
commit
217faa3b6f
File diff suppressed because it is too large
Load Diff
|
@ -2,10 +2,14 @@ package com.ljsd.jieling.handler.map.mapHandler;
|
|||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.mapType.IMap;
|
||||
import com.ljsd.jieling.handler.map.mapType.MapEnum;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChallengeConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -22,6 +26,10 @@ public class MapEnterRequestHandler extends BaseHandler{
|
|||
byte[] message = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapEnterRequest mapEnterRequest = MapInfoProto.MapEnterRequest.parseFrom(message);
|
||||
int teamId = mapEnterRequest.getTeamId();
|
||||
MapLogic.getInstance().enterMap(iSession, mapEnterRequest.getMapId(), teamId, MessageTypeProto.MessageType.MAP_ENTER_RESPONSE);
|
||||
// MapLogic.getInstance().enterMap();
|
||||
MapInfoProto.MapEnterResponse.Builder builder = MapInfoProto.MapEnterResponse.newBuilder();
|
||||
MapEnum.getAbstractMap(SChallengeConfig.sChallengeConfigs.get(mapEnterRequest.getMapId()).getType()).enterMap(iSession.getUid(), mapEnterRequest.getMapId(), teamId,builder);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.MAP_ENTER_RESPONSE.getNumber(), builder.build(), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,16 @@ package com.ljsd.jieling.handler.map.mapHandler;
|
|||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.mapType.AbstractMap;
|
||||
import com.ljsd.jieling.handler.map.mapType.MapEnum;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
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.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChallengeConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
@ -16,6 +23,9 @@ public class MapFastFightRequestHandler extends BaseHandler {
|
|||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
MapLogic.getInstance().fastFight(iSession, MessageTypeProto.MessageType.MAP_FAST_FIGHT_RESPONSE);
|
||||
FightInfoProto.FastFightResponse.Builder builder = FightInfoProto.FastFightResponse.newBuilder();
|
||||
MapLogic.curMapType(iSession).fastFight(iSession.getUid(), builder);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.MAP_FAST_FIGHT_RESPONSE.getNumber(), builder.build(), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,15 @@ package com.ljsd.jieling.handler.map.mapHandler;
|
|||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.mapType.AbstractMap;
|
||||
import com.ljsd.jieling.handler.map.mapType.MapEnum;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChallengeConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
@ -19,10 +24,12 @@ public class MapOutRequestHandler extends BaseHandler{
|
|||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapOutRequest mapOutRequest = MapInfoProto.MapOutRequest.parseFrom(bytes);
|
||||
int mapId = mapOutRequest.getMapId();
|
||||
int outType = mapOutRequest.getOutType();
|
||||
int curXY = mapOutRequest.getCurXY();
|
||||
int targetMapId = mapOutRequest.getTargetMapId();
|
||||
MapLogic.getInstance().outMap(iSession, mapId,outType,curXY,targetMapId,MessageTypeProto.MessageType.MAP_OUT_RESPONSE);
|
||||
int curMapId = UserManager.getUser(iSession.getUid()).getMapManager().getCurMapId();
|
||||
AbstractMap abstractMap = MapEnum.getAbstractMap(SChallengeConfig.sChallengeConfigs.get(curMapId).getType());
|
||||
MapInfoProto.MapOutResponse.Builder builder = MapInfoProto.MapOutResponse.newBuilder();
|
||||
abstractMap.outMap(iSession.getUid(),outType,curXY,builder);
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.MAP_OUT_RESPONSE_VALUE,builder.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,9 @@ public class StartFightRequestHandler extends BaseHandler<FightInfoProto.FightSt
|
|||
}
|
||||
// MapLogic.getInstance().startLevelDifficultyFight(iSession,fightId,teamId,type, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
}else if(type == 2){
|
||||
MapLogic.getInstance().startFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
|
||||
FightInfoProto.FightStartResponse.Builder responseBuilder = FightInfoProto.FightStartResponse.newBuilder();
|
||||
MapLogic.curMapType(iSession).startFight(iSession.getUid(),responseBuilder);
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.FIGHT_START_RESPONSE_VALUE,responseBuilder.build(),true);
|
||||
}else if(type == 3){
|
||||
MapLogic.getInstance().startSuddlenlyFight(iSession,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
}else if(type == 5){
|
||||
|
|
|
@ -0,0 +1,416 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.MapStaticConfig;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.map.*;
|
||||
|
||||
import com.ljsd.jieling.handler.map.behavior.BaseBehavior;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.StoryEvent;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import util.CellUtil;
|
||||
import util.MathUtils;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public abstract class AbstractMap implements IMap {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(AbstractMap.class);
|
||||
private Map<Integer, BaseBehavior> baseBehaviorMap = new HashMap<>();
|
||||
|
||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
Map<String, BaseBehavior> beansOfType = configurableApplicationContext.getBeansOfType(BaseBehavior.class);
|
||||
for (BaseBehavior baseBehavior : beansOfType.values()) {
|
||||
baseBehaviorMap.put(baseBehavior.getBehaviorType(), baseBehavior);
|
||||
}
|
||||
}
|
||||
int endlessSeason;
|
||||
AbstractMap(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractMap getInstence(int mapType) {
|
||||
Map<Integer,AbstractMap> mapInstence = new HashMap<>();
|
||||
return mapInstence.get(mapType);
|
||||
}
|
||||
@Override
|
||||
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception{
|
||||
// int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (teamId == 0) {
|
||||
LOGGER.info("enterMap() uid=>{} teamId =>{} ", uid, teamId);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
user.getTeamPosManager().setCurTeamPosId(teamId);
|
||||
if (mapManager.getCurMapId() == 0) {
|
||||
enterNewMap(user,mapId,teamId,mapEnterResponse);
|
||||
} else if (mapManager.getCurMapId() != mapId) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("地图错误,应进入" + mapManager.getCurMapId()));
|
||||
}else{
|
||||
mapEnterResponse.setCurXY(mapManager.getCurXY());
|
||||
}
|
||||
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
|
||||
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
|
||||
cellToProto(cells, entry);
|
||||
}
|
||||
|
||||
mapEnterResponse.setLeftTime(MapLogic.getLeftTime(user, true));
|
||||
for (Map.Entry<Integer, Integer> buffEntry : mapManager.getFoodBufferMap().entrySet()) {
|
||||
if (buffEntry.getValue()==0) {
|
||||
continue;
|
||||
}
|
||||
CommonProto.FoodBuffer foodBuffer = CBean2Proto.getFoodBuffer(buffEntry.getKey(), buffEntry.getValue());
|
||||
mapEnterResponse.addFoodBuffers(foodBuffer);
|
||||
}
|
||||
|
||||
int reviveTime = (int) ((mapManager.getCanMoveTime() - TimeUtils.now()) / 1000);
|
||||
if (reviveTime > 0) {
|
||||
mapEnterResponse.setReviveTime(reviveTime);
|
||||
}
|
||||
|
||||
mapEnterResponse.setDieCount(mapManager.getDieCount());
|
||||
mapEnterResponse.addAllMapList(cells);
|
||||
mapEnterResponse.addAllWakeCells(mapManager.getWalkCells() == null ? new ArrayList<>() : mapManager.getWalkCells());
|
||||
if (mapManager.getTemporaryItems() != null) {
|
||||
mapEnterResponse.setTemporaryItems(CBean2Proto.getDrop(mapManager.getTemporaryItems()));
|
||||
}
|
||||
MapMission mapMissionProgres = mapManager.getCopyMissionProgresById(mapId);
|
||||
if (mapMissionProgres != null) {
|
||||
Map<Integer, Integer> allMissionProgress = mapMissionProgres.getAllMissionProgress();
|
||||
List<CommonProto.ExploreDetail> exploreDetailList = new ArrayList<>(allMissionProgress.size());
|
||||
for (Map.Entry<Integer, Integer> item : allMissionProgress.entrySet()) {
|
||||
exploreDetailList.add(CommonProto.ExploreDetail.newBuilder().setId(item.getKey()).setProgress(item.getValue()).build());
|
||||
}
|
||||
mapEnterResponse.addAllExploreDetail(exploreDetailList);
|
||||
} else {
|
||||
LOGGER.error("the curmap={}", mapManager.getCurMapId());
|
||||
}
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
Map<String, Map<Integer, Integer>> heroAllAttributeMap = mapManager.getHeroAllAttributeMap();
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
|
||||
Map<Integer, Integer> map = heroAllAttributeMap.get(teamPosHeroInfo.getHeroId());
|
||||
if (map == null) {
|
||||
continue;
|
||||
}
|
||||
MapInfoProto.HeroInfo heroInfo = MapInfoProto.HeroInfo.newBuilder()
|
||||
.setHeroId(teamPosHeroInfo.getHeroId())
|
||||
.setHeroHp(map.get(HeroAttributeEnum.CurHP.getPropertyId()) == null ? 0 : map.get(HeroAttributeEnum.CurHP.getPropertyId()))
|
||||
.setHeroMaxHp(map.get(HeroAttributeEnum.Hp.getPropertyId()) == null ? 0 : map.get(HeroAttributeEnum.Hp.getPropertyId()))
|
||||
.build();
|
||||
mapEnterResponse.addHeroInfos(heroInfo);
|
||||
}
|
||||
LOGGER.info("enterMap() uid=>{} mapId =>{}", uid, mapManager.getCurMapId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder builder)throws Exception{
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if(mapManager.getCurMapId()==0){
|
||||
mapManager.setCurXY(0);
|
||||
return;
|
||||
}
|
||||
int time = (int)(mapManager.getCurrTowerTime())/1000;
|
||||
builder.setUseTime(time);
|
||||
LOGGER.info("当前层使用时间{}",time);
|
||||
//清除副本中增加的怪物被动技能
|
||||
user.getMapManager().removeMonsterTempSkill();
|
||||
boolean result = MapLogic.getInstance().onlyLevelMap(user, true);
|
||||
if (!result) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
|
||||
int getMapType(int mapId){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void enterNewMap(User user,int mapId,int teamId,MapInfoProto.MapEnterResponse.Builder mapEnterResponse)throws Exception{
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if(mapManager.getCurMapId()!=0){
|
||||
return;
|
||||
}
|
||||
SChallengeMapConfig scMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapId);
|
||||
SChallengeConfig sChallengeConfig = STableManager.getConfig(SChallengeConfig.class).get(mapId);
|
||||
mapEnterResponse.setCurXY(CellUtil.xy2Pos(scMapConfig.getPosition()[0],scMapConfig.getPosition()[1]));
|
||||
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId);
|
||||
if (scMap == null) {
|
||||
LOGGER.info("enterMap() uid=>{} scMap == null =>{} ", user.getId(), mapId);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if (scMapConfig == null) {
|
||||
LOGGER.info("enterMap() uid=>{} sChallengeConfig == null =>{} ", user.getId(), mapId);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("该地图不存在"));
|
||||
}
|
||||
if (sChallengeConfig == null) {
|
||||
LOGGER.info("enterMap() uid=>{} sChallengeConfig == null =>{} ", user.getId(), mapId);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("该地图不存在"));
|
||||
}
|
||||
// TODO 可进入地图条件判断
|
||||
int[][] openRule = sChallengeConfig.getOpenRule();
|
||||
if (openRule != null && openRule.length > 0) {
|
||||
if (user.getPlayerInfoManager().getLevel() < openRule[0][1]) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("需要等级:" + openRule[0][1]));
|
||||
}
|
||||
if(!SMainLevelConfig.biggerThanFight(user.getMainLevelManager().getFightId(),openRule[0][0])){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("需要通关:" + openRule[0][0]));
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getPlayerInfoManager().getMapId() < mapId) {
|
||||
user.getPlayerInfoManager().setMapId(mapId);
|
||||
}
|
||||
String error = MapLogic.getInstance().initTeamInfo(teamId, user.getId(), user, mapManager,1);
|
||||
if (!error.isEmpty()) {
|
||||
LOGGER.info("enterMap() uid=>{} error =>{} ", user.getId(), error);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
mapManager.setCurMapId(mapId);
|
||||
//todo 更新地圖次數
|
||||
user.setMapManager(mapManager);
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.PlAY_STORY, SChallengeConfig.sChallengeConfigs.get(mapId).getType(),1);
|
||||
Poster.getPoster().dispatchEvent(new StoryEvent(user.getId(),1));
|
||||
}
|
||||
|
||||
private void cellToProto(List<CommonProto.Cell> cells, Map.Entry<Integer, Cell> entry) {
|
||||
Cell cell = entry.getValue();
|
||||
if (cell.getEventId() == -1) {
|
||||
return;
|
||||
}
|
||||
CommonProto.Cell.Builder cellProto = CommonProto.Cell
|
||||
.newBuilder()
|
||||
.setCellId(entry.getKey())
|
||||
.setPointId(cell.getPointId())
|
||||
.setMonsterForce(cell.getForce());
|
||||
cells.add(cellProto.build());
|
||||
}
|
||||
public void fastFight(int uid, FightInfoProto.FastFightResponse.Builder fastFightResponseBuilder) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager.getMapInfo() == null) {
|
||||
LOGGER.info("fastFight mapManager.getMapInfo() == null");
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if (mapManager.getCanMoveTime() > 0) {
|
||||
long leftTime = mapManager.getCanMoveTime() - TimeUtils.now();
|
||||
if (leftTime > 0) {
|
||||
throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN, Collections.singletonList((leftTime / 1000)+""));
|
||||
}
|
||||
}
|
||||
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
|
||||
if (cell == null) {
|
||||
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
|
||||
if (cell == null) {
|
||||
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
int bigEventId = cell.getEventId();
|
||||
SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(bigEventId);
|
||||
if (sEventPointConfig == null) {
|
||||
LOGGER.info("sEventPointConfig == null");
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int[] option = sEventPointConfig.getOption();
|
||||
if (option == null) {
|
||||
LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId());
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int groupId = option[0];
|
||||
if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4) {
|
||||
Integer newGroupId= STableManager.getFigureConfig(MapStaticConfig.class).getDifficultyMonster().get(groupId);
|
||||
if(newGroupId!=null){
|
||||
groupId = newGroupId;
|
||||
}
|
||||
}
|
||||
int destoryXY = mapManager.getTriggerXY();
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user, mapManager.getTeamId(), true);
|
||||
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = new ArrayList<>(3);
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(groupId, monsterByGroup, Global.MONSTER_1);
|
||||
monsterTeamList.addAll(monsterGroupList);
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList1 = BehaviorUtil.getFightTeamInfos(groupId, monsterByGroup, Global.MONSTER_2);
|
||||
monsterTeamList.addAll(monsterGroupList1);
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList2 = BehaviorUtil.getFightTeamInfos(groupId, monsterByGroup, Global.MONSTER_3);
|
||||
monsterTeamList.addAll(monsterGroupList2);
|
||||
//设置战斗随机种子
|
||||
int seed = (int) (System.currentTimeMillis() / 1000);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId());
|
||||
int mostTime = sChallengeConfig.getMostTime();
|
||||
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, FightType.MapExploreFight);
|
||||
List<Integer> remainHp = new ArrayList<>(5);
|
||||
for (int i = 2; i < checkResult.length; i++) {
|
||||
if (checkResult[i] <= 0) {
|
||||
remainHp.add(0);
|
||||
} else {
|
||||
remainHp.add(checkResult[i]);
|
||||
}
|
||||
}
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
int teamId = mapManager.getTeamId();
|
||||
mapManager.setLastFightResult(resultCode);
|
||||
|
||||
if (resultCode == 0) {
|
||||
//复活相关(无尽本不复活)
|
||||
revive(user,sChallengeConfig,remainHp,teamId);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
fastFightResponseBuilder.setResult(resultCode)
|
||||
.setEnventDrop(dropBuilder)
|
||||
.addAllRemainHpList(remainHp)
|
||||
.setEssenceValue(mapManager.getEssenceValue())
|
||||
.setLastXY(mapManager.getLastXY());
|
||||
mapManager.setCurXY(mapManager.getLastXY());
|
||||
return;
|
||||
}
|
||||
refreshHp(user,teamId,checkResult);
|
||||
BehaviorUtil.destoryApointXY(user, destoryXY);
|
||||
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(groupId);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 1, BIReason.MAP_FAST_FIGHT_REWARD);
|
||||
|
||||
if (mapManager.getMonsterId() > 0) {
|
||||
BaseBehavior baseBehavior = baseBehaviorMap.get(10);
|
||||
baseBehavior.afterFastFight(user, groupId, fastFightResponseBuilder);
|
||||
}
|
||||
fastFightResponseBuilder.setEnventDrop(drop.build());
|
||||
fastFightResponseBuilder.setResult(resultCode);
|
||||
fastFightResponseBuilder.addAllRemainHpList(remainHp);
|
||||
fastFightResponseBuilder.setEssenceValue(mapManager.getEssenceValue());
|
||||
// LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId);
|
||||
MapMissionManager.updateMapMission(user, EventType.fightEvent, groupId, checkResult[1]);
|
||||
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fastFightResponse.getMission(), fastFightResponse.getEnventDrop(), fastFightResponse.getMissionDrop());
|
||||
}
|
||||
public void startFight(int uid,FightInfoProto.FightStartResponse.Builder responseBuilder) throws Exception{
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager.getMapInfo() == null) {
|
||||
LOGGER.info("mapManager.getMapInfo() == null");
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if (mapManager.getCanMoveTime() > 0) {
|
||||
long leftTime = mapManager.getCanMoveTime() - TimeUtils.now();
|
||||
if (leftTime > 0) {
|
||||
throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+""));
|
||||
}
|
||||
}
|
||||
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
|
||||
if (cell == null) {
|
||||
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
|
||||
if (cell == null) {
|
||||
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("cell == null"));
|
||||
}
|
||||
}
|
||||
int bigEventId = cell.getEventId();
|
||||
SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(bigEventId);
|
||||
if (sEventPointConfig == null) {
|
||||
LOGGER.info("sEventPointConfig == null");
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false);
|
||||
String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey);
|
||||
int groupId;
|
||||
String pointId = "0";
|
||||
if (fightReady != null) {
|
||||
String[] split = fightReady.split("#");
|
||||
RedisUtil.getInstence().del(fightReadyKey);
|
||||
groupId = monsterGroupChange(Integer.parseInt(split[0]));
|
||||
if (split.length > 1) {
|
||||
pointId = split[1];
|
||||
}
|
||||
} else {
|
||||
int[] option = sEventPointConfig.getOption();
|
||||
if (option == null||option.length<1) {
|
||||
LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId());
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
groupId = monsterGroupChange(option[0]);
|
||||
}
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
|
||||
BehaviorUtil.getFightInfo(user, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true);
|
||||
// MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
|
||||
}
|
||||
|
||||
public void endFight(){
|
||||
|
||||
}
|
||||
|
||||
public void revive(User user,SChallengeConfig sChallengeConfig,List<Integer> remainHp,int teamId) throws Exception {
|
||||
|
||||
// 失败需要等待n秒后复活所有英雄
|
||||
MapManager mapManager = user.getMapManager();
|
||||
int dieCount = user.getMapManager().getDieCount();
|
||||
|
||||
dieCount++;
|
||||
user.getMapManager().setDieCount(dieCount);
|
||||
int[] reviveTime = sChallengeConfig.getReviveTime();
|
||||
long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000);
|
||||
user.getMapManager().setCanMoveTime(TimeUtils.now() + time);
|
||||
int leftTime = MapLogic.getLeftTime(user, true);
|
||||
remainHp.clear();
|
||||
if (leftTime <= (int) (time / 1000)) {
|
||||
MapLogic.resetMapInfo(user, false);
|
||||
} else {
|
||||
MapLogic.getInstance().initTeamInfo(mapManager.getTeamId(), user.getId(), user, mapManager, 2);
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId());
|
||||
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
|
||||
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId);
|
||||
remainHp.add(heroAttributeMap.get(HeroAttributeEnum.CurHP.getPropertyId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void refreshHp(User user,int teamId,int[] checkResult){
|
||||
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : team) {
|
||||
user.getMapManager().updateHeroOneAttribute(teamPosHeroInfo.getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[teamPosHeroInfo.getPosition()+1]);
|
||||
}
|
||||
}
|
||||
public int monsterGroupChange(int groupId){
|
||||
return groupId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.map.MapMission;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SAccomplishmentConfig;
|
||||
import config.SChallengeConfig;
|
||||
import manager.STableManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public class DifficultMap extends AbstractMap {
|
||||
int type = 3;
|
||||
@Override
|
||||
public void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder builder) throws Exception{
|
||||
super.outMap(uid,outType,curXY,builder);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
SChallengeConfig challengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
|
||||
//精英副本清除功绩
|
||||
int[] achievementRefreshType = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getAchievementRefreshType();
|
||||
List<SAccomplishmentConfig> accomplishmentConfig = SAccomplishmentConfig.getsAccomplishmentConfigByMapId(challengeConfig.getMapId());
|
||||
MapMission mapMission = mapManager.getCopyMissionProgresById(challengeConfig.getMapId());
|
||||
Map<Integer, Integer> copyMissionProgresById = mapMission.getAllMissionProgress();
|
||||
for(SAccomplishmentConfig accomplishment:accomplishmentConfig){
|
||||
for(int i = 0 ; i <achievementRefreshType.length;i++){
|
||||
if(accomplishment.getLogic()==achievementRefreshType[i]&©MissionProgresById.get(accomplishment.getId())!=-1){
|
||||
copyMissionProgresById.put(accomplishment.getId(),0);
|
||||
mapMission.setAllMissionProgress(copyMissionProgresById);
|
||||
mapManager.setCopyMissionProgres(mapMission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterMap(uid, mapId, teamId, mapEnterResponse);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
if (mapManager.getMission() != null) {
|
||||
mapEnterResponse.setMissions(MapLogic.getMission(mapManager.getMission()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterNewMap(User user, int mapId, int teamId,MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterNewMap(user, mapId,teamId, mapEnterResponse);
|
||||
boolean enough = ItemUtil.itemCost(user, new int[][]{{Global.HEROSTORY_TICKET, 1}}, BIReason.MAP_ENTER_CONSUME,mapId);
|
||||
if(!enough){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("no ticket"));
|
||||
}
|
||||
MapLogic.getInstance().initMap(user.getMapManager(), user);
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.MapStaticConfig;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.EndlessMapInfo;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import util.CellUtil;
|
||||
import util.MathUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public class EndlessMap extends AbstractMap{
|
||||
int type=4;
|
||||
int endlessMapId = 4001;
|
||||
@Override
|
||||
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterMap(uid, mapId, teamId,mapEnterResponse);
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
mapEnterResponse.setCurXY(mapManager.getCurXY());
|
||||
List<TeamPosHeroInfo> teamPosForHero = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
for (int i = 0; i <teamPosForHero.size() ; i++) {
|
||||
String endlessHeroId = teamPosForHero.get(i).getHeroId();
|
||||
int maxHp = HeroLogic.getInstance().calHeroNotBufferAttribute(user,user.getHeroManager().getHero(endlessHeroId),false,teamId).get(1);
|
||||
mapManager.addEndlessHero(teamPosForHero.get(i).getHeroId(),maxHp);
|
||||
}
|
||||
EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo();
|
||||
if(endlessMapInfo.getSeason()!=MapLogic.endlessSeason){
|
||||
TimeControllerOfFunction openTimeOfFuntionCacheByType = GlobalDataManaager.getInstance().getOpenTimeOfFuntionCacheByType(FunctionIdEnum.Endless);
|
||||
StoreLogic.initOnsStoereWithTime(user, SEndlessMapConfig.sEndlessMapConfigMap.get(endlessMapId).getMapStoreId(),openTimeOfFuntionCacheByType.getStartTime(),openTimeOfFuntionCacheByType.getEndTime());
|
||||
mapManager.updateEndlessSeason(MapLogic.endlessSeason);
|
||||
mapManager.updateEndlessMapId(0);
|
||||
mapManager.endlessWalkCellSave(new HashSet<>());
|
||||
mapManager.endlessMapInfoSave(new HashMap<>());
|
||||
}else{
|
||||
Map<Integer, Cell> endlessMapCellInfo = mapManager.getEndlessMapInfo().getMapInfo();
|
||||
if(endlessMapCellInfo !=null&&endlessMapCellInfo.size()>0){
|
||||
mapManager.setMapInfo(endlessMapCellInfo);
|
||||
}
|
||||
Set<Integer> walkCell = mapManager.getEndlessMapInfo().getWalkCell();
|
||||
if(walkCell!=null&&walkCell.size()>0){
|
||||
mapManager.setWalkCells(walkCell);
|
||||
}
|
||||
}
|
||||
mapManager.updateEndlessMapId(mapId);
|
||||
for(Map.Entry<Integer,Map<Integer,String>> entry :endlessMapInfo.getMapSign().entrySet()){
|
||||
int curMapId = entry.getKey();
|
||||
for(Map.Entry<Integer,String> signEntry: entry.getValue().entrySet()){
|
||||
CommonProto.endlessSign sign = CommonProto.endlessSign.newBuilder()
|
||||
.setMapId(curMapId)
|
||||
.setCellId(signEntry.getKey())
|
||||
.setInfo(signEntry.getValue())
|
||||
.build();
|
||||
mapEnterResponse.addSigns(sign);
|
||||
}
|
||||
}
|
||||
Map<Integer, Integer> cellRefreshTime = endlessMapInfo.getCellRefreshTime();
|
||||
if(cellRefreshTime!=null&&cellRefreshTime.size()>0){
|
||||
for(Map.Entry<Integer, Integer> time:cellRefreshTime.entrySet()){
|
||||
CommonProto.EndlessRefreshInfo.Builder info = CommonProto.EndlessRefreshInfo.newBuilder();
|
||||
info.setCellId(time.getKey());
|
||||
info.setTime(time.getValue());
|
||||
mapEnterResponse.addRefreshInfo(info);
|
||||
}
|
||||
}
|
||||
mapEnterResponse.setSkipFight(endlessMapInfo.getSkipFight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder builder) throws Exception{
|
||||
super.outMap(uid, outType, curXY, builder);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
if(outType!=1){
|
||||
if(MapLogic.endlessSeason!=mapManager.getEndlessMapInfo().getSeason()){
|
||||
mapManager.updateEndlessLocation(0);
|
||||
}else{
|
||||
mapManager.updateEndlessLocation(curXY);
|
||||
}
|
||||
mapManager.updateEndlessConsumeExecution(0);
|
||||
mapManager.updateEndlessFightCount(0);
|
||||
}
|
||||
//无尽副本信息保存
|
||||
mapManager.endlessWalkCellSave(mapManager.getWalkCells());
|
||||
mapManager.endlessMapInfoSave(mapManager.getMapInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterNewMap(User user, int mapId,int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterNewMap(user, mapId,teamId, mapEnterResponse);
|
||||
MapLogic.getInstance().initMap(user.getMapManager(), user);
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revive(User user, SChallengeConfig sChallengeConfig, List<Integer> remainHp, int teamId) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
aceConsumeExecution(user);
|
||||
for(Map.Entry<String, Map<Integer, Integer>> entry: mapManager.getHeroAllAttributeMap().entrySet()){
|
||||
mapManager.updateHeroOneAttribute(entry.getKey(), HeroAttributeEnum.CurHP.getPropertyId(),0);
|
||||
mapManager.updateEndlessHeroHp(entry.getKey(),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void refreshHp(User user, int teamId, int[] checkResult) {
|
||||
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
for (int i = 0 ; i <team.size();i++) {
|
||||
Hero hero = user.getHeroManager().getHero(team.get(i).getHeroId());
|
||||
Map<Integer, Integer> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,teamId);
|
||||
int per = (int)(checkResult[i+2] / (double) heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
|
||||
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
|
||||
mapManager.updateHeroOneAttribute(team.get(i).getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[i+2]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastFight(int uid, FightInfoProto.FastFightResponse.Builder fastFightResponseBuilder) throws Exception {
|
||||
super.fastFight(uid, fastFightResponseBuilder);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
mapManager.updateEndlessFightCount(1+mapManager.getEndlessMapInfo().getFightCount());
|
||||
endlessRefreshMonster(uid,mapManager.getTriggerXY());
|
||||
}
|
||||
|
||||
/**
|
||||
* 无尽小怪打死随机刷新
|
||||
* @param session
|
||||
* @param triggerXY
|
||||
* @throws Exception
|
||||
*/
|
||||
private void endlessRefreshMonster(int uid,int triggerXY) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
Cell cell = mapManager.getMapInfo().get(triggerXY);
|
||||
MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(cell.getPointId());
|
||||
if(mapPointConfig.getStyle()==1){
|
||||
Map<Integer, SCMap> map= SCMap.sCMap.get(mapManager.getCurMapId());
|
||||
List<Integer> points = new ArrayList<>();
|
||||
for(Map.Entry<Integer, SCMap> entry:map.entrySet()){
|
||||
if(entry.getValue().getEvent()!=cell.getPointId()){
|
||||
continue;
|
||||
}
|
||||
boolean flagToAddMonster = true;
|
||||
int[][] groups = entry.getValue().getGroups();
|
||||
for(int i = 0;i<groups.length;i++){
|
||||
if(mapManager.getMapInfo().get(CellUtil.xy2Pos(groups[i][0],groups[i][1]))==null){
|
||||
continue;
|
||||
}
|
||||
if(mapManager.getMapInfo().get(CellUtil.xy2Pos(groups[i][0],groups[i][1])).getPointId()!=0){
|
||||
flagToAddMonster = false;
|
||||
}
|
||||
}
|
||||
if(flagToAddMonster){
|
||||
for(int i = 0;i<groups.length;i++){
|
||||
points.add(CellUtil.xy2Pos(groups[i][0], groups[i][1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.size()>0){
|
||||
//无尽副本随机空地刷新小怪
|
||||
int cellPos = points.get(MathUtils.randomInt(points.size()));
|
||||
Cell addCell = new Cell(cellPos,mapPointConfig.getInitialEventId(),mapPointConfig.getId());
|
||||
LOGGER.info("刷新位置为{},{}",CellUtil.pos2XY(cellPos)[0],CellUtil.pos2XY(cellPos)[1]);
|
||||
mapManager.addOrUpdateCell(cellPos,addCell);
|
||||
MapInfoProto.RefreshMonsterResponse monsterResponse = MapInfoProto.RefreshMonsterResponse.newBuilder().addCell(CBean2Proto.getCell(addCell)).build();
|
||||
MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(uid),1, MessageTypeProto.MessageType.ENDLESS_MONSTER_REFRESH_INDICATION_VALUE,monsterResponse,true);
|
||||
}
|
||||
BehaviorUtil.destoryApointXY(user, triggerXY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无尽副本团灭消耗行动力
|
||||
* @param user
|
||||
* @throws Exception
|
||||
*/
|
||||
private void aceConsumeExecution(User user) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()!=4){
|
||||
return;
|
||||
}
|
||||
mapManager.updateEndlessFightCount(mapManager.getEndlessMapInfo().getFightCount()+1);
|
||||
//消耗行动力
|
||||
int [][] cost = new int[1][];
|
||||
int costId = SChallengeSetting.getChallengeSetting().getActionPowerId();
|
||||
int costNum = SEndlessMapConfig.sEndlessMapConfigMap.get(mapManager.getCurMapId()).getDeathCost();
|
||||
mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution()+costNum);
|
||||
int [] cost1 = new int[]{costId,costNum};
|
||||
cost[0] = cost1;
|
||||
boolean costResult = ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1);
|
||||
if(!costResult) {
|
||||
costNum = user.getItemManager().getItem(costId).getItemNum();
|
||||
cost1[1]= costNum;
|
||||
cost[0] = cost1;
|
||||
ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int monsterGroupChange(int groupId) {
|
||||
if(STableManager.getFigureConfig(MapStaticConfig.class).getDifficultyMonster().containsKey(groupId)){
|
||||
groupId = STableManager.getFigureConfig(MapStaticConfig.class).getDifficultyMonster().get(groupId);
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public interface IMap {
|
||||
|
||||
IMap getInstence(int mapType);
|
||||
|
||||
void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception;
|
||||
|
||||
void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder mapOutResponse)throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum MapEnum {
|
||||
STORY_MAP(1, new StoryMap()),
|
||||
TOWER_MAP(2, new TowerMap()),
|
||||
DIFFICULTY_MAP(3, new DifficultMap()),
|
||||
ENDLESS_MAP(4, new EndlessMap()),
|
||||
|
||||
;
|
||||
|
||||
private int type;
|
||||
private AbstractMap toAbstractMap;
|
||||
private static final HashMap<Integer,MapEnum> MapEnumMap = new HashMap<>();
|
||||
static {
|
||||
for (MapEnum map:MapEnum.values()) {
|
||||
MapEnumMap.put(map.getType(),map);
|
||||
}
|
||||
}
|
||||
MapEnum(int type, AbstractMap toAbstractMap) {
|
||||
this.type = type;
|
||||
this.toAbstractMap = toAbstractMap;
|
||||
}
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AbstractMap getToAbstractMap() {
|
||||
return toAbstractMap;
|
||||
}
|
||||
|
||||
public static AbstractMap getAbstractMap(int type) {
|
||||
return MapEnumMap.get(type).getToAbstractMap();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public class StoryMap extends AbstractMap{
|
||||
int type = 1;
|
||||
public StoryMap() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterMap(uid, mapId, teamId, mapEnterResponse);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
|
||||
if (mapManager.getMission() != null) {
|
||||
mapEnterResponse.setMissions(MapLogic.getInstance().getMission(mapManager.getMission()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterNewMap(User user, int mapId,int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterNewMap(user, mapId,teamId, mapEnterResponse);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager.getPlayGenMaps().contains(mapId)) {
|
||||
boolean enough = ItemUtil.itemCost(user, new int[][]{{Global.GENERALSTORY_TICKET, 1}}, BIReason.MAP_ENTER_CONSUME, mapId);
|
||||
if (!enough) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("no ticket"));
|
||||
}
|
||||
}else{
|
||||
mapManager.updatePlayGenMaps(mapId);
|
||||
}
|
||||
MapLogic.getInstance().initMap(mapManager, user);
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.map.TowerBuff;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.TowerRankUtil;
|
||||
import config.STrialConfig;
|
||||
import config.STrialSetting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2019/10/25
|
||||
* @discribe
|
||||
*/
|
||||
public class TowerMap extends AbstractMap {
|
||||
int type = 2;
|
||||
@Override
|
||||
public void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder builder) throws Exception{
|
||||
super.outMap(uid,outType,curXY,builder);
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if(mapManager.getTowerUnusedBuffer()!=null){
|
||||
mapManager.setTowerUnusedBuffer(new HashMap<>());
|
||||
}
|
||||
LOGGER.info("退出地图");
|
||||
if(mapManager.getTower()>=1){
|
||||
mapManager.setMapIntoFlag(1);
|
||||
if(mapManager.getTower()== STrialConfig.getHighestTower()){
|
||||
mapManager.setHighestTower(mapManager.getTower());
|
||||
if(TowerRankUtil.getRankNumber(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000))> RedisUtil.getInstence().getZSetScore(RedisKey.TOWER_RANK, "", String.valueOf(user.getId()))){
|
||||
RedisUtil.getInstence().zsetAddOne(RedisKey.getKey(RedisKey.TOWER_RANK,"",false),String.valueOf(user.getId()),TowerRankUtil.getRankNumber(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
mapManager.setEssenceValue(0);
|
||||
mapManager.setCurrTowerTime(0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterMap(uid, mapId, teamId,mapEnterResponse);
|
||||
MapManager mapManager = UserManager.getUser(uid).getMapManager();
|
||||
if(mapManager.getTowerUnusedBuffer()!=null&&mapManager.getTowerUnusedBuffer().size()>=1){
|
||||
List<MapInfoProto.TowerBuff> towerBuffs = new ArrayList<>();
|
||||
for(Map.Entry<Integer,Integer> buffer:mapManager.getTowerUnusedBuffer().entrySet()){
|
||||
TowerBuff towerBuff = new TowerBuff(buffer.getKey(),buffer.getValue());
|
||||
towerBuffs.add(CBean2Proto.getTowerBuff(towerBuff));
|
||||
}
|
||||
mapEnterResponse.addAllBuf(towerBuffs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterNewMap(User user, int mapId,int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
|
||||
super.enterNewMap(user, mapId, teamId,mapEnterResponse);
|
||||
STrialSetting sTrialSetting = STrialSetting.sTrialSetting;
|
||||
int[] privilegeReward = sTrialSetting.getPrivilegeReward();
|
||||
if(user.getPlayerInfoManager().checkFunctionIsAllowed(privilegeReward[privilegeReward.length-1])){
|
||||
ItemUtil.drop(user,sTrialSetting.getBombReward(),1.0f,1,BIReason.MONTH_CARD_REWARD);
|
||||
}
|
||||
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_TIMES,1);
|
||||
MapLogic.getInstance().initTrialMap(user.getMapManager(), user);
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,user.getMapManager().getTower());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshHp(User user, int teamId, int[] checkResult) {
|
||||
super.refreshHp(user, teamId, checkResult);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
//删点之前进行查找
|
||||
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
|
||||
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
|
||||
int[][] randomMonsterType = sTrialConfig.getRandomMonsterType();
|
||||
if(cell.getCellId()!=mapManager.getBossXY()){
|
||||
if(mapManager.getEssenceValue()!=-1){
|
||||
if (randomMonsterType[0][1] == cell.getPointId()) {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getNormalEnergy());
|
||||
} else {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getEliteEnergy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue