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.mission.GameEvent;
|
||||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.tools.Utils;
|
||||||
import com.ljsd.jieling.util.CBean2Proto;
|
import com.ljsd.jieling.util.CBean2Proto;
|
||||||
import com.ljsd.jieling.util.ItemUtil;
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
|
@ -87,35 +88,40 @@ public class HomeLogic {
|
||||||
}
|
}
|
||||||
// 1:普通升级, 2:立即完成 3:取消升级 4:特权加速
|
// 1:普通升级, 2:立即完成 3:取消升级 4:特权加速
|
||||||
int type = proto.getType();
|
int type = proto.getType();
|
||||||
if (type == 1 || type == 2){
|
if (type == 1 && info.getUpLvEndTime() == 0){
|
||||||
// 消耗道具
|
boolean cost = ItemUtil.itemCost(user, landLevel.getCost(), BIReason.ARCHITECTURE_UP_LEVEL, 0);
|
||||||
if (info.getUpLvEndTime() == 0){
|
|
||||||
boolean ifType = false;
|
|
||||||
boolean cost = ItemUtil.checkCostLong(user, landLevel.getCost(), 1);
|
|
||||||
if (!cost) {
|
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());
|
info.setUpLvEndTime(now + landLevel.getTime());
|
||||||
}
|
}
|
||||||
// 立即升级消耗妖晶
|
|
||||||
if (type == 2){
|
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 道具数量
|
// 条件: 单位/s 道具id 道具数量
|
||||||
int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE);
|
int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE);
|
||||||
// 立即升级消耗的道具
|
// 立即升级消耗的道具
|
||||||
int time = Math.max(info.getUpLvEndTime() - now, 0);
|
double time = info.getUpLvEndTime() - now;
|
||||||
if (time > 0){
|
|
||||||
// 每一个单位的消耗
|
// 每一个单位的消耗
|
||||||
int oneCost = intValues[0] * intValues[2];
|
int oneCost = intValues[0] * intValues[2];
|
||||||
// 总消耗数量,向上取整
|
// 总消耗数量,向上取整
|
||||||
int count = (int) Math.ceil((double) time/oneCost);
|
int count = (int) Math.ceil(time / oneCost);
|
||||||
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{intValues[1], count}}, BIReason.ARCHITECTURE_IMMEDIATELY_UP_LEVEL, 0);
|
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){
|
if (!itemCost){
|
||||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级,立刻升级失败道具不足,建筑levelId:"+info.getId());
|
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);
|
architectureUpLvEnd(user, landLevel.getPoolID(), info);
|
||||||
}
|
}
|
||||||
if (type == 3){
|
if (type == 3){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue