【家园功能1.1.14】

1、处理装备强化逻辑bug2
back_recharge
duhui 2022-01-05 15:03:28 +08:00
parent 1e11b909fc
commit a0de4fd484
1 changed files with 31 additions and 25 deletions

View File

@ -14,6 +14,7 @@ import com.ljsd.jieling.logic.home.event.HomeEvent;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.tools.Utils;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
@ -87,35 +88,40 @@ public class HomeLogic {
}
// 1普通升级 2立即完成 3:取消升级 4:特权加速
int type = proto.getType();
if (type == 1 || type == 2){
// 消耗道具
if (info.getUpLvEndTime() == 0){
boolean ifType = false;
boolean cost = ItemUtil.checkCostLong(user, landLevel.getCost(), 1);
if (type == 1 && info.getUpLvEndTime() == 0){
boolean cost = ItemUtil.itemCost(user, landLevel.getCost(), BIReason.ARCHITECTURE_UP_LEVEL, 0);
if (!cost) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级,建筑升级要求道具不足建筑levelId"+info.getId());
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑普通升级建筑levelId"+info.getId()+",道具:"+Arrays.toString(landLevel.getCost()));
}
ifType = true;
info.setUpLvEndTime(now + landLevel.getTime());
}
// 立即升级消耗妖晶
if (type == 2){
ArrayList<int[]> costList = new ArrayList<>();
// 验证消耗道具是否满足
if (info.getUpLvEndTime() == 0){
info.setUpLvEndTime(now + landLevel.getTime());
costList.addAll(Arrays.asList(landLevel.getCost()));
}
// 条件: 单位/s 道具id 道具数量
int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE);
// 立即升级消耗的道具
int time = Math.max(info.getUpLvEndTime() - now, 0);
if (time > 0){
double time = info.getUpLvEndTime() - now;
// 每一个单位的消耗
int oneCost = intValues[0] * intValues[2];
// 总消耗数量,向上取整
int count = (int) Math.ceil((double) time/oneCost);
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{intValues[1], count}}, BIReason.ARCHITECTURE_IMMEDIATELY_UP_LEVEL, 0);
if (!itemCost) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级立刻升级失败道具不足建筑levelId"+info.getId());
int count = (int) Math.ceil(time / oneCost);
if (count <= 0){
LOGGER.error("浮生门建筑立即升级消耗道具数量小于0请检查配置表数据");
count = 0;
}
costList.add(new int[]{intValues[1], count});
// 类型转换
int[][] arrayObject = Utils.getTwoArrayObject(costList);
boolean itemCost = ItemUtil.itemCost(user, arrayObject, BIReason.ARCHITECTURE_UP_LEVEL, 0);
if (!itemCost){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑立即升级建筑levelId"+info.getId()+",道具:"+Arrays.toString(arrayObject));
}
}
ItemUtil.itemCost(user, landLevel.getCost(), BIReason.ARCHITECTURE_UP_LEVEL, 0);
// 升级
architectureUpLvEnd(user, landLevel.getPoolID(), info);
}
if (type == 3){