parent
1e11b909fc
commit
a0de4fd484
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Reference in New Issue