无尽副本第二版

back_recharge
lvxinran 2021-05-26 16:14:29 +08:00
parent 6d76941d51
commit a597b3545e
14 changed files with 438 additions and 220 deletions

View File

@ -37,8 +37,8 @@ public class EndlessFunction implements FunctionManager {
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception { public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
int times = timeControllerOfFunction.getTimes(); int times = timeControllerOfFunction.getTimes();
int[] maps = new int[]{4001,4002}; int[] maps = new int[]{4001,4002};
// maps[times % maps.length];
int mapId = maps[times % maps.length]; int mapId = 4001;
MapLogic.endlessMapId = mapId; MapLogic.endlessMapId = mapId;

View File

@ -120,6 +120,8 @@ public class EventType {
public static final int fourtyNine = 49; public static final int fourtyNine = 49;
public static final int fifty = 50; public static final int fifty = 50;
public static final int fiftyone = 51; public static final int fiftyone = 51;
public static final int fiftytwo = 52;
public static final int fiftythree = 53;
public static final int updatePonintEvent = 1; public static final int updatePonintEvent = 1;
public static final int fightEvent = 2; public static final int fightEvent = 2;

View File

@ -3348,7 +3348,8 @@ public class MapLogic {
int uid = session.getUid(); int uid = session.getUid();
User user = UserManager.getUser(uid); User user = UserManager.getUser(uid);
EndlessTreasureReward worldTreasureReward = user.getMapManager().getEndlessTreasureReward(); EndlessTreasureReward worldTreasureReward = user.getMapManager().getEndlessTreasureReward();
//检测一下刷新
flushEndlessTreasure(user);
MapInfoProto.EndlessTreasureInfoResponse.Builder response = MapInfoProto.EndlessTreasureInfoResponse.newBuilder(); MapInfoProto.EndlessTreasureInfoResponse.Builder response = MapInfoProto.EndlessTreasureInfoResponse.newBuilder();
// if(worldTreasureReward.getFirstStartTime()!=0&&worldTreasureReward.getFirstStartTime()<=TimeUtils.nowInt()&&worldTreasureReward.getCreateTime()>TimeUtils.now()/1000){ // if(worldTreasureReward.getFirstStartTime()!=0&&worldTreasureReward.getFirstStartTime()<=TimeUtils.nowInt()&&worldTreasureReward.getCreateTime()>TimeUtils.now()/1000){
Map<Integer, Integer> rewardStatusMap = worldTreasureReward.getRewardStatusMap(); Map<Integer, Integer> rewardStatusMap = worldTreasureReward.getRewardStatusMap();
@ -3369,13 +3370,12 @@ public class MapLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
} }
public void flushEndlessTreasure(User user) throws Exception { public void flushEndlessTreasure(User user) throws Exception {
if(user.getMapManager().getEndlessTreasureReward().getCreateTime()<TimeUtils.now()){ if(user.getMapManager().getEndlessTreasureReward().getCreateTime()<TimeUtils.nowInt()){
user.getMapManager().getEndlessTreasureReward().reset(); user.getMapManager().getEndlessTreasureReward().reset();
Item item = user.getItemManager().getItem(102);//升级积分清除 Item item = user.getItemManager().getItem(102);//升级积分清除
if(item!=null&&item.getItemNum()>0){ if(item!=null&&item.getItemNum()>0){
item.setItemNum(0); item.setItemNum(0);
} }
} }
} }
} }

View File

