出地图方法优化
parent
256099e1a1
commit
43ee84f538
|
@ -57,7 +57,7 @@ public class MapLogic {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MapLogic.class);
|
||||
|
||||
private Map<Integer, BaseBehavior> baseBehaviorMap = new HashMap<>();
|
||||
public Map<Integer, BaseBehavior> baseBehaviorMap = new HashMap<>();
|
||||
|
||||
public static int endlessSeason;
|
||||
|
||||
|
@ -507,7 +507,7 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
|
||||
private int getNextEventId(User user, Cell cell, SOptionConfig sOptionConfig) throws Exception {
|
||||
public int getNextEventId(User user, Cell cell, SOptionConfig sOptionConfig) throws Exception {
|
||||
int jumpType = sOptionConfig.getJumpType();
|
||||
int[][] jumpTypeValues = sOptionConfig.getJumpTypeValues();
|
||||
switch (jumpType) {
|
||||
|
|
|
@ -30,7 +30,9 @@ public class FightEndRequestHandler extends BaseHandler {
|
|||
//MapLogic.getInstance().endDifficultyFight(iSession, frames,fightId,MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
|
||||
}else if(type == 2){
|
||||
int dropout = fightEndRequest.getDropout();
|
||||
MapLogic.getInstance().endFight(iSession, frames, MessageTypeProto.MessageType.FIGHT_END_RESPONSE,dropout);
|
||||
FightInfoProto.FightEndResponse.Builder builder = FightInfoProto.FightEndResponse.newBuilder();
|
||||
MapLogic.curMapType(iSession).endFight(iSession.getUid(), frames, builder,dropout);
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.FIGHT_END_RESPONSE_VALUE,builder.build(),true );
|
||||
}else if(type == 3){
|
||||
MapLogic.getInstance().endSuddlenlyFight(iSession, frames, MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
|
||||
}else if(type == 5){
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler.map.mapType;
|
||||
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.MapStaticConfig;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
@ -368,11 +369,146 @@ public abstract class AbstractMap implements IMap {
|
|||
}
|
||||
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 endFight(int uid, String frames, FightInfoProto.FightEndResponse.Builder builder,int dropout) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT, Integer.toString(uid), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
RedisUtil.getInstence().del(key);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
LOGGER.info("endFight() uid=>{} not start fight", uid);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过"));
|
||||
}
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (user.getMapManager().getCanMoveTime() > 0) {
|
||||
long leftTime = user.getMapManager().getCanMoveTime() - TimeUtils.now();
|
||||
if (leftTime > 0) {
|
||||
throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+""));
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> remainHp = new ArrayList<>(5);
|
||||
int triggerXY = mapManager.getTriggerXY();
|
||||
int optionId = Integer.parseInt((String) valueMap.get(RedisKey.NEED_VICTORY_AFTER));
|
||||
int nextEventId = 0;
|
||||
SOptionConfig sOptionConfig = SOptionConfig.sOptionConfigMap.get(optionId);
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId());
|
||||
//校验结果码 1:胜利
|
||||
int resultCode=0;
|
||||
int[] checkResult = new int[0];
|
||||
int monsterGroupId=0;
|
||||
SMonsterGroup sMonsterGroup=null;
|
||||
if(dropout ==0){
|
||||
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
|
||||
monsterGroupId = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_GROUPID));
|
||||
CommonProto.FightTeamInfo.Builder fightTeamBuilder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), fightTeamBuilder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = fightTeamBuilder.build();
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(monsterGroupId);
|
||||
if (sMonsterGroup == null) {
|
||||
LOGGER.info("endFight() uid=>{} monsterGroupId=>{} sMonsterGroup == null", uid, monsterGroupId);
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
int mostTime = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getMostTime();
|
||||
checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, FightType.MapExploreFight);
|
||||
resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
mapManager.setLastFightResult(resultCode);
|
||||
if (resultCode == 0 || dropout == 1) {
|
||||
//todo 无尽副本复活
|
||||
//无尽副本复活消耗
|
||||
revive(user,sChallengeConfig,remainHp,mapManager.getTeamId());
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
builder.setResult(resultCode);
|
||||
builder.setEnventDrop(dropBuilder);
|
||||
builder.addAllRemainHpList(remainHp);
|
||||
builder.setLastXY(mapManager.getLastXY());
|
||||
mapManager.setCurXY(mapManager.getLastXY());
|
||||
if (SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType() == 2) {
|
||||
builder.setLastTowerTime((int) (mapManager.getCurrTowerTime() / 1000));
|
||||
}
|
||||
if (sOptionConfig != null) {
|
||||
int[][] jumpTypeValues = sOptionConfig.getJumpTypeValues();
|
||||
if (jumpTypeValues.length > 0 && sOptionConfig.getJumpType() == 3) {
|
||||
SOptionAddCondition sOptionAddConditions = SOptionAddCondition.sOptionAddConditionMap.get(jumpTypeValues[1][1]);
|
||||
if (sOptionAddConditions != null && sOptionAddConditions.getType() == 7) {
|
||||
Cell cell = mapManager.getMapInfo().get(triggerXY);
|
||||
if (cell != null) {
|
||||
nextEventId = MapLogic.getInstance().getNextEventId(user, cell, sOptionConfig);
|
||||
cell.setEventId(nextEventId);
|
||||
mapManager.addOrUpdateCell(triggerXY, cell);
|
||||
builder.setEventId(nextEventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int i = 2; i < checkResult.length; i++) {
|
||||
if (checkResult[i] <= 0) {
|
||||
remainHp.add(0);
|
||||
} else {
|
||||
remainHp.add(checkResult[i]);
|
||||
}
|
||||
}
|
||||
//血量更新
|
||||
refreshHp(user, mapManager.getTeamId(),checkResult);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 1, BIReason.MAP_GENERAL_FIGHT_REWARD);
|
||||
builder.setEnventDrop(drop.build());
|
||||
builder.setResult(resultCode);
|
||||
builder.addAllRemainHpList(remainHp);
|
||||
builder.build();
|
||||
//todo 无尽本待定
|
||||
// if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4){
|
||||
// endlessRefreshMonster(session,triggerXY);
|
||||
// }
|
||||
if (sOptionConfig != null) {
|
||||
int behaviorType = sOptionConfig.getBehaviorType();
|
||||
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
|
||||
BaseBehavior baseBehavior = MapLogic.getInstance().baseBehaviorMap.get(behaviorType);
|
||||
if (baseBehavior != null) {
|
||||
baseBehavior.afterFight(user, behaviorTypeValues, builder);
|
||||
}
|
||||
}else{
|
||||
BehaviorUtil.destoryApointXY(user,triggerXY);
|
||||
}
|
||||
|
||||
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
|
||||
mapManager.findSuddenlyBoss(0, 0);
|
||||
|
||||
}else{
|
||||
if(sOptionConfig!=null){
|
||||
Cell cell = mapManager.getMapInfo().get(triggerXY);
|
||||
if (cell != null ) {
|
||||
nextEventId = MapLogic.getInstance().getNextEventId(user, cell, sOptionConfig);
|
||||
cell.setEventId(nextEventId);
|
||||
mapManager.addOrUpdateCell(triggerXY, cell);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
builder.setEventId(nextEventId);
|
||||
MapMissionManager.updateMapMission(user, EventType.fightEvent, monsterGroupId, checkResult[1]);
|
||||
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
|
||||
mapManager.findSuddenlyBoss(0, 0);
|
||||
}
|
||||
if(mapManager.getTower()==STrialConfig.getHighestTower()&&mapManager.getBossType()!=0){
|
||||
|
||||
int time = (int)((TimeUtils.now()-mapManager.getTowerStartTime())/1000);
|
||||
mapManager.setCurrTowerTime(time*1000);
|
||||
LOGGER.info("此层为最后一层,使用时间为{}",time);
|
||||
builder.setLastTowerTime(time);
|
||||
}else{
|
||||
builder.setLastTowerTime(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void revive(User user,SChallengeConfig sChallengeConfig,List<Integer> remainHp,int teamId) throws Exception {
|
||||
|
@ -406,7 +542,7 @@ public abstract class AbstractMap implements IMap {
|
|||
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]);
|
||||
user.getMapManager().updateHeroOneAttribute(teamPosHeroInfo.getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[teamPosHeroInfo.getPosition()+2]);
|
||||
}
|
||||
}
|
||||
public int monsterGroupChange(int groupId){
|
||||
|
|
Loading…
Reference in New Issue