心愿抽卡, 逻辑封装

back_recharge
duhui 2021-07-01 11:52:39 +08:00
parent 2569029171
commit 6bfaa31a8a
1 changed files with 30 additions and 13 deletions

View File

@ -36,10 +36,12 @@ import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.tools.Utils;
import com.ljsd.jieling.util.*;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.ToolsUtil;
import config.*;
import manager.STableManager;
import org.slf4j.Logger;
@ -329,17 +331,7 @@ public class HeroLogic{
for(int i = 0 ;i<perCount;i++){
int rewardId = randomOne(user, type);
SLotteryRewardConfig sLotteryRewardConfig = STableManager.getConfig(SLotteryRewardConfig.class).get(rewardId);
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
// 对应卡池抽奖次数
Integer num = heroManager.getRandomCountByType().getOrDefault(sLotterySetting.getLotteryType(),0);
// 心愿抽卡
if (sLotterySetting.getLotteryType() == 1 && num >= value){
resultRandom[i] = wishDrawCardCheck(user,sLotteryRewardConfig.getReward());
}else {
resultRandom[i] = sLotteryRewardConfig.getReward();
}
//记录次数
heroManager.putRandomCount(sLotterySetting.getLotteryType(),num+1);
resultRandom[i] = drawCard(user,sLotteryRewardConfig,sLotterySetting);
index = i;
}
//上报抽卡
@ -382,6 +374,31 @@ public class HeroLogic{
}
}
/**
* 英雄卡池抽卡封装
* @param user
* @param sLotteryRewardConfig
* @param sLotterySetting
* @return
*/
private int[] drawCard(User user, SLotteryRewardConfig sLotteryRewardConfig, SLotterySetting sLotterySetting){
HeroManager heroManager = user.getHeroManager();
// 限制次数
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
// 对应卡池抽奖次数
Integer num = heroManager.getRandomCountByType().getOrDefault(sLotterySetting.getLotteryType(),0);
// 心愿抽卡
int[] result;
if (sLotterySetting.getLotteryType() == 1 && num >= value){
result = wishDrawCardCheck(user,sLotteryRewardConfig.getReward());
}else {
result = sLotteryRewardConfig.getReward();
}
//记录次数
heroManager.putRandomCount(sLotterySetting.getLotteryType(),num+1);
return result;
}
/**
* 心愿抽卡校验
* @param user