小兵功能三版,挂机奖励逻辑完善
parent
b39e7b37df
commit
9068f1484a
|
|
@ -86,10 +86,6 @@ public class CheckFight {
|
|||
|
||||
/**
|
||||
* 单线程执行每次用时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 long[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
|
||||
|
|
@ -108,9 +104,9 @@ public class CheckFight {
|
|||
for (int i = 1; i <= result.length(); i++) {
|
||||
long talon = result.rawget(i).tolong();
|
||||
if (talon > 0) {
|
||||
resultCache[i + 1] = Math.min(Long.MAX_VALUE, talon);
|
||||
resultCache[i + 1] = talon;
|
||||
} else {
|
||||
resultCache[i + 1] = Math.max(Long.MIN_VALUE, talon);
|
||||
resultCache[i + 1] = talon;
|
||||
}
|
||||
resultCache[i + 1] = result.rawget(i).tolong();
|
||||
LOGGER.info(i + " --> 单位剩余血量 : " + resultCache[i + 1]);
|
||||
|
|
@ -138,17 +134,17 @@ public class CheckFight {
|
|||
}
|
||||
|
||||
long[] resultCache = new long[8];//对方阵容走配置 Todo 后面结构走配置
|
||||
resultCache[0]= (long) status;
|
||||
resultCache[1]= (long) duration;
|
||||
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((long) Integer.MAX_VALUE,tolong);
|
||||
resultCache[i+1]= Math.min(Integer.MAX_VALUE,tolong);
|
||||
}else {
|
||||
resultCache[i+1]= Math.max((long) Integer.MIN_VALUE,tolong);
|
||||
resultCache[i+1]= Math.max(Integer.MIN_VALUE,tolong);
|
||||
}
|
||||
resultCache[i+1] = (long) result.rawget(i).toint();
|
||||
resultCache[i+1] = result.rawget(i).toint();
|
||||
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
||||
}
|
||||
resultX[0] = resultCache;
|
||||
|
|
@ -174,12 +170,4 @@ public class CheckFight {
|
|||
return transCoderObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1015,7 +1015,7 @@ public class CombatLogic {
|
|||
// 分关卡阶段记录
|
||||
Map<Integer, Integer> soldierStateInfo = mainLevelManager.getSoldierStateInfo();
|
||||
// 获取每个阶段得挂机时间
|
||||
Map<Integer, Integer> calculated = calculateDifferences(soldierStateInfo, mainLevelManager.getSoldierRestartTime());
|
||||
Map<Integer, Integer> calculated = calculateDifferences(soldierStateInfo, mainLevelManager.getSoldierLayerId(), mainLevelManager.getSoldierRestartTime());
|
||||
// 计数器
|
||||
int count = 0;
|
||||
for (Map.Entry<Integer, Integer> entry : calculated.entrySet()) {
|
||||
|
|
@ -1052,7 +1052,7 @@ public class CombatLogic {
|
|||
* @param startTime 初始时间
|
||||
* @return map
|
||||
*/
|
||||
public static Map<Integer, Integer> calculateDifferences(Map<Integer, Integer> timestamps, int startTime) {
|
||||
public static Map<Integer, Integer> calculateDifferences(Map<Integer, Integer> timestamps, int layerId, int startTime) {
|
||||
// 使用TreeMap确保按键排序
|
||||
TreeMap<Integer, Integer> sortedMap = new TreeMap<>(timestamps);
|
||||
// 用于存储差值结果的Map
|
||||
|
|
@ -1068,6 +1068,8 @@ public class CombatLogic {
|
|||
// 更新上一个时间戳的值为当前值,用于下一次比较
|
||||
previousTimestamp = entry.getValue();
|
||||
}
|
||||
// 最近得一次记录
|
||||
differences.put(layerId, TimeUtils.nowInt() - previousTimestamp);
|
||||
return differences;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@ public class SoldierLogic {
|
|||
int type = soldierType[typeIndex];
|
||||
// 等级
|
||||
int userLevel = user.getPlayerInfoManager().getLevel();
|
||||
int[] settingLevel = SSpecialConfig.getIntegerArrayValue("Soldiers_Level_interval");// 4#2 -4到+2之间
|
||||
// 4#2 -4到+2之间
|
||||
int[] settingLevel = SSpecialConfig.getIntegerArrayValue("Soldiers_Level_interval");
|
||||
int min = Math.max(1, userLevel - settingLevel[0]);
|
||||
int max = Math.min(200, userLevel + settingLevel[1]);
|
||||
int level = random.nextInt(max - min) + min;
|
||||
|
|
@ -279,7 +280,7 @@ public class SoldierLogic {
|
|||
if (attackTime * round < stageConfig.getTime()){
|
||||
throw new ErrorTableException(161);//战斗失败
|
||||
}
|
||||
// 更新关卡id
|
||||
// 更新关卡id和挂机时间
|
||||
mainLevelManager.setSoldierLayerId(stageConfig.getNextId());
|
||||
mainLevelManager.putSoldierState(stageConfig.getId(), TimeUtils.nowInt());
|
||||
// 通关奖励
|
||||
|
|
|
|||
Loading…
Reference in New Issue