@ -162,11 +162,16 @@ public class BehaviorUtil {
* @param fightStartRespons * @param fightStartRespons
* @throws Exception * @throws Exception
*/ */
public static void getFightInfo(User user, int teamId,int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String pointId,int maxTime,boolean isMyself) throws Exception { public static void getFightInfo(User user, int teamId,int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String pointId,int maxTime,boolean isMyself,Map<String,Integer> bloodMap) throws Exception {
MapManager mapManager = user.getMapManager(); MapManager mapManager = user.getMapManager();
CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder(); CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder();
CommonProto.FightTeamInfo fightTeamInfo = getFightTeamInfo(user, teamId,isMyself); CommonProto.FightTeamInfo fightTeamInfo;
if(teamId==GlobalsDef.ENDLESS_TEAM){
fightTeamInfo = FightUtil.makePersonFightData(user,teamId,bloodMap,null);
}else{
fightTeamInfo = getFightTeamInfo(user, teamId,isMyself);
}
fightData.setHeroFightInfos(fightTeamInfo); fightData.setHeroFightInfos(fightTeamInfo);
//monster //monster
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId); Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);

View File

@ -0,0 +1,43 @@
package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.EndlessMapInfo;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.logic.dao.root.User;
import org.springframework.stereotype.Component;
import rpc.protocols.MapInfoProto;
import util.MathUtils;
import java.util.HashMap;
import java.util.Map;
/**
* @author lvxinran
* @date 2021/5/26
* @discribe
*/
@Component
public class FiftyThreeBehavior extends BaseBehavior {
@Override
public int getBehaviorType() {
return EventType.fiftythree;
}
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
//回复血量
EndlessMapInfo endlessMapInfo = user.getMapManager().getEndlessMapInfo();
Map<String, Integer> endlessHeroInfo = endlessMapInfo.getEndlessHeroInfo();
Map<String,Integer> newHpMap = new HashMap<>();
endlessHeroInfo.forEach((k,v)-> newHpMap.put(k,v==0?0: Math.min(v+behaviorTypeValues[0][0],10000)));
user.getMapManager().updateEndlessHero(newHpMap);
//计算时间
BehaviorUtil.refreshTimeMonster(user,behaviorTypeValues[0][1]);
return true;
}
}

View File

@ -0,0 +1,56 @@
package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.Cell;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import org.springframework.stereotype.Component;
import rpc.protocols.FightInfoProto;
import rpc.protocols.MapInfoProto;
import util.CellUtil;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author lvxinran
* @date 2021/5/25
* @discribe
*/
@Component
public class FiftyTwoBehavior extends BaseBehavior {
@Override
public int getBehaviorType() {
return EventType.fiftytwo;
}
@Override
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
String readyInfo = behaviorTypeValues[0][0] + "#" + Integer.toString(optionId);
BehaviorUtil.fightReady(user.getId(), readyInfo);
return true;
}
@Override
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
BehaviorUtil.destoryPoint(user,behaviorTypeValues[0][1]);
int[] behaviorTypeValue = behaviorTypeValues[1];
Set<Integer> checkPoint = new HashSet<>();
Arrays.stream(behaviorTypeValue).forEach(checkPoint::add);
for(Map.Entry<Integer, Cell> entry:user.getMapManager().getMapInfo().entrySet()){
int pointId = entry.getValue().getPointId();
if(checkPoint.contains(pointId)){
return true;
}
}
int[] add = behaviorTypeValues[2];
BehaviorUtil.addBehaviorInfo(add[2],user, CellUtil.xy2Pos(add[0],add[1]));
user.getUserMissionManager().onGameEvent(user, GameEvent.ENDLESS_KILL_SMALL_BOSS);
return true;
}
}

View File

