占星优化

back_recharge
zhangshanxue 2019-09-23 14:22:34 +08:00
parent 9c96318b63
commit 8b5210be28
8 changed files with 105 additions and 33 deletions

View File

@ -20,9 +20,11 @@ public class SEquipTalismanaLottery implements BaseConfig {
private int[] repeatedlyCost;
private static Map<Integer,SEquipTalismanaLottery> sEquipTalismanaLotteryMap;
@Override
public void init() throws Exception {
sEquipTalismanaLotteryMap = STableManager.getConfig(SEquipTalismanaLottery.class);
}
@ -46,4 +48,7 @@ public class SEquipTalismanaLottery implements BaseConfig {
return repeatedlyCost;
}
public static Map<Integer, SEquipTalismanaLottery> getsEquipTalismanaLotteryMap() {
return sEquipTalismanaLotteryMap;
}
}

View File

@ -1,13 +1,20 @@
package com.ljsd.jieling.handler.equip;
import com.ljsd.jieling.config.SEquipTalismanaLottery;
import com.ljsd.jieling.config.SSpecialConfig;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import org.springframework.stereotype.Component;
@ -27,10 +34,23 @@ public class ForceRandSoulEquipHandler extends BaseHandler<HeroInfoProto.SoulFor
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.SOUL_FORCE_RAND_EQUIP_RESPONSE_VALUE,err);
return;
}
int pos= SSpecialConfig.getIntegerValue(SSpecialConfig.MANDATORY_ASTROLOGICAL);
SEquipTalismanaLottery lotteryIn = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(pos);
if (null == lotteryIn) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + pos);
}
user.getEquipManager().setSoulEquipPool(pos);
int[] droplist = new int[1];
droplist[0]=(MathUtils.randomFromWeight(lotteryIn.getDrop()));
CommonProto.Drop.Builder drop = ItemUtil.drop(user, droplist,1,0,BIReason.RANDOM_SOULEQUIP);
HeroInfoProto.SoulForceRandResponse.Builder builder = HeroInfoProto.SoulForceRandResponse.newBuilder();
builder.setDrop(drop);
builder.setPos(pos);
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.SOUL_FORCE_RAND_EQUIP_RESPONSE_VALUE,builder.build(),true);
user.getUserMissionManager().onGameEvent(user, GameEvent.FIND_STAR,1);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.SOUL_FORCE_RAND_EQUIP_RESPONSE_VALUE, builder.build(), true);
}
}

View File

@ -249,9 +249,9 @@ public class Cmd_changename extends GmRoleAbstract {
String key = RedisKey.getKey(RedisKey.C_User_Name_Key, name, false);
RedisUtil.getInstence().set(key, String.valueOf(getUser().getId()), RedisKey.REDIS_OVER_FOREVER);
Map<Integer, Integer> itemMap = new HashMap<>(1);
itemMap.put(Global.CHANGENAME, 1);
ItemUtil.addItem(user, itemMap, null, BIReason.GM_CHANGENAME);
// Map<Integer, Integer> itemMap = new HashMap<>(1);
// itemMap.put(Global.CHANGENAME, 1);
// ItemUtil.addItem(user, itemMap, null, BIReason.GM_CHANGENAME);
//sendmail
String title = SErrorCodeEerverConfig.getI18NMessage("change_name_title");

View File

@ -0,0 +1,17 @@
package com.ljsd.jieling.kefu;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
public class Cmd_join_gm extends GmAbstract {
@Override
public boolean exec(String[] args) throws Exception {
// for (int i = 0; i <150 ; i++) {
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(10000+i), 10000+i);
// }
return true;
}
}

View File

@ -0,0 +1,9 @@
package com.ljsd.jieling.kefu;
public class Cmd_role_gm extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
return true;
}
}

View File

@ -975,23 +975,26 @@ public class ActivityLogic {
}
int start = (page - 1) * 20, end = page * 20 - 1;
List<CommonProto.UseForceInfo> useForceInfoList = new ArrayList<>(20);
Set<ZSetOperations.TypedTuple<String>> rankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FORCE_RANK,"", start, end);
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
String value = item.getValue();
int score = item.getScore().intValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUser(uid);
int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.COMBAT_RANKINGSHOWNUM);
if(end<rankEndLine) {
Set<ZSetOperations.TypedTuple<String>> rankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FORCE_RANK, "", start, end);
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
String value = item.getValue();
int score = item.getScore().intValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUser(uid);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
CommonProto.UseForceInfo personInfoBuild = CommonProto.UseForceInfo.newBuilder()
.setLeve(playerInfoManager.getLevel())
.setName(playerInfoManager.getNickName())
.setForce(score)
.setRank(++start)
.setHeadFrame(playerInfoManager.getHeadFrame())
.setHead(0)
.build();
useForceInfoList.add(personInfoBuild);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
CommonProto.UseForceInfo personInfoBuild = CommonProto.UseForceInfo.newBuilder()
.setLeve(playerInfoManager.getLevel())
.setName(playerInfoManager.getNickName())
.setForce(score)
.setRank(++start)
.setHeadFrame(playerInfoManager.getHeadFrame())
.setHead(0)
.build();
useForceInfoList.add(personInfoBuild);
}
}
int uid = session.getUid();

View File

@ -72,8 +72,7 @@ class ForceRankActivity extends AbstractActivity {
}
}
int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.COMBAT_RANKINGSHOWNUM);
Set<ZSetOperations.TypedTuple<String>> rankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FORCE_RANK, "", 0, rankEndLine-1);
Set<ZSetOperations.TypedTuple<String>> rankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FORCE_RANK, "", 0, maxRank-1);
int rank = 1;
int nowTime = (int) (TimeUtils.now() / 1000);
for (ZSetOperations.TypedTuple<String> item : rankInfo) {

View File

@ -4,6 +4,7 @@ import com.ljsd.jieling.config.*;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.activity.event.EspecialEquipUpEvent;
@ -510,27 +511,45 @@ public class ItemLogic {
User user = UserManager.getUser(uid);
int currentPool = user.getEquipManager().getSoulEquipPool();
int[][] cost = time == 50 ? new int[1][]:new int[time][];
int[][] cost = time == 50 ? new int[1][]:new int[50][];
//跳卡池
SEquipTalismanaLottery lottery = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
if (null == lottery) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
currentPool = MathUtils.randomFromWeight(lottery.getProbability());
//50cost
SEquipTalismanaLottery lotteryRepeat = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
if (null == lotteryRepeat) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
if(time==50){
SEquipTalismanaLottery lottery = STableManager.getConfig(SEquipTalismanaLottery.class).get(currentPool);
if (null == lottery) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
cost[0]=lottery.getRepeatedlyCost();
cost[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++) {
SEquipTalismanaLottery lottery = STableManager.getConfig(SEquipTalismanaLottery.class).get(currentPool);
if (null == lottery) {
SEquipTalismanaLottery lotteryIn = SEquipTalismanaLottery.getsEquipTalismanaLotteryMap().get(currentPool);
if (null == lotteryIn) {
throw new Exception("SEquipTalismanaLottery 配置不存在" + currentPool);
}
droplist[i]=(MathUtils.randomFromWeight(lottery.getDrop()));
currentPool = MathUtils.randomFromWeight(lottery.getProbability());
if(time!=50){
cost[i] = lottery.getCostItem();
cost[i] = lotteryIn.getCostItem();
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) {
break;
}
}
droplist[i]=(MathUtils.randomFromWeight(lotteryIn.getDrop()));
currentPool = MathUtils.randomFromWeight(lottery.getProbability());
}
boolean enoughCost = ItemUtil.itemCost(user, cost, BIReason.RANDOM_SOULEQUIP_CONSUME, 0);