change fight
parent
9c68ef183a
commit
df7b1345b6
|
|
@ -0,0 +1,141 @@
|
|||
import manager.STableManager;
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.jse.JsePlatform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CheckFight {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CheckFight.class);
|
||||
|
||||
private ThreadLocal<LuaValue> localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
|
||||
// private String luaFileName = null;
|
||||
|
||||
private CheckFight(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static CheckFight instance = new CheckFight();
|
||||
}
|
||||
|
||||
public static CheckFight getInstance() {
|
||||
return CheckFight.Instance.instance;
|
||||
}
|
||||
|
||||
private int hotFixVersion = 0;
|
||||
|
||||
static class LuaHotFixBean{
|
||||
private int version;
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void luaHotFix(){
|
||||
LuaHotFixBean luaHotFixBean = STableManager.getJsonFilePathInJsonConf("lua-hotfix.json", LuaHotFixBean.class);
|
||||
if(luaHotFixBean!=null && hotFixVersion < luaHotFixBean.getVersion()){
|
||||
LOGGER.info("the curhotFixVersion={},the new hotFixVersion={} will hotifx ",hotFixVersion,luaHotFixBean.getVersion());
|
||||
init();
|
||||
LOGGER.info("the luahotfix done");
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
this.localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
}
|
||||
}
|
||||
|
||||
public void init(){
|
||||
LuaHotFixBean luaHotFixBean = STableManager.getJsonFilePathInJsonConf("lua-hotfix.json", LuaHotFixBean.class);
|
||||
if(luaHotFixBean!=null) {
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getPath(String prefixDir, String... filePath) throws IOException {
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(getRootPath()).append(prefixDir);
|
||||
for (String p : filePath) {
|
||||
path.append(File.separator).append(p);
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public static String getRootPath() throws IOException {
|
||||
StringBuilder path = new StringBuilder();
|
||||
if (isWindows()) {// Window 系统
|
||||
path.append(new File(".").getCanonicalPath()).append(File.separator);
|
||||
}else {
|
||||
path.append("../");
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public static boolean isWindows() {
|
||||
String osName = System.getProperty("os.name");
|
||||
return osName.matches("^(?i)Windows.*$");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单线程执行每次用时50ms,目前支持并发100以内,再大用线程池异步处理
|
||||
* http://www.luaj.org/luaj/3.0/examples/jse/SampleMultiThreaded.java
|
||||
* @param seed
|
||||
* @param fightData
|
||||
* @param optionData
|
||||
* @return {战斗结果,战斗时间,单位1剩余血量,单位2剩余血量,单位3剩余血量,单位4剩余血量,单位5剩余血量}
|
||||
*/
|
||||
public int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
|
||||
LuaValue transCoderObj = this.getTransCoderObj();
|
||||
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
|
||||
LuaValue args = new LuaTable();
|
||||
args.set("seed",seed);
|
||||
args.set("maxTime",maxTime);
|
||||
//todo type
|
||||
args.set("type",fightType.getType());
|
||||
LuaValue result = func.call( args,fightData,optionData);
|
||||
int status = result.get("result").toint();
|
||||
int duration = result.get("duration").toint();
|
||||
int[] resultCache = new int[7];
|
||||
resultCache[0]=status;
|
||||
resultCache[1]=duration;
|
||||
LOGGER.info(" lua check test fight result : "+ status);
|
||||
for (int i = 1; i <= result.length(); i++) {
|
||||
resultCache[i+1] = result.rawget(i).toint();
|
||||
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
||||
}
|
||||
|
||||
return resultCache;
|
||||
}
|
||||
|
||||
public LuaValue getTransCoderObj(){
|
||||
LuaValue transCoderObj = localTransCoderObj.get();
|
||||
if(transCoderObj == null){
|
||||
String luaFileName = null;
|
||||
try {
|
||||
luaFileName = getPath("luafight/BattleMain.lua");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Globals globals = JsePlatform.debugGlobals();
|
||||
transCoderObj = globals.loadfile(luaFileName).call();
|
||||
localTransCoderObj.set(transCoderObj);
|
||||
return transCoderObj;
|
||||
}
|
||||
return transCoderObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
public enum FightType {
|
||||
StoryFight(1), //故事副本
|
||||
MapExploreFight(2), // 地图探索
|
||||
ArenaFight(3), //竞技场
|
||||
InvasionBossFight(4),//秘境boss
|
||||
AdventureLock(5), // 解锁秘境
|
||||
GuildFight(6), // 公会站
|
||||
BloodyFight(7), // 血战
|
||||
MonterFight(8), // 兽潮
|
||||
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
FightType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,9 +26,8 @@ import com.ljsd.jieling.logic.activity.event.Poster;
|
|||
import com.ljsd.jieling.logic.activity.event.StoryEvent;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.fight.*;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
|
|
@ -1229,24 +1228,13 @@ public class MapLogic {
|
|||
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();
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid, mapManager.getTeamId(), mostTime, "", FightType.MapExploreFight, groupId, 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
||||
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) {
|
||||
|
|
@ -1328,6 +1316,8 @@ public class MapLogic {
|
|||
mapManager.updateHeroOneAttribute(teamPosHeroInfo.getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[teamPosHeroInfo.getPosition()+1]);
|
||||
}
|
||||
}
|
||||
|
||||
int destoryXY = mapManager.getTriggerXY();
|
||||
if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4) {
|
||||
endlessRefreshMonster(session,destoryXY);
|
||||
}
|
||||
|
|
@ -1472,21 +1462,11 @@ public class MapLogic {
|
|||
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 builder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = builder.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);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, mostTime,frames, FightType.MapExploreFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
checkResult = fightResult.getCheckResult();
|
||||
resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
|
|
@ -1979,24 +1959,13 @@ public class MapLogic {
|
|||
public void endSuddlenlyFight(ISession session, String frames, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
String key = RedisKey.getKey(RedisKey.SUDDLENLY_FIGHT, Integer.toString(user.getId()), 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("此战斗已结算过 !"));
|
||||
}
|
||||
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
|
||||
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getFindSuddenlyBossMapId());
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sChallengeConfig.getMostTime(), getFightData, getOptionData,FightType.MapExploreFight);
|
||||
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sChallengeConfig.getMostTime(),frames, FightType.MapExploreFight);
|
||||
fightEvent.setExtraParm(RedisKey.SUDDLENLY_FIGHT);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
|
|
@ -2125,17 +2094,13 @@ public class MapLogic {
|
|||
LOGGER.info("endFight() uid=>{} not start fight", uid);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过 !"));
|
||||
}
|
||||
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
|
||||
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
|
||||
|
||||
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sMainLevelConfig.getRankTime(), getFightData, getOptionData,FightType.StoryFight);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sMainLevelConfig.getRankTime(),frames, FightType.StoryFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
int resultCode = fightResult.getCheckResult()[0];
|
||||
if (resultCode == -1) {
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
} else if (resultCode == 0) {
|
||||
|
|
@ -2332,32 +2297,16 @@ public class MapLogic {
|
|||
}
|
||||
String[] split = fightInfos.split("#");
|
||||
int checkFightId = Integer.parseInt(split[0]);
|
||||
|
||||
String key = RedisKey.getKey(RedisKey.CHALLENGE_MONSTER_ATTACK, Integer.toString(user.getId()), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
RedisUtil.getInstence().del(key,fightKey);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
LOGGER.info("endFight() uid=>{} not start fight", uid);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过!!"));
|
||||
}
|
||||
|
||||
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
|
||||
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
|
||||
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(checkFightId);
|
||||
if (sFloodConfig == null) {
|
||||
LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, checkFightId);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sFloodConfig.getBattleTime(), getFightData, getOptionData,FightType.MonterFight);
|
||||
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sFloodConfig.getBattleTime(),frames, FightType.MapExploreFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ public class BehaviorUtil {
|
|||
fightData.addAllMonsterList(monsterGroupList).addAllMonsterList(monsterGroupList1).addAllMonsterList(monsterGroupList2);
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
// int seed = 1553167956;
|
||||
fightData.setFightSeed(seed);
|
||||
fightData.setFightMaxTime(maxTime);
|
||||
fightData.setFightType(FightType.MapExploreFight.getType());
|
||||
|
|
|
|||
|
|
@ -59,18 +59,8 @@ public class StartFightRequestHandler extends BaseHandler<FightInfoProto.FightSt
|
|||
int type = fightStartRequest.getType();
|
||||
int fightId = fightStartRequest.getFightId();
|
||||
int teamId = fightStartRequest.getTeamId();
|
||||
|
||||
|
||||
if (type ==1){
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int curMapId = user.getMapManager().getCurMapId();
|
||||
if(curMapId>0){
|
||||
throw new ErrorCodeException(ErrorCode.MAP_IN);
|
||||
}
|
||||
// MapLogic.getInstance().startLevelDifficultyFight(iSession,fightId,teamId,type, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
}else if(type == 2){
|
||||
if(type == 2){
|
||||
MapLogic.getInstance().startFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
|
||||
}else if(type == 3){
|
||||
MapLogic.getInstance().startSuddlenlyFight(iSession,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
}else if(type == 5){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ljsd.jieling.handler.monsterAttack;
|
||||
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.core.TransTask;
|
||||
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;
|
||||
|
|
@ -15,7 +18,10 @@ 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.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.fight.PVEFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
|
@ -25,6 +31,7 @@ import com.ljsd.jieling.util.FightDataUtil;
|
|||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.MonsterUtil;
|
||||
import config.SChallengeConfig;
|
||||
import config.SFloodConfig;
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
|
@ -80,42 +87,25 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
LOGGER.info("startLevelDifficultyFight==> uid={},fightId={},teamId={}", uid, fightId, teamId);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误"));
|
||||
}
|
||||
|
||||
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType, KTGameType.CHALLENGE_MONSTERATTACK.getIndex(), fightId);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.MONSTER_ATTACK_PLAY);
|
||||
|
||||
|
||||
int groupId = sFloodConfig.getMonster();
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user, teamId, 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("");
|
||||
int mostTime = sFloodConfig.getBattleTime();
|
||||
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, FightType.MonterFight);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid,teamId, mostTime, "", FightType.MonterFight, groupId, 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode == -1) {
|
||||
ItemUtil.itemCost(user,cost, BIReason.MONSTERATTACK_CONSUME, fightId);
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
|
||||
CommonProto.FightData fightDataBuild = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(mostTime)
|
||||
.setFightSeed(seed)
|
||||
.setHeroFightInfos(fightTeamInfo)
|
||||
.addAllMonsterList(monsterTeamList)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.build();
|
||||
|
||||
if (resultCode == 0) {
|
||||
|
|
@ -124,7 +114,6 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||
.setResult(resultCode)
|
||||
.setEnventDrop(dropBuilder)
|
||||
.setFightData(fightDataBuild)
|
||||
.build();
|
||||
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, builder, true);
|
||||
return;
|
||||
|
|
@ -138,7 +127,7 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||
.setResult(resultCode)
|
||||
.setEnventDrop(drop)
|
||||
.setFightData(fightDataBuild)
|
||||
// .setFightData(fightDataBuild)
|
||||
.build();
|
||||
|
||||
user.getMapManager().setLastMonsterAttack(fightId + 1);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class LuckyCatActivity extends AbstractActivity {
|
|||
|
||||
ActivityProgressInfo activityProgressInfo = activityMission.getActivityProgressInfoMap().get(missionId);
|
||||
if (activityProgressInfo == null || activityProgressInfo.getState() == ActivityType.HAD_TAKED) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("had taked"));
|
||||
throw/**/ new ErrorCodeException(ErrorCode.newDefineCode("had taked"));
|
||||
}
|
||||
|
||||
//check cfg
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@ import com.ljsd.jieling.logic.activity.event.Poster;
|
|||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.fight.PVPFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
|
|
@ -180,7 +183,7 @@ public class ArenaLogic {
|
|||
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
|
||||
ArenaRecord arenaRecord = new ArenaRecord();
|
||||
defUser = UserManager.getUser(challengeUid);
|
||||
fightResult = getFightResultByPersonToPerson(user, teamId, defUser, GlobalsDef.TEAM_ARENA_DEFENSE,arenaRecord,skipFight,builder);
|
||||
fightResult = getFightResultByPersonToPerson(user, teamId, defUser, GlobalsDef.TEAM_ARENA_DEFENSE,arenaRecord,builder);
|
||||
if(fightResult == -1){
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
|
|
@ -202,8 +205,7 @@ public class ArenaLogic {
|
|||
MessageUtil.sendRedIndication(challengeUid,GlobalsDef.ARENA_CHALLENGE_TYPE);
|
||||
}
|
||||
}else{
|
||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(challengeUid);
|
||||
fightResult = getFightResultByPersonToRobot(user, teamId,sArenaRobotConfig,skipFight,builder);
|
||||
fightResult = getFightResultByPersonToRobot(user, teamId,challengeUid,builder);
|
||||
if(fightResult == -1){
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
|
|
@ -268,12 +270,13 @@ public class ArenaLogic {
|
|||
|
||||
|
||||
|
||||
public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, int skipFight, ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,true);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,defTeamId,false);
|
||||
public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", FightType.ArenaFight,defUser.getId(),defTeamId);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
CommonProto.FightTeamInfo fightTeamInfo =fightResult.getFightTeamInfo();
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = fightResult.getDefFightTeamInfo();
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
|
||||
int seed = fightResult.getSeed();
|
||||
CommonProto.FightData build = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
|
||||
.setFightSeed(seed)
|
||||
|
|
@ -289,29 +292,25 @@ public class ArenaLogic {
|
|||
.addMonsterList(fightTeamInfo)
|
||||
.build().toByteArray();
|
||||
arenaRecord.setFightData(snapRecord);
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData, FightType.ArenaFight);
|
||||
return checkResult[0];
|
||||
return fightResult.getCheckResult()[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getFightResultByPersonToRobot(User mine, int myteamId, SArenaRobotConfig sArenaRobotConfig, int skipFight, ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,true);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getRobotFightTeamInfo(sArenaRobotConfig);
|
||||
public int getFightResultByPersonToRobot(User mine, int myteamId, int challengeUid,ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", FightType.ArenaFight,challengeUid,-1);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
CommonProto.FightTeamInfo fightTeamInfo =fightResult.getFightTeamInfo();
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = fightResult.getDefFightTeamInfo();
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
int seed = fightResult.getSeed();
|
||||
builder.setFightData(CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
|
||||
.setFightSeed(seed)
|
||||
.setHeroFightInfos(fightTeamInfo)
|
||||
.addMonsterList(deffightTeamInfo)
|
||||
.build());
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData,FightType.ArenaFight);
|
||||
return checkResult[0];
|
||||
return fightResult.getCheckResult()[0];
|
||||
}
|
||||
|
||||
private String checkChallenge(User user,int skipFight, ArenaEnemy enemyInfo) throws Exception {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
|
||||
public class FightDispatcher {
|
||||
|
||||
|
||||
public static FightResult dispatcher(FightEvent fightEvent){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
public class FightEvent {
|
||||
private int attackUid;
|
||||
private int teamId;
|
||||
private int mostTime;
|
||||
private String frames;
|
||||
private FightType fightType;
|
||||
private String extraParm;
|
||||
|
||||
public FightEvent(int attackUid, int teamId,int mostTime,String frams, FightType fightType) {
|
||||
this.attackUid = attackUid;
|
||||
this.teamId = teamId;
|
||||
this.fightType = fightType;
|
||||
this.mostTime = mostTime;
|
||||
this.frames = frams;
|
||||
}
|
||||
|
||||
public String getExtraParm() {
|
||||
return extraParm;
|
||||
}
|
||||
|
||||
public void setExtraParm(String extraParm) {
|
||||
this.extraParm = extraParm;
|
||||
}
|
||||
|
||||
public int getAttackUid() {
|
||||
return attackUid;
|
||||
}
|
||||
|
||||
public int getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public FightType getFightType() {
|
||||
return fightType;
|
||||
}
|
||||
|
||||
public int getMostTime() {
|
||||
return mostTime;
|
||||
}
|
||||
|
||||
public String getFrames() {
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ public enum FightType {
|
|||
}
|
||||
|
||||
FightType(int type) {
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
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.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.util.FightDataUtil;
|
||||
import com.ljsd.jieling.util.MonsterUtil;
|
||||
import config.SArenaRobotConfig;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FightUtil {
|
||||
|
||||
public static Map<FightType,String> redisTypeOfFightType = new HashMap<>();
|
||||
static {
|
||||
redisTypeOfFightType.put(FightType.StoryFight,RedisKey.LEVE_DIFFICULTY_FIGHT);
|
||||
}
|
||||
|
||||
public static CommonProto.FightTeamInfo makePersonFightData(User player,int teamId){
|
||||
return BehaviorUtil.getFightTeamInfo(player,teamId,true);
|
||||
}
|
||||
|
||||
public static Map<Integer, List<CommonProto.FightUnitInfo>> makeMonsterGroup(int bossGroupId,Map<Integer,List<Integer>> hps){
|
||||
return MonsterUtil.getMonsterByGroup(bossGroupId,hps);
|
||||
}
|
||||
|
||||
public static Map<Integer, List<CommonProto.FightUnitInfo>> makeMonsterGroup(int bossGroupId){
|
||||
return MonsterUtil.getMonsterByGroup(bossGroupId);
|
||||
}
|
||||
|
||||
public static int getFightSeed(){
|
||||
return (int)(System.currentTimeMillis()/1000);
|
||||
}
|
||||
|
||||
//防守方是怪物
|
||||
public static List<CommonProto.FightTeamInfo> makeMonsterFightData(int bossGroupId,int nums){
|
||||
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = makeMonsterGroup(bossGroupId);
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = new ArrayList<>(nums);
|
||||
for(int i=0;i<nums;i++){
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(bossGroupId, monsterByGroup, i);
|
||||
monsterTeamList.addAll(monsterGroupList);
|
||||
}
|
||||
return monsterTeamList;
|
||||
}
|
||||
//防守方是机器人(目前是竞技场适用)
|
||||
public static CommonProto.FightTeamInfo makeRobotFightData(int robotId){
|
||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
|
||||
return BehaviorUtil.getRobotFightTeamInfo(sArenaRobotConfig);
|
||||
}
|
||||
|
||||
public static FightResult getFightForPVE(FightEvent fightEvent){
|
||||
PVEFightEvent pveFightEvent = (PVEFightEvent)fightEvent;
|
||||
User userInMem = UserManager.getUserInMem(pveFightEvent.getAttackUid());
|
||||
CommonProto.FightTeamInfo fightTeamInfo = makePersonFightData(userInMem, pveFightEvent.getTeamId());
|
||||
int fightSeed =getFightSeed();
|
||||
List<CommonProto.FightTeamInfo> monsterfightTeamInfos = makeMonsterFightData(pveFightEvent.getMonsterGroupId(), pveFightEvent.getNums());
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterfightTeamInfos);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(fightEvent.getFrames());
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(fightSeed, fightEvent.getMostTime(), getFightData, getOptionData, fightEvent.getFightType());
|
||||
|
||||
FightResult.Builder builder = FightResult.newBuilder();
|
||||
builder.setCheckResult(fightResult);
|
||||
builder.setSeed(fightSeed);
|
||||
builder.setFightTeamInfo(fightTeamInfo);
|
||||
builder.setMonsterTeamList(monsterfightTeamInfos);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void mergeFightData(){
|
||||
/* LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);*/
|
||||
}
|
||||
|
||||
|
||||
public static int[] getFightFromRedis(FightEvent fightEvent) throws Exception {
|
||||
FightType fightType = fightEvent.getFightType();
|
||||
int playerId = fightEvent.getAttackUid();
|
||||
String frames = fightEvent.getFrames();
|
||||
int fightTime = fightEvent.getMostTime();
|
||||
String extraParm = fightEvent.getExtraParm();
|
||||
String fightTypeOfRedis = FightUtil.redisTypeOfFightType.get(fightType);
|
||||
if(!StringUtil.isEmpty(extraParm)){
|
||||
fightTypeOfRedis = extraParm;
|
||||
}
|
||||
String key = RedisKey.getKey(fightTypeOfRedis, Integer.toString(playerId), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().
|
||||
hmget(key);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过 !"));
|
||||
}
|
||||
RedisUtil.getInstence().del(key);
|
||||
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
|
||||
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
|
||||
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
return CheckFight.getInstance().checkFight(seed,fightTime, getFightData, getOptionData,fightType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
public class PVEFightEvent extends FightEvent{
|
||||
private int monsterGroupId;
|
||||
private int nums;
|
||||
|
||||
public PVEFightEvent(int attackUid, int teamId, int mostTime,String frams, FightType fightType, int monsterGroupId, int nums) {
|
||||
super(attackUid, teamId, mostTime,frams, fightType);
|
||||
this.monsterGroupId = monsterGroupId;
|
||||
this.nums = nums;
|
||||
}
|
||||
|
||||
public int getMonsterGroupId() {
|
||||
return monsterGroupId;
|
||||
}
|
||||
|
||||
public int getNums() {
|
||||
return nums;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
public class PVPFightEvent extends FightEvent {
|
||||
private int defUid;
|
||||
private int defTeamId;
|
||||
|
||||
|
||||
public PVPFightEvent(int attackUid, int teamId, int mostTime, String frams, FightType fightType, int defUid, int defTeamId) {
|
||||
super(attackUid, teamId, mostTime, frams, fightType);
|
||||
this.defUid = defUid;
|
||||
this.defTeamId = defTeamId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.ljsd.jieling.logic.fight.eventhandler;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.FightEvent;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
|
||||
public class DefaultOfRedisCacheFightHandler implements IFightEventProcesor {
|
||||
|
||||
@Override
|
||||
public FightResult process(FightEvent fightEvent) throws Exception {
|
||||
int[] fightResult = FightUtil.getFightFromRedis(fightEvent);
|
||||
return FightResult.newBuilder().setCheckResult(fightResult).build();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ljsd.jieling.logic.fight.eventhandler;
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.fight.FightEvent;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
public class DefaultWithoutHandFightHandler implements IFightEventProcesor {
|
||||
@Override
|
||||
public FightResult process(FightEvent fightEvent) throws Exception {
|
||||
return FightUtil.getFightForPVE(fightEvent);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ljsd.jieling.logic.fight.eventhandler;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.FightEvent;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
public interface IFightEventProcesor {
|
||||
|
||||
FightResult process(FightEvent fightEvent) throws Exception;
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.ljsd.jieling.logic.fight.result;
|
||||
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FightResult {
|
||||
private int[] checkResult;
|
||||
private int seed;
|
||||
private CommonProto.FightTeamInfo fightTeamInfo;
|
||||
private CommonProto.FightTeamInfo defFightTeamInfo;
|
||||
private CommonProto.FightData fightData;
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList;
|
||||
|
||||
private FightResult(){
|
||||
|
||||
}
|
||||
|
||||
public static Builder newBuilder(){
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final class Builder{
|
||||
private int[] checkResult;
|
||||
private int seed;
|
||||
private CommonProto.FightTeamInfo fightTeamInfo;
|
||||
private CommonProto.FightTeamInfo defFightTeamInfo;
|
||||
List<CommonProto.FightTeamInfo> monsterTeamList;
|
||||
|
||||
private CommonProto.FightData fightData;
|
||||
|
||||
private Builder(){
|
||||
}
|
||||
|
||||
public Builder setCheckResult(int[] checkResult) {
|
||||
this.checkResult = checkResult;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFightData(CommonProto.FightData fightData) {
|
||||
this.fightData = fightData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSeed(int seed) {
|
||||
this.seed = seed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFightTeamInfo(CommonProto.FightTeamInfo fightTeamInfo) {
|
||||
this.fightTeamInfo = fightTeamInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMonsterTeamList(List<CommonProto.FightTeamInfo> monsterTeamList) {
|
||||
this.monsterTeamList = monsterTeamList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setDefFightTeamInfo(CommonProto.FightTeamInfo defFightTeamInfo) {
|
||||
this.defFightTeamInfo = defFightTeamInfo;
|
||||
}
|
||||
|
||||
public FightResult build(){
|
||||
FightResult fightResult = new FightResult();
|
||||
fightResult.setCheckResult(this.checkResult);
|
||||
fightResult.setSeed(seed);
|
||||
fightResult.setMonsterTeamList(monsterTeamList);
|
||||
fightResult.setFightTeamInfo(fightTeamInfo);
|
||||
fightResult.setDefFightTeamInfo(defFightTeamInfo);
|
||||
fightResult.setFightData(fightData);
|
||||
return fightResult;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCheckResult(int[] checkResult) {
|
||||
this.checkResult = checkResult;
|
||||
}
|
||||
|
||||
public void setFightData(CommonProto.FightData fightData) {
|
||||
this.fightData = fightData;
|
||||
}
|
||||
|
||||
public int[] getCheckResult() {
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
public CommonProto.FightData getFightData() {
|
||||
return fightData;
|
||||
}
|
||||
|
||||
|
||||
public int getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public void setSeed(int seed) {
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public CommonProto.FightTeamInfo getFightTeamInfo() {
|
||||
return fightTeamInfo;
|
||||
}
|
||||
|
||||
public void setFightTeamInfo(CommonProto.FightTeamInfo fightTeamInfo) {
|
||||
this.fightTeamInfo = fightTeamInfo;
|
||||
}
|
||||
|
||||
public List<CommonProto.FightTeamInfo> getMonsterTeamList() {
|
||||
return monsterTeamList;
|
||||
}
|
||||
|
||||
public void setMonsterTeamList(List<CommonProto.FightTeamInfo> monsterTeamList) {
|
||||
this.monsterTeamList = monsterTeamList;
|
||||
}
|
||||
|
||||
public CommonProto.FightTeamInfo getDefFightTeamInfo() {
|
||||
return defFightTeamInfo;
|
||||
}
|
||||
|
||||
public void setDefFightTeamInfo(CommonProto.FightTeamInfo defFightTeamInfo) {
|
||||
this.defFightTeamInfo = defFightTeamInfo;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue