战斗服校验逻辑优化

master_dev
grimm 2024-05-06 16:15:12 +08:00
parent b1406255ed
commit 2162847376
1 changed files with 61 additions and 45 deletions

View File

@ -88,68 +88,84 @@ public class CheckFight {
* 线50ms100线
* @return {, /1,2,3,4,5}
*/
public long[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
/**
*
* @param seed
* @param maxTime
* @param fightData
* @param optionData
* @param fightType
* @return
*/
public long[] 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("type",fightType.getType());
args.set("maxRound",maxTime);
LuaValue result = func.call(args,fightData,optionData);
long[] resultCache = new long[9];//对方阵容走配置 Todo 后面结构走配置
resultCache[0]= result.get("result").tolong();
resultCache[1]= result.get("duration").tolong();
LOGGER.info(" lua check test fight result : {} {}", resultCache[0] , result.length());
for (int i = 1; i <= result.length(); i++) {
long talon = result.rawget(i).tolong();
if (talon > 0) {
resultCache[i + 1] = talon;
} else {
resultCache[i + 1] = talon;
}
resultCache[i + 1] = result.rawget(i).tolong();
LOGGER.info(i + " --> 单位剩余血量 : " + resultCache[i + 1]);
LuaValue result = callLuaValue(seed, maxTime, fightData, optionData, fightType, transCoderObj);
long[] resultCache = new long[9]; // 假定最多有8个单位的剩余血量信息
resultCache[0] = result.get("result").tolong();
resultCache[1] = result.get("duration").tolong();
LOGGER.info("Lua check test fight result: {} Length: {}", resultCache[0], result.length());
for (int i = 1; i <= result.length() && i < 8; i++) {
long remainingHealth = result.rawget(i).tolong();
resultCache[i + 1] = remainingHealth;
LOGGER.info("{} --> 单位剩余血量: {}", i, remainingHealth);
}
resultCache[8]= result.get("curRound").tolong();
resultCache[8] = result.get("curRound").tolong();
return resultCache;
}
public long[][] checkHardStageFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
public long[][] checkHardStageFight(int seed, int maxTime, LuaValue fightData, LuaValue optionData, FightType fightType) {
LuaValue transCoderObj = this.getTransCoderObj();
long[][] resultX = new long[2][];
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
LuaValue args = new LuaTable();
args.set("seed",seed);
args.set("type",fightType.getType());
args.set("maxRound",maxTime);
LuaValue result = func.call( args,fightData,optionData);
int status = result.get("result").toint();
int duration = result.get("duration").toint();
LuaValue result = callLuaValue(seed, maxTime, fightData, optionData, fightType, transCoderObj);
int status = 0;
int duration = 0;
LuaValue resultVal = result.get("result");
if (!resultVal.isnil()) status = resultVal.toint();
resultVal = result.get("duration");
if (!resultVal.isnil()) duration = resultVal.toint();
long[] starRecord = new long[6];
for(int x = 1; x <= result.get("starRecord").length() ; x++){
long s = result.get("starRecord").rawget(x).tolong();
starRecord[x-1] = s;
LuaValue starRecordVal = result.get("starRecord");
if (!starRecordVal.isnil()) {
for (int x = 1; x <= starRecordVal.length() && x <= starRecord.length; x++) {
LuaValue val = starRecordVal.rawget(x);
if (!val.isnil()) {
starRecord[x - 1] = val.tolong();
}
}
}
long[] resultCache = new long[8];//对方阵容走配置 Todo 后面结构走配置
resultCache[0]= status;
resultCache[1]= duration;
LOGGER.info(" lua check test fight result : {} {}", resultCache[0] , result.length());
for (int i = 1; i <= result.length(); i++) {
long tolong = result.rawget(i).tolong();
if(tolong>0){
resultCache[i+1]= Math.min(Integer.MAX_VALUE,tolong);
}else {
resultCache[i+1]= Math.max(Integer.MIN_VALUE,tolong);
long[] resultCache = new long[8];
resultCache[0] = status;
resultCache[1] = duration;
for (int i = 2; i < resultCache.length && i <= result.length(); i++) {
LuaValue val = result.rawget(i);
if (!val.isnil()) {
resultCache[i] = val.toint();
}
resultCache[i+1] = result.rawget(i).toint();
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
LOGGER.info("{} --> 单位剩余血量 : {}", i, resultCache[i]);
}
resultX[0] = resultCache;
resultX[1] = starRecord;
return resultX;
}
public LuaValue callLuaValue(int seed, int maxTime, LuaValue fightData, LuaValue optionData, FightType fightType, LuaValue transCoderObj) {
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
LuaValue args = new LuaTable();
args.set("seed", seed);
args.set("type", fightType.getType());
args.set("maxRound", maxTime);
return func.call(args, fightData, optionData);
}
public LuaValue getTransCoderObj(){
LuaValue transCoderObj = localTransCoderObj.get();
if(transCoderObj == null||localVersion.get()!=hotFixVersion.get()){