小兵功能三版,挂机奖励逻辑完善

master_dev
grimm 2024-03-14 17:14:46 +08:00
parent b39e7b37df
commit 9068f1484a
3 changed files with 14 additions and 23 deletions

View File

@ -86,10 +86,6 @@ public class CheckFight {
/** /**
* 线50ms100线 * 线50ms100线
* http://www.luaj.org/luaj/3.0/examples/jse/SampleMultiThreaded.java
* @param seed
* @param fightData
* @param optionData
* @return {, /1,2,3,4,5} * @return {, /1,2,3,4,5}
*/ */
public long[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){ 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++) { for (int i = 1; i <= result.length(); i++) {
long talon = result.rawget(i).tolong(); long talon = result.rawget(i).tolong();
if (talon > 0) { if (talon > 0) {
resultCache[i + 1] = Math.min(Long.MAX_VALUE, talon); resultCache[i + 1] = talon;
} else { } else {
resultCache[i + 1] = Math.max(Long.MIN_VALUE, talon); resultCache[i + 1] = talon;
} }
resultCache[i + 1] = result.rawget(i).tolong(); resultCache[i + 1] = result.rawget(i).tolong();
LOGGER.info(i + " --> 单位剩余血量 : " + resultCache[i + 1]); LOGGER.info(i + " --> 单位剩余血量 : " + resultCache[i + 1]);
@ -138,17 +134,17 @@ public class CheckFight {
} }
long[] resultCache = new long[8];//对方阵容走配置 Todo 后面结构走配置 long[] resultCache = new long[8];//对方阵容走配置 Todo 后面结构走配置
resultCache[0]= (long) status; resultCache[0]= status;
resultCache[1]= (long) duration; resultCache[1]= duration;
LOGGER.info(" lua check test fight result : {} {}", resultCache[0] , result.length()); LOGGER.info(" lua check test fight result : {} {}", resultCache[0] , result.length());
for (int i = 1; i <= result.length(); i++) { for (int i = 1; i <= result.length(); i++) {
long tolong = result.rawget(i).tolong(); long tolong = result.rawget(i).tolong();
if(tolong>0){ if(tolong>0){
resultCache[i+1]= Math.min((long) Integer.MAX_VALUE,tolong); resultCache[i+1]= Math.min(Integer.MAX_VALUE,tolong);
}else { }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]); LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
} }
resultX[0] = resultCache; resultX[0] = resultCache;
@ -174,12 +170,4 @@ public class CheckFight {
return transCoderObj; return transCoderObj;
} }
} }

View File

@ -1015,7 +1015,7 @@ public class CombatLogic {
// 分关卡阶段记录 // 分关卡阶段记录
Map<Integer, Integer> soldierStateInfo = mainLevelManager.getSoldierStateInfo(); 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; int count = 0;
for (Map.Entry<Integer, Integer> entry : calculated.entrySet()) { for (Map.Entry<Integer, Integer> entry : calculated.entrySet()) {
@ -1052,7 +1052,7 @@ public class CombatLogic {
* @param startTime * @param startTime
* @return map * @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确保按键排序
TreeMap<Integer, Integer> sortedMap = new TreeMap<>(timestamps); TreeMap<Integer, Integer> sortedMap = new TreeMap<>(timestamps);
// 用于存储差值结果的Map // 用于存储差值结果的Map
@ -1068,6 +1068,8 @@ public class CombatLogic {
// 更新上一个时间戳的值为当前值,用于下一次比较 // 更新上一个时间戳的值为当前值,用于下一次比较
previousTimestamp = entry.getValue(); previousTimestamp = entry.getValue();
} }
// 最近得一次记录
differences.put(layerId, TimeUtils.nowInt() - previousTimestamp);
return differences; return differences;
} }
} }

View File

@ -138,7 +138,8 @@ public class SoldierLogic {
int type = soldierType[typeIndex]; int type = soldierType[typeIndex];
// 等级 // 等级
int userLevel = user.getPlayerInfoManager().getLevel(); 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 min = Math.max(1, userLevel - settingLevel[0]);
int max = Math.min(200, userLevel + settingLevel[1]); int max = Math.min(200, userLevel + settingLevel[1]);
int level = random.nextInt(max - min) + min; int level = random.nextInt(max - min) + min;
@ -279,7 +280,7 @@ public class SoldierLogic {
if (attackTime * round < stageConfig.getTime()){ if (attackTime * round < stageConfig.getTime()){
throw new ErrorTableException(161);//战斗失败 throw new ErrorTableException(161);//战斗失败
} }
// 更新关卡id // 更新关卡id和挂机时间
mainLevelManager.setSoldierLayerId(stageConfig.getNextId()); mainLevelManager.setSoldierLayerId(stageConfig.getNextId());
mainLevelManager.putSoldierState(stageConfig.getId(), TimeUtils.nowInt()); mainLevelManager.putSoldierState(stageConfig.getId(), TimeUtils.nowInt());
// 通关奖励 // 通关奖励