占星优化

back_recharge
zhangshanxue 2019-09-23 17:58:07 +08:00
parent 9af1ae4196
commit 68daab49d7
3 changed files with 43 additions and 22 deletions

View File

@ -16,14 +16,18 @@ public class SFloodConfig implements BaseConfig {
private int battleTime;
private static Map<Integer,SFloodConfig> sFloodConfigMap;
@Override
public void init() throws Exception {
sFloodConfigMap = STableManager.getConfig(SFloodConfig.class);
}
public static Map<Integer, SFloodConfig> getsFloodConfigMap() {
return sFloodConfigMap;
}
public int getId() {
public int getId() {
return id;
}

View File

@ -2287,7 +2287,7 @@ public class MapLogic {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "fightId 有误");
return;
}
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(fightId);
SFloodConfig sFloodConfig =SFloodConfig.getsFloodConfigMap().get(fightId);
if (sFloodConfig == null) {
LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, fightId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
@ -2355,7 +2355,7 @@ public class MapLogic {
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(checkFightId);
SFloodConfig sFloodConfig = SFloodConfig.getsFloodConfigMap().get(checkFightId);
if (sFloodConfig == null) {
LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, checkFightId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");

View File

@ -502,16 +502,16 @@ public class ItemLogic {
/**
*
*
* @param session session
* @param time 50
* @param time 50
* @throws Exception
*/
public void soulEquipRand(ISession session,int time) throws Exception{
public void soulEquipRand(ISession session, int time) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
int currentPool = user.getEquipManager().getSoulEquipPool();
int[][] cost = time == 50 ? new int[1][]:new int[50][];
//跳卡池
SEquipTalismanaLottery lottery = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
@ -520,55 +520,72 @@ public class ItemLogic {
}
currentPool = MathUtils.randomFromWeight(lottery.getProbability());
//50cost
SEquipTalismanaLottery lotteryRepeat = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
if (null == lotteryRepeat) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
if(time==50){
cost[0]=lotteryRepeat.getRepeatedlyCost();
int[][] tempCost = new int[1][];
if (time == 50) {
tempCost[0] = lotteryRepeat.getRepeatedlyCost();
}
//next cost and drop
int[] droplist = new int[time];
Map<Integer, Integer> itemMap = new HashMap<>();
for (int i = 0; i < time; i++) {
ArrayList<Integer> droplist = new ArrayList<>();
int realTime = 0;
int randTime = time == 1 ? 1 : 50;
for (int i = 0; i < randTime; i++) {
SEquipTalismanaLottery lotteryIn = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
if (null == lotteryIn) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
if(time!=50){
cost[i] = lotteryIn.getCostItem();
if (time != 50) {
int itemId = lotteryIn.getCostItem()[0];
int itemNum = lotteryIn.getCostItem()[1];
itemMap.merge(itemId, itemNum, (a, b) -> b + a);
boolean result = ItemUtil.checkCost(user, itemMap);
if (!result) {
itemMap.merge(itemId, itemNum, (a, b) -> a - b);
break;
}
}
droplist[i]=(MathUtils.randomFromWeight(lotteryIn.getDrop()));
droplist.add(MathUtils.randomFromWeight(lotteryIn.getDrop()));
currentPool = MathUtils.randomFromWeight(lottery.getProbability());
realTime++;
}
if (time != 50) {
tempCost = new int[itemMap.size()][2];
int index = 0;
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
tempCost[index][0] = entry.getKey();
tempCost[index][1] = entry.getValue();
index++;
}
}
boolean enoughCost = ItemUtil.itemCost(user, cost, BIReason.RANDOM_SOULEQUIP_CONSUME, 0);
boolean enoughCost = ItemUtil.itemCost(user, tempCost, BIReason.RANDOM_SOULEQUIP_CONSUME, 0);
if (!enoughCost) {
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.SOUL_RAND_EQUIP_RESPONSE_VALUE, "道具不足");
return;
}
if (realTime == 0) {
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.SOUL_RAND_EQUIP_RESPONSE_VALUE, HeroInfoProto.SoulRandResponse.newBuilder().setTime(0).build(), true);
return;
}
user.getEquipManager().setSoulEquipPool(currentPool);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, droplist,1,0,BIReason.RANDOM_SOULEQUIP);
int[] dropArray = droplist.stream().mapToInt(Integer::valueOf).toArray();
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropArray, 1, 0, BIReason.RANDOM_SOULEQUIP);
HeroInfoProto.SoulRandResponse.Builder builder = HeroInfoProto.SoulRandResponse.newBuilder();
builder.setDrop(drop);
builder.setPos(currentPool);
user.getUserMissionManager().onGameEvent(user,GameEvent.FIND_STAR,time);
builder.setTime(realTime);
user.getUserMissionManager().onGameEvent(user, GameEvent.FIND_STAR, time);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.SOUL_RAND_EQUIP_RESPONSE_VALUE, builder.build(), true);
}
public static int getSoulCfgIdByEquipId(int equipId,int leve){
return equipId*100+leve;
}