【家园功能1.1.5】

1、家园特权功能添加
back_recharge
duhui 2021-12-30 16:09:24 +08:00
parent a61999d664
commit 9e433e1969
4 changed files with 52 additions and 25 deletions

View File

@ -52,4 +52,7 @@ public interface VipPrivilegeType {
int NEW_GENERAL_ATTACK_NUM = 3005;
int HOME_DAY_TIME_NUM = 4021;//每日浮生特权秒时间次数%
int HOME_ADD_EARNINGS = 4022;//浮生特权增加浮生门产出建筑产量
}

View File

@ -2783,7 +2783,8 @@ public class HeroLogic {
for (int[] prop : property) {
int buff = 0;
// 家园装备强化属性
buff += Optional.ofNullable(strengthenMap.get(intensifyMap.get(sEquipConfig.getPosition()))).map(SEquipStrengthen::getRate).orElse(0);
int strongeId = Optional.ofNullable(intensifyMap.get(sEquipConfig.getPosition())).orElse(0);
buff += Optional.ofNullable(strengthenMap.get(strongeId)).map(SEquipStrengthen::getRate).orElse(0);
// 突破
buff += Optional.ofNullable(rankUpMap.get(homeRankUp)).map(v -> v.getRate()[sEquipConfig.getPosition() - 1]).orElse(0);
long value = prop[1] + (long) prop[1] / 100 *buff;

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.home;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
@ -51,7 +52,7 @@ public class HomeLogic {
User user = UserManager.getUser(session.getUid());
//xxxx 目前只允许升级一个建筑,多个建筑一键升级需要优化
int id = proto.getIdsList().get(0);
// 1普通升级 2立即完成
// 1普通升级 2立即完成 3:取消升级 4:特权加速
int type = proto.getType();
ArrayList<CommonProto.ArchitectureInfo> list = new ArrayList<>();
// 当前时间
@ -95,7 +96,7 @@ public class HomeLogic {
info.setUpLvEndTime(now + endTime);
}
// 特殊情况
else if (info.getUpLvEndTime() <= now){
if (info.getUpLvEndTime() <= now){
// 升级
architectureUpLvEnd(user, landLevel.getPoolID(), info);
// 可以继续升级
@ -104,32 +105,46 @@ public class HomeLogic {
info.setUpLvEndTime(landLevel1.getTime() + now);
}
}
// 取消
if (type == 3){
info.setUpLvEndTime(0);
}
// 立即完成
if (type == 2 && info.getUpLvEndTime() > now){
// 验证特权次数
boolean countBol = PlayerLogic.getInstance().checkAndUpdate(user, proto.getPrivilageTypeId(), 1);
// 无特权,消耗道具
if (!countBol || proto.getPrivilageTypeId() == 0) {
// 条件: 单位/s 道具id 道具数量
String[] stringValue = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_LATTICE_PRICE).split("#");
// 立即升级消耗的道具
double time = Math.max(info.getUpLvEndTime() - now,0);
if (type == 2){
// 条件: 单位/s 道具id 道具数量
int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE);
// 立即升级消耗的道具
int time = Math.max(info.getUpLvEndTime() - now, 0);
if (time > 0){
// 每一个单位的消耗
double oneCost = Integer.parseInt(stringValue[0]) * Integer.parseInt(stringValue[2]);
int oneCost = intValues[0] * intValues[2];
// 总消耗数量,向上取整
double count = Math.ceil(time / oneCost);
int[][] cost1 = {{Integer.parseInt(stringValue[1]), (int) count}};
int count = (int) Math.ceil((double) time/oneCost);
int[][] cost1 = {{intValues[1], count}};
boolean itemCost = ItemUtil.itemCost(user, cost1, BIReason.ARCHITECTURE_IMMEDIATELY_UP_LEVEL, 0);
if (!itemCost){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH,"浮生门建筑升级立刻升级失败道具不足建筑levelId"+info.getId()+",道具要求:"+Arrays.toString(cost1));
if (!itemCost) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级立刻升级失败道具不足建筑levelId" + info.getId() + ",道具要求:" + Arrays.toString(cost1));
}
}
architectureUpLvEnd(user, landLevel.getPoolID(), info);
}
// 取消升级
if (type == 3){
info.setUpLvEndTime(0);
}
// 特权加速
if (type == 4){
// 验证特权次数
boolean countBol = PlayerLogic.getInstance().checkAndUpdate(user, VipPrivilegeType.HOME_DAY_TIME_NUM, 1);
if (!countBol) {
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"特权加速,特权次数不足");
}
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.BUILDING_TIME_REDUCE);
int time = now + value;
// 加速后是否达到升级时间
if (time >= info.getUpLvEndTime()){
info.setUpLvEndTime(0);
architectureUpLvEnd(user, landLevel.getPoolID(), info);
}else {
info.setUpLvEndTime(time);
}
}
ItemUtil.itemCost(user, items, BIReason.ARCHITECTURE_UP_LEVEL, 0);
// 最后更新
user.getPlayerInfoManager().putArchitectureInfo(landLevel.getPoolID(),info);
@ -217,7 +232,13 @@ public class HomeLogic {
// 配置表参数生产道具id
int itemId = homeLandLevel.getGain()[0];
// 每分钟生产数量
int minutesNum = homeLandLevel.getGain()[1];
double minutesNum = homeLandLevel.getGain()[1];
// 特权
boolean allowed = user.getPlayerInfoManager().checkFunctionIsAllowed(VipPrivilegeType.HOME_ADD_EARNINGS);
if (allowed){
int[][]condition= SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(VipPrivilegeType.HOME_ADD_EARNINGS).getCondition();
minutesNum = minutesNum + minutesNum * condition[0][1] / 10000;
}
// 可领取上限
int getNumMax = homeLandLevel.getStorage()[0][1];
// 存储总上限数值可能为00表示没有上限
@ -232,14 +253,14 @@ public class HomeLogic {
// 可领取的数量,总上限
long maxLimit = totalMax - itemNum;
// 可领取的数量,单位上限
long unitLimit = Math.min(minutesNum*time, getNumMax);
double unitLimit = Math.min(minutesNum*time, getNumMax);
// 可领取的数量
long getNum = Math.min(maxLimit, unitLimit);
double getNum = Math.min(maxLimit, unitLimit);
if (totalMax == 0){
getNum = unitLimit;
}
// 走掉落,进背包
ItemUtil.drop(user, new long[][]{{itemId, getNum}}, BIReason.ARCHITECTURE_EARNINGS, drop);
ItemUtil.drop(user, new long[][]{{itemId, (long) Math.ceil(getNum)}}, BIReason.ARCHITECTURE_EARNINGS, drop);
// 未领取的数量
int time2 = (int) ((unitLimit - getNum) / minutesNum * 60);
info.setProductionStartTime(nowInt - time2);

View File

@ -127,6 +127,8 @@ public class SSpecialConfig implements BaseConfig {
public static final String DAYS_FOR_RECHARGE_SINGLE = "DaysForRechargeSingle";//近期最大单笔充值金额累计时长
public static final String PER_CHANGING_CART_PROP = "PerChangingCartProp";//每激活一张变身卡所增加的全体属性
public static final String BUILDING_TIME_REDUCE = "BuildingTimeReduce";//浮生特权每日每次减少建筑升级时间:秒
@Override
public void init() throws Exception {