@ -218,53 +218,53 @@ public abstract class AbstractMap implements IMap {
* @throws Exception * @throws Exception
*/ */
public void startFight(int uid,FightInfoProto.FightStartResponse.Builder responseBuilder) throws Exception{ public void startFight(int uid,FightInfoProto.FightStartResponse.Builder responseBuilder) throws Exception{
User user = UserManager.getUser(uid); // User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager(); // MapManager mapManager = user.getMapManager();
if (mapManager.getMapInfo() == null) { // if (mapManager.getMapInfo() == null) {
LOGGER.info("mapManager.getMapInfo() == null"); // LOGGER.info("mapManager.getMapInfo() == null");
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); //// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} // }
if (mapManager.getCanMoveTime() > 0) { // if (mapManager.getCanMoveTime() > 0) {
long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); // long leftTime = mapManager.getCanMoveTime() - TimeUtils.now();
if (leftTime > 0) { // if (leftTime > 0) {
// throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+"")); //// throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+""));
} // }
} // }
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); // Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
if (cell == null) { // if (cell == null) {
cell = mapManager.getMapInfo().get(mapManager.getCurXY()); // cell = mapManager.getMapInfo().get(mapManager.getCurXY());
if (cell == null) { // if (cell == null) {
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY()); // LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
// throw new ErrorCodeException(ErrorCode.newDefineCode("cell == null")); //// throw new ErrorCodeException(ErrorCode.newDefineCode("cell == null"));
} // }
} // }
int bigEventId = cell.getEventId(); // int bigEventId = cell.getEventId();
SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(bigEventId); // SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(bigEventId);
if (sEventPointConfig == null) { // if (sEventPointConfig == null) {
LOGGER.info("sEventPointConfig == null"); // LOGGER.info("sEventPointConfig == null");
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); //// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} // }
String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false); // String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false);
String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey); // String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey);
int groupId; // int groupId;
String pointId = "0"; // String pointId = "0";
if (fightReady != null) { // if (fightReady != null) {
String[] split = fightReady.split("#"); // String[] split = fightReady.split("#");
RedisUtil.getInstence().del(fightReadyKey); // RedisUtil.getInstence().del(fightReadyKey);
groupId = monsterGroupChange(Integer.parseInt(split[0]),user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId()); // groupId = monsterGroupChange(Integer.parseInt(split[0]),user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId());
if (split.length > 1) { // if (split.length > 1) {
pointId = split[1]; // pointId = split[1];
} // }
} else { // } else {
int[] option = sEventPointConfig.getOption(); // int[] option = sEventPointConfig.getOption();
if (option == null||option.length<1) { // if (option == null||option.length<1) {
LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId()); // LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId());
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); //// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} // }
groupId = monsterGroupChange(option[0],user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId()); // groupId = monsterGroupChange(option[0],user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId());
} // }
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()); // SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
BehaviorUtil.getFightInfo(user,401, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true); // BehaviorUtil.getFightInfo(user,401, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true);
} }
public void fastFight(int uid, FightInfoProto.FastFightResponse.Builder fastFightResponseBuilder) throws Exception { public void fastFight(int uid, FightInfoProto.FastFightResponse.Builder fastFightResponseBuilder) throws Exception {
@ -272,157 +272,7 @@ public abstract class AbstractMap implements IMap {
} }
public void endFight(int uid, String frames, FightInfoProto.FightEndResponse.Builder builder,int dropout) throws Exception { 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)+""));
}
}
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;
long[] checkResult = new long[0];
int monsterGroupId=0;
List<Long> remainHp = new ArrayList<>(6);
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 = 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 = (int) checkResult[0];
if (resultCode == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
}
mapManager.setLastFightResult(resultCode);
if (resultCode == 0) {
//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;
}
//无尽本更新血量
if(mapManager.getCurMapType()==MapEnum.ENDLESS_MAP.getType()){
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (int i = 0 ; i <team.size();i++) {
int position = team.get(i).getPosition();
Hero hero = user.getHeroManager().getHero(team.get(i).getHeroId());
Map<Integer, Long> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,GlobalsDef.ENDLESS_TEAM);
int per = (int)(checkResult[position+1] / (double) heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+1]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
}
}
for (int i = 2; i < checkResult.length; i++) {
if (checkResult[i] <= 0) {
remainHp.add((long) 0);
} else {
remainHp.add(checkResult[i]);
}
}
//血量更新
// refreshHp(user, mapManager.getTeamId(),checkResult);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 0, 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, (int) checkResult[1]);
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
mapManager.findSuddenlyBoss(0, 0);
}
if(mapManager.getTrialInfo().getFloor()==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<Long> remainHp,int teamId) throws Exception { public void revive(User user,SChallengeConfig sChallengeConfig,List<Long> remainHp,int teamId) throws Exception {

View File

@ -1,12 +1,18 @@
package com.ljsd.jieling.handler.map.mapType; package com.ljsd.jieling.handler.map.mapType;
import com.googlecode.protobuf.format.JsonFormat;
import com.ljsd.fight.CheckFight;
import com.ljsd.fight.FightType;
import com.ljsd.jieling.core.FunctionIdEnum; import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil; import com.ljsd.jieling.db.mongo.MongoUtil;
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.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException; import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.map.*; 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.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.OnlineUserManager;
@ -20,6 +26,8 @@ import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.util.FightDataUtil;
import org.luaj.vm2.LuaValue;
import rpc.protocols.CommonProto; import rpc.protocols.CommonProto;
import rpc.protocols.FightInfoProto; import rpc.protocols.FightInfoProto;
import rpc.protocols.MapInfoProto; import rpc.protocols.MapInfoProto;
@ -31,6 +39,7 @@ import config.*;
import manager.STableManager; import manager.STableManager;
import util.CellUtil; import util.CellUtil;
import util.MathUtils; import util.MathUtils;
import util.TimeUtils;
import java.util.*; import java.util.*;
@ -237,9 +246,10 @@ public class EndlessMap extends AbstractMap{
}else{ }else{
for (TeamPosHeroInfo info:team) { for (TeamPosHeroInfo info:team) {
int position = info.getPosition(); int position = info.getPosition();
Hero hero = user.getHeroManager().getHero(info.getHeroId()); Hero hero = user.getHeroManager().getEndlessHeroInfo().get(info.getHeroId());
Map<Integer, Long> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,GlobalsDef.ENDLESS_TEAM); Map<Integer, Long> heroAttributeMap = SEndlessHeroProp.propsMap.get(hero.getTemplateId());
int per = (int)(checkResult[position+1] *10000d / heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId()));
int per = (int)(checkResult[position+1] *10000d / heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
if(checkResult[position+1]>0&&per<=0){ if(checkResult[position+1]>0&&per<=0){
per = 1; per = 1;
} }
@ -255,6 +265,7 @@ public class EndlessMap extends AbstractMap{
} }
} }
user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, updateTeam); user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, updateTeam);
user.getUserMissionManager().onGameEvent(user,GameEvent.ENDLESS_KILL_MONTER);
} }
@ -285,17 +296,19 @@ public class EndlessMap extends AbstractMap{
private void checkMoraleLevel(User user) throws Exception { private void checkMoraleLevel(User user) throws Exception {
Map<Integer, Item> itemMap = user.getItemManager().getItemMap(); Map<Integer, Item> itemMap = user.getItemManager().getItemMap();
if(!itemMap.containsKey(100)){
return;
}
int moraleLevel = user.getMapManager().getEndlessMapInfo().getMoraleLevel();
Map<Integer, SEndlessMorale> config = STableManager.getConfig(SEndlessMorale.class); Map<Integer, SEndlessMorale> config = STableManager.getConfig(SEndlessMorale.class);
int moraleLevel = user.getMapManager().getEndlessMapInfo().getMoraleLevel();
SEndlessMorale expConfig = config.get(moraleLevel + 1); SEndlessMorale expConfig = config.get(moraleLevel + 1);
if(expConfig==null||expConfig.getExp()==0){ int[] exp = expConfig.getExp();
if(exp==null|| exp.length==0){
return; return;
} }
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{100, expConfig.getExp()}}, BIReason.MORALE_LEVEL_UP_CONSUME, 1); if(!itemMap.containsKey(exp[0])){
return;
}
Map<Integer,Integer> costMap = new HashMap<>();
costMap.put(exp[0],exp[1]);
boolean itemCost = ItemUtil.checkCost(user,costMap);
if(!itemCost){ if(!itemCost){
return; return;
} }
@ -500,4 +513,228 @@ public class EndlessMap extends AbstractMap{
public void updateLocation(User user,int xy) { public void updateLocation(User user,int xy) {
user.getMapManager().updateEndlessLocation(xy); user.getMapManager().updateEndlessLocation(xy);
} }
/**
*
* @param uid
* @param responseBuilder
* @throws Exception
*/
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]),user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId());
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],user.getPlayerInfoManager().getLevel(),mapManager.getCurMapId());
}
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
Map<String, Integer> endlessHeroInfo = mapManager.getEndlessMapInfo().getEndlessHeroInfo();
List<TeamPosHeroInfo> endteam = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
Map<String,Integer> bloodMap = new HashMap<>();
for (int i = 0 ; i <endteam.size();i++) {
String heroId= endteam.get(i).getHeroId();
bloodMap.put(heroId,(10000-endlessHeroInfo.get(heroId))/100);
}
BehaviorUtil.getFightInfo(user,401, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true,bloodMap);
}
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)+""));
}
}
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;
long[] checkResult = new long[0];
int monsterGroupId=0;
List<Long> remainHp = new ArrayList<>(6);
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 = 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 = (int) checkResult[0];
if (resultCode == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
}
mapManager.setLastFightResult(resultCode);
if (resultCode == 0) {
//无尽副本复活消耗
// 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);
}
}
}
}
if(mapManager.getCurMapType()==MapEnum.ENDLESS_MAP.getType()){
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (int i = 0 ; i <team.size();i++) {
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),0);
}
}
return;
}
//无尽本更新血量
if(mapManager.getCurMapType()==MapEnum.ENDLESS_MAP.getType()){
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (int i = 0 ; i <team.size();i++) {
int position = team.get(i).getPosition();
Hero hero = user.getHeroManager().getEndlessHeroInfo().get(team.get(i).getHeroId());
Map<Integer, Long> heroAttributeMap = SEndlessHeroProp.propsMap.get(hero.getTemplateId());
int per = (int)(checkResult[position+1] / (double) heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+1]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
}
}
for (int i = 2; i < checkResult.length; i++) {
if (checkResult[i] <= 0) {
remainHp.add((long) 0);
} else {
remainHp.add(checkResult[i]);
}
}
//血量更新
// refreshHp(user, mapManager.getTeamId(),checkResult);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 0, 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, (int) checkResult[1]);
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
mapManager.findSuddenlyBoss(0, 0);
}
if(mapManager.getTrialInfo().getFloor()==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);
}
}
} }

View File

@ -804,4 +804,8 @@ public class UserMissionManager extends MongoBase {
public EndlessMissionType getEndlessMissionType() { public EndlessMissionType getEndlessMissionType() {
return endlessMissionType; return endlessMissionType;
} }
public CumulationData getEndlessTask() {
return endlessTask;
}
} }

View File

@ -115,5 +115,7 @@ public enum GameEvent {
ENDLESS_MISSION_REWARD, ENDLESS_MISSION_REWARD,
ENDLESS_MORALE_LEVEL_UP, ENDLESS_MORALE_LEVEL_UP,
ENDLESS_KILL_MONTER, ENDLESS_KILL_MONTER,
ENDLESS_KILL_SMALL_BOSS,
ENDLESS_KILL_LAST_BOSS,
ENDLESS_OPEN_MAP ENDLESS_OPEN_MAP
} }

View File

@ -381,16 +381,23 @@ public class MissionLoigc {
BitSet rewardedMissionIds = missionType.getRewardedMissionIds(); BitSet rewardedMissionIds = missionType.getRewardedMissionIds();
Collection<SEndlessTask> values = STableManager.getConfig(SEndlessTask.class).values(); Collection<SEndlessTask> values = STableManager.getConfig(SEndlessTask.class).values();
CumulationData treasureCumulationData = user.getUserMissionManager().getEndlessTask();
values.forEach(v->{ values.forEach(v->{
int id = v.getId(); int id = v.getId();
SEndlessTask config = STableManager.getConfig(SEndlessTask.class).get(id);
CommonProto.UserMissionInfo.Builder info = CommonProto.UserMissionInfo.newBuilder(); CommonProto.UserMissionInfo.Builder info = CommonProto.UserMissionInfo.newBuilder();
info.setMissionId(id); info.setMissionId(id);
info.setType(GameMisionType.ENDLESS_MISSION.getType()); info.setType(GameMisionType.ENDLESS_MISSION.getType());
if (doingMissionIds.contains(id)){ if (doingMissionIds.contains(id)){
info.setState(MissionState.DOING.getState()); info.setState(MissionState.DOING.getState());
int doingProgress = getDoingProgress(user, treasureCumulationData, config.getType(), config.getValues()[0]);
info.setProgress(doingProgress);
} }
if (finishMissionIds.contains(id)){ if (finishMissionIds.contains(id)){
int finishProgress = config.getValues()[1][0];
info.setState(MissionState.FINISH.getState()); info.setState(MissionState.FINISH.getState());
info.setProgress(finishProgress);
} }
if (rewardedMissionIds.get(id)){ if (rewardedMissionIds.get(id)){
info.setState(MissionState.REWARD.getState()); info.setState(MissionState.REWARD.getState());

View File

@ -12,7 +12,7 @@ import com.ljsd.jieling.logic.mission.MissionType;
public class EndlessMoraleDataManager extends AbstractDataManager { public class EndlessMoraleDataManager extends AbstractDataManager {
@Override @Override
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) { public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
data.endlessMorale+=(int)parm[0]; data.endlessMorale=(int)parm[0];
return new CumulationData.Result(missionType); return new CumulationData.Result(missionType);
} }

View File

@ -439,12 +439,24 @@ public class MissionEventDistributor {
typeList = new ArrayList<>(); typeList = new ArrayList<>();
typeList.add(MissionType.ENDLESS_MONSTER_KILL); typeList.add(MissionType.ENDLESS_MONSTER_KILL);
typeList.add(MissionType.ENDLESS_BOSS_KILL);
typeList.add(MissionType.ENDLESS_LAST_BOSS);
eventEnumListMap.put(GameEvent.ENDLESS_KILL_MONTER, typeList); eventEnumListMap.put(GameEvent.ENDLESS_KILL_MONTER, typeList);
eventProcessor.put(GameEvent.ENDLESS_KILL_MONTER, new CumulationDataEventProcessor()); eventProcessor.put(GameEvent.ENDLESS_KILL_MONTER, new CumulationDataEventProcessor());
typeList = new ArrayList<>();
typeList.add(MissionType.ENDLESS_BOSS_KILL);
eventEnumListMap.put(GameEvent.ENDLESS_KILL_SMALL_BOSS, typeList);
eventProcessor.put(GameEvent.ENDLESS_KILL_SMALL_BOSS, new CumulationDataEventProcessor());
typeList = new ArrayList<>();
typeList.add(MissionType.ENDLESS_LAST_BOSS);
eventEnumListMap.put(GameEvent.ENDLESS_KILL_LAST_BOSS, typeList);
eventProcessor.put(GameEvent.ENDLESS_KILL_LAST_BOSS, new CumulationDataEventProcessor());
typeList = new ArrayList<>(); typeList = new ArrayList<>();
typeList.add(MissionType.ENDLESS_OPEN_PERCENT); typeList.add(MissionType.ENDLESS_OPEN_PERCENT);
eventEnumListMap.put(GameEvent.ENDLESS_OPEN_MAP, typeList); eventEnumListMap.put(GameEvent.ENDLESS_OPEN_MAP, typeList);
@ -537,7 +549,7 @@ public class MissionEventDistributor {
if(gameMisionType == GameMisionType.COPYMISSION || gameMisionType == GameMisionType.TREASUREMISSION if(gameMisionType == GameMisionType.COPYMISSION || gameMisionType == GameMisionType.TREASUREMISSION
|| gameMisionType == GameMisionType.SEVENMISSION || gameMisionType == GameMisionType.BLOODYMISSION || gameMisionType == GameMisionType.SEVENMISSION || gameMisionType == GameMisionType.BLOODYMISSION
|| gameMisionType == GameMisionType.ACHIEVEMISSION || gameMisionType == GameMisionType.JADE_DYNASTY_MISSION || gameMisionType == GameMisionType.ACHIEVEMISSION || gameMisionType == GameMisionType.JADE_DYNASTY_MISSION
|| gameMisionType == GameMisionType.COWFLYSKYMISSION ){ || gameMisionType == GameMisionType.COWFLYSKYMISSION||gameMisionType==GameMisionType.ENDLESS_MISSION){
progress = missionStateChangeInfo.getProgress(); progress = missionStateChangeInfo.getProgress();
} }
if(missionState == MissionState.DOING){ if(missionState == MissionState.DOING){

View File

@ -12,7 +12,7 @@ public class SEndlessMorale implements BaseConfig {
private int level; private int level;
private int exp; private int[] exp;
private int[][] props; private int[][] props;
@ -33,7 +33,7 @@ public class SEndlessMorale implements BaseConfig {
return level; return level;
} }
public int getExp() { public int[] getExp() {
return exp; return exp;
} }