命格脚本提交
parent
40ae47feb0
commit
204eb5f959
|
@ -370,4 +370,6 @@ public interface BIReason {
|
|||
|
||||
int FABAO_SOUL_UP_COST =1223;//法宝之魂升级消耗
|
||||
int TRANSFORMATION_CARD_COST = 1224;//变身卡激活消耗
|
||||
|
||||
int LIFE_STONE_UP = 1225;//命石合成
|
||||
}
|
|
@ -38,6 +38,7 @@ public interface GlobalItemType {
|
|||
int MOUNT_FRAGMENTS_ITEM = 28;//坐骑碎片
|
||||
int TRANSFORMATION_CARD = 29;//化身卡
|
||||
int TRUMP_CHIP=30;//法宝碎片(法宝聚灵使用)
|
||||
int LIFE_STONE=31;//命石
|
||||
//物品使用类型
|
||||
int NO_USE = 0 ; //不使用
|
||||
int RANDOM_USE = 1; // 随机使用
|
||||
|
|
|
@ -245,6 +245,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
.setXiuweiLevel(heroManager.getXiuweiLevel())
|
||||
.addAllPracticeSkillInfos(practiceSkillInfos)
|
||||
.addAllFaBaoSoulInfos(faBaoSoulInfos)
|
||||
.addAllLifeGridInfos(getLifeGridInfos(heroManager))
|
||||
.build();
|
||||
ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType());
|
||||
try {
|
||||
|
@ -387,6 +388,26 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
return faBaoSoulInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化获取命格数据
|
||||
* @param heroManager
|
||||
* @return
|
||||
*/
|
||||
private List<CommonProto.LifeGridInfo>getLifeGridInfos(HeroManager heroManager){
|
||||
List<CommonProto.LifeGridInfo>lifeGridInfos=new ArrayList<>();
|
||||
for (Map.Entry<Integer, Map<Integer,Integer>> entry : heroManager.getLifeGridMap().entrySet()) {
|
||||
for (Map.Entry<Integer, Integer> indexById : entry.getValue().entrySet()) {
|
||||
CommonProto.LifeGridInfo info=CommonProto.LifeGridInfo.newBuilder()
|
||||
.setGridId(entry.getKey())
|
||||
.setGridIndex(indexById.getKey())
|
||||
.setItemId(indexById.getValue())
|
||||
.build();
|
||||
lifeGridInfos.add(info);
|
||||
}
|
||||
}
|
||||
return lifeGridInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化英雄星级map(针对老号)
|
||||
* @param user
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.HeroManager;
|
||||
import com.ljsd.jieling.logic.dao.Item;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 命格穿戴/卸下
|
||||
*/
|
||||
@Component
|
||||
public class LifeGridChangeRequestHandler extends BaseHandler<HeroInfoProto.LifeGridChangeRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.LIFE_GRID_CHANGE_REQUEST;
|
||||
}
|
||||
@Override
|
||||
public void processWithProto(ISession session, HeroInfoProto.LifeGridChangeRequest proto) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int type=proto.getType();
|
||||
int position=proto.getPosition();
|
||||
int index=proto.getIndex();
|
||||
int itemId=proto.getLifeStoneId();
|
||||
HeroManager heroManager=user.getHeroManager();
|
||||
Map<Integer, Map<Integer,Integer>>lifeGridMap=heroManager.getLifeGridMap();
|
||||
HeroInfoProto.LifeGridChangeResponse response=null;
|
||||
if (type==1){//穿戴
|
||||
Map<Integer,Integer>instItemMap=new HashMap<>();
|
||||
instItemMap.put(itemId,1);
|
||||
boolean isTrue=ItemUtil.itemCost(user,instItemMap,BIReason.LIFE_STONE_UP,type);
|
||||
if (!isTrue){
|
||||
LOGGER.error("穿戴的命石未拥有");
|
||||
throw new ErrorCodeException(ErrorCode.HANDLE_FAILED);
|
||||
}
|
||||
//更换
|
||||
if (lifeGridMap.containsKey(position)&&lifeGridMap.get(position).containsKey(index)&&lifeGridMap.get(position).get(index)>0){
|
||||
int unItemId=lifeGridMap.get(position).get(index);
|
||||
int[][]unItem=new int[1][2];
|
||||
unItem[0][0]=unItemId;
|
||||
unItem[0][1]=1;
|
||||
ItemUtil.drop(user,unItem, BIReason.LIFE_STONE_UP);
|
||||
}
|
||||
heroManager.setLifeGridMap(position,index,itemId);
|
||||
CommonProto.LifeGridInfo lifeGridInfo=CommonProto.LifeGridInfo.newBuilder()
|
||||
.setGridId(position)
|
||||
.setGridIndex(index)
|
||||
.setItemId(itemId)
|
||||
.build();
|
||||
response=HeroInfoProto.LifeGridChangeResponse.newBuilder().setLifeGridInfo(lifeGridInfo).build();
|
||||
}else{//卸下
|
||||
int unItemId= lifeGridMap.get(position).get(index);
|
||||
int[][]unItem=new int[1][2];
|
||||
unItem[0][0]=unItemId;
|
||||
unItem[0][1]=1;
|
||||
ItemUtil.drop(user,unItem, BIReason.LIFE_STONE_UP);
|
||||
heroManager.setLifeGridMap(position,index,0);
|
||||
CommonProto.LifeGridInfo lifeGridInfo=CommonProto.LifeGridInfo.newBuilder()
|
||||
.setGridId(position)
|
||||
.setGridIndex(index)
|
||||
.setItemId(0)
|
||||
.build();
|
||||
response=HeroInfoProto.LifeGridChangeResponse.newBuilder().setLifeGridInfo(lifeGridInfo).build();
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.LIFE_GRID_CHANGE_RESPONSE_VALUE,response,true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
|
||||
import com.ljsd.jieling.logic.dao.Item;
|
||||
import com.ljsd.jieling.logic.dao.ItemManager;
|
||||
import com.ljsd.jieling.logic.dao.SixiangProfessionInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.tools.Utils;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SFourQuadrantConfig;
|
||||
import config.SGemConfig;
|
||||
import config.SItem;
|
||||
import manager.STableManager;
|
||||
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 命石合成协议
|
||||
*/
|
||||
@Component
|
||||
public class LifeStoneUpRequestHandler extends BaseHandler<HeroInfoProto.LifeStoneUpRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.LIFE_STONE_UP_REQUEST;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, HeroInfoProto.LifeStoneUpRequest proto) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int type= proto.getType();
|
||||
Map<Integer, Long>costItemMap=new HashMap<>();
|
||||
Map<Integer, Long>addItemMap=new HashMap<>();
|
||||
int equipLifeStoneId=0;
|
||||
ItemManager itemManager=user.getItemManager();
|
||||
//操作类型 1:批量合成 2:一键合成 3:命石单个合成 4:快速合成
|
||||
if (type==1) {
|
||||
int itemId=proto.getCurGemId();
|
||||
int itemNum=proto.getSelectNum();
|
||||
SGemConfig gemConfig=STableManager.getConfig(SGemConfig.class).get(itemId);
|
||||
long upNum=itemNum/gemConfig.getUpgradeNum();
|
||||
long costGold=upNum*gemConfig.getUpgradeCost()[1];
|
||||
costItemMap.put(gemConfig.getUpgradeCost()[0],costGold);
|
||||
costItemMap.put(itemId,(long)itemNum);
|
||||
addItemMap.put(gemConfig.getNextGem(),upNum);
|
||||
}else if(type==2){
|
||||
for (Map.Entry<Integer, TreeMap<Integer, SGemConfig>> integerTreeMapEntry : SGemConfig.gemConfigMapByType.entrySet()) {
|
||||
boolean isCost=LifeStoneAllUp(itemManager,integerTreeMapEntry.getValue(),costItemMap,addItemMap);
|
||||
if (!isCost) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if (type==3){
|
||||
int itemId=proto.getCurGemId();
|
||||
int itemNum=proto.getSelectNum();
|
||||
SGemConfig gemConfig=STableManager.getConfig(SGemConfig.class).get(itemId);
|
||||
costItemMap.put(gemConfig.getUpgradeCost()[0],(long)gemConfig.getUpgradeCost()[1]);
|
||||
if (proto.getGridId()>0){
|
||||
costItemMap.put(itemId,(long)itemNum);
|
||||
equipLifeStoneId=gemConfig.getNextGem();
|
||||
}else{
|
||||
costItemMap.put(itemId,(long)itemNum+1);
|
||||
addItemMap.put(gemConfig.getNextGem(),1L);
|
||||
}
|
||||
|
||||
}else if (type==4){
|
||||
SGemConfig gemConfig=STableManager.getConfig(SGemConfig.class).get(proto.getCurGemId());
|
||||
TreeMap<Integer,SGemConfig>gemConfigMap=SGemConfig.gemConfigMapByType.get(gemConfig.getType());
|
||||
if (LifeStoneQuickUp(itemManager,gemConfigMap,costItemMap,gemConfig.getLevel())) {
|
||||
int[]curUpCost=gemConfig.getUpgradeCost();
|
||||
long allGoldCost= costItemMap.get(curUpCost[0])+curUpCost[1];
|
||||
costItemMap.put(curUpCost[0],allGoldCost);
|
||||
if (proto.getGridId()>0){
|
||||
equipLifeStoneId=gemConfig.getNextGem();
|
||||
}else {
|
||||
addItemMap.put(gemConfig.getNextGem(),1L);
|
||||
costItemMap.put(proto.getCurGemId(),1L);
|
||||
}
|
||||
}else{
|
||||
LOGGER.error("命石合成材料不足");
|
||||
throw new ErrorCodeException(ErrorCode.HANDLE_FAILED);
|
||||
}
|
||||
}
|
||||
if (costItemMap.isEmpty()){
|
||||
LOGGER.error("命石合成异常,请联系后端");
|
||||
throw new ErrorCodeException(ErrorCode.HANDLE_FAILED);
|
||||
}
|
||||
boolean isTrue= ItemUtil.itemCostLong(user,costItemMap,BIReason.LIFE_STONE_UP,type);
|
||||
if (!isTrue){
|
||||
LOGGER.error("命石合成材料不足");
|
||||
throw new ErrorCodeException(ErrorCode.HANDLE_FAILED);
|
||||
}
|
||||
HeroInfoProto.LifeStoneUpResponse.Builder response=HeroInfoProto.LifeStoneUpResponse.newBuilder();
|
||||
///大于0说明是在命格系统操作
|
||||
if (equipLifeStoneId>0){
|
||||
CommonProto.LifeGridInfo lifeGridInfo=CommonProto.LifeGridInfo.newBuilder()
|
||||
.setGridId(proto.getGridId())
|
||||
.setGridIndex(proto.getGridIndex())
|
||||
.setItemId(equipLifeStoneId)
|
||||
.build();
|
||||
response.setLifeGridInfo(lifeGridInfo);
|
||||
user.getHeroManager().setLifeGridMap(proto.getGridId(),proto.getGridIndex(),equipLifeStoneId);
|
||||
}else{
|
||||
long[][]addItem=ItemUtil.mapToLongArray(addItemMap);
|
||||
CommonProto.Drop.Builder drop=ItemUtil.drop(user,addItem,BIReason.LIFE_STONE_UP);
|
||||
response.setDrop(drop.build());
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.LIFE_STONE_UP_RESPONSE_VALUE,response.build(),true);
|
||||
}
|
||||
|
||||
|
||||
///命石一键合成
|
||||
public boolean LifeStoneAllUp(ItemManager itemManager,TreeMap<Integer,SGemConfig>gemConfigMap, Map<Integer, Long>costItemMap, Map<Integer, Long>addItemMap){
|
||||
long addCount=0;//一个循环合成数量
|
||||
long costGoldNum=0;//合成金币总消耗
|
||||
if(costItemMap.containsKey(14)){
|
||||
costGoldNum=costItemMap.get(14);
|
||||
}
|
||||
for (Map.Entry<Integer, SGemConfig> gemConfigEntry : gemConfigMap.entrySet()) {
|
||||
SGemConfig gemConfig=gemConfigEntry.getValue();
|
||||
///升到满级
|
||||
if (gemConfig.getNextGem()==0){
|
||||
if (addCount>0){
|
||||
addItemMap.put(gemConfig.getId(),addCount);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Item curItem= itemManager.getItem(gemConfig.getId());
|
||||
long costNum=addCount;
|
||||
if (curItem!=null){
|
||||
costNum=curItem.getItemNum()+addCount;
|
||||
}
|
||||
///命石不足
|
||||
if (costNum< gemConfig.getUpgradeNum()){
|
||||
if (addCount>0){
|
||||
addItemMap.put(gemConfig.getId(),addCount);
|
||||
addCount=0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int stoneNum=gemConfig.getUpgradeNum();
|
||||
int[]costGold=gemConfig.getUpgradeCost();
|
||||
long remainNum=costNum%stoneNum;
|
||||
if (remainNum!=0){
|
||||
costNum-=remainNum;
|
||||
}
|
||||
if (costNum>0){
|
||||
//本次合成消耗
|
||||
long needCostGoldNum=costNum/stoneNum*costGold[1];
|
||||
long haveGoldNum=0;
|
||||
if (itemManager.getItem(costGold[0])!=null){
|
||||
haveGoldNum=itemManager.getItem(costGold[0]).getItemNum();
|
||||
}
|
||||
///金币不足情况中断合成
|
||||
if (needCostGoldNum+costGoldNum>haveGoldNum){
|
||||
long upNum= (haveGoldNum-costGoldNum)/costGold[1];
|
||||
costItemMap.put(gemConfig.getId(),upNum*stoneNum);
|
||||
addItemMap.put(gemConfig.getNextGem(),upNum);
|
||||
costGoldNum+=upNum*costGold[1];
|
||||
//刷新消耗金币数量
|
||||
costItemMap.put(costGold[0],costGoldNum);
|
||||
return false;
|
||||
}
|
||||
//计算累计消耗金币
|
||||
costGoldNum+=needCostGoldNum;
|
||||
if (curItem!=null){
|
||||
long bagCost=curItem.getItemNum()-remainNum;
|
||||
//刷新消耗命石数量
|
||||
costItemMap.put(gemConfig.getId(),bagCost);
|
||||
long addNum=remainNum-curItem.getItemNum();
|
||||
if (addNum>0){
|
||||
addItemMap.put(gemConfig.getId(),addNum);
|
||||
}
|
||||
}
|
||||
//保存累计消耗金币数量
|
||||
costItemMap.put(costGold[0],costGoldNum);
|
||||
}
|
||||
if (curItem==null){
|
||||
addItemMap.put(gemConfig.getId(),remainNum);
|
||||
}
|
||||
addCount=costNum/stoneNum;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命石快速合成
|
||||
* @param itemManager
|
||||
* @param gemConfigMap
|
||||
* @param costItemMap
|
||||
* @param selectGemLv
|
||||
* @return
|
||||
*/
|
||||
public boolean LifeStoneQuickUp(ItemManager itemManager,TreeMap<Integer,SGemConfig>gemConfigMap, Map<Integer, Long>costItemMap,int selectGemLv){
|
||||
long addCount=0;//一个循环合成数量
|
||||
long costGoldNum=0;//合成金币总消耗
|
||||
for (Map.Entry<Integer, SGemConfig> gemConfigEntry : gemConfigMap.entrySet()) {
|
||||
SGemConfig gemConfig=gemConfigEntry.getValue();
|
||||
///如果命石等级大于当前选中的命石等级跳过
|
||||
if (gemConfig.getLevel()>=selectGemLv){
|
||||
break;
|
||||
}
|
||||
|
||||
Item curItem= itemManager.getItem(gemConfig.getId());
|
||||
long costNum=addCount;
|
||||
if (curItem!=null){
|
||||
costNum=curItem.getItemNum()+addCount;
|
||||
}
|
||||
int[]costGold=gemConfig.getUpgradeCost();
|
||||
int stoneNum=gemConfig.getUpgradeNum();
|
||||
if (costNum<stoneNum){
|
||||
costItemMap.clear();
|
||||
costGoldNum=0;
|
||||
addCount=0;
|
||||
continue;
|
||||
}
|
||||
long needNum= GetNeedLifeStoneNum(gemConfig.getType(),gemConfig.getLevel(),selectGemLv);
|
||||
//剩余数量
|
||||
long remainNum=costNum%stoneNum;
|
||||
if (costNum>needNum){
|
||||
costNum=needNum;
|
||||
remainNum=costNum-needNum;
|
||||
}
|
||||
addCount=costNum/stoneNum;
|
||||
//本次合成消耗金币
|
||||
long needCostGoldNum=addCount*costGold[1];
|
||||
//计算累计消耗金币
|
||||
costGoldNum+=needCostGoldNum;
|
||||
costItemMap.put(costGold[0],costGoldNum);
|
||||
if (curItem!=null){
|
||||
long bagCost=curItem.getItemNum()-remainNum;
|
||||
//刷新消耗命石数量
|
||||
costItemMap.put(gemConfig.getId(),bagCost);
|
||||
}
|
||||
long haveGoldNum=itemManager.getItem(costGold[0]).getItemNum();
|
||||
if (costGoldNum>haveGoldNum){
|
||||
LOGGER.error("命石快速合成金币不足");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return addCount==1;
|
||||
}
|
||||
/**
|
||||
* 获取升级到目标等级获取消耗指定命石需要数量
|
||||
* @param stoneType 命石类型
|
||||
* @param costStoneLv 消耗命石等级
|
||||
* @param targetStoneLv 目标等级
|
||||
* @return
|
||||
*/
|
||||
private long GetNeedLifeStoneNum(int stoneType, int costStoneLv,int targetStoneLv){
|
||||
long needNum=1;
|
||||
TreeMap<Integer,SGemConfig>stoneLvMap= SGemConfig.gemConfigMapByType.get(stoneType);
|
||||
for (Map.Entry<Integer, SGemConfig> gemConfigEntry : stoneLvMap.entrySet()) {
|
||||
if (gemConfigEntry.getKey()<costStoneLv){
|
||||
continue;
|
||||
}
|
||||
if (gemConfigEntry.getValue().getLevel()==targetStoneLv){
|
||||
break;
|
||||
}
|
||||
needNum*=gemConfigEntry.getValue().getUpgradeNum();
|
||||
}
|
||||
return needNum;
|
||||
}
|
||||
|
||||
}
|
|
@ -167,6 +167,24 @@ public class HeroManager extends MongoBase {
|
|||
return faBaoGongMingSkillMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命格数据
|
||||
*/
|
||||
private Map<Integer,Map<Integer,Integer>>LifeGridMap=new HashMap<>();
|
||||
|
||||
public Map<Integer, Map<Integer, Integer>> getLifeGridMap() {
|
||||
return LifeGridMap;
|
||||
}
|
||||
|
||||
///设置命格数据
|
||||
public void setLifeGridMap(int gridId,int index,int itemId) {
|
||||
if (!LifeGridMap.containsKey(gridId)) {
|
||||
LifeGridMap.put(gridId, new HashMap<>());
|
||||
}
|
||||
LifeGridMap.get(gridId).put(index,itemId);
|
||||
updateString("LifeGridMap."+gridId, LifeGridMap.get(gridId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 心愿可以选择的英雄列表
|
||||
*/
|
||||
|
|
|
@ -567,6 +567,7 @@ public class ItemUtil {
|
|||
case GlobalItemType.LikableCostItem:
|
||||
case GlobalItemType.MOUNT_FRAGMENTS_ITEM:
|
||||
case GlobalItemType.TRUMP_CHIP:
|
||||
case GlobalItemType.LIFE_STONE:
|
||||
case GlobalItemType.TRANSFORMATION_CARD:
|
||||
itemType = GlobalItemType.ITEM;
|
||||
break;
|
||||
|
@ -1408,15 +1409,6 @@ public class ItemUtil {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean itemCostLong(User user,Map<Integer, Long> costItems,int reason,int subReson) throws Exception {
|
||||
boolean result = checkCostLong(user, costItems);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
useItemLong(user, costItems,reason,subReson);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean itemCost(User user,int[][] costItems,int times,int reason,int subReason) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
selectCost(costItems,itemMap,times);
|
||||
|
@ -1428,6 +1420,15 @@ public class ItemUtil {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean itemCostLong(User user,Map<Integer, Long> costItems,int reason,int subReson) throws Exception {
|
||||
boolean result = checkCostLong(user, costItems);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
useItemLong(user, costItems,reason,subReson);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean checkCost(User user, Map<Integer, Integer> itemMap) throws Exception {
|
||||
HashMap<Integer, Long> longMap = new HashMap<>();
|
||||
itemMap.forEach((k,v)->longMap.put(k,v.longValue()));
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Table(name ="GemConfig")
|
||||
public class SGemConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int quality;
|
||||
|
||||
private int type;
|
||||
|
||||
private int level;
|
||||
|
||||
private int[][] property;
|
||||
|
||||
private int upgradeNum;
|
||||
|
||||
private int[] upgradeCost;
|
||||
|
||||
private int nextGem;
|
||||
|
||||
public static TreeMap<Integer, TreeMap<Integer,SGemConfig>>gemConfigMapByType;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
gemConfigMapByType=new TreeMap<>();
|
||||
Map<Integer, SGemConfig> config = STableManager.getConfig(SGemConfig.class);
|
||||
for(SGemConfig sGemConfig : config.values()){
|
||||
if (!gemConfigMapByType.containsKey(sGemConfig.getType())){
|
||||
TreeMap<Integer,SGemConfig>lvMap=new TreeMap<>();
|
||||
gemConfigMapByType.put(sGemConfig.getType(),lvMap);
|
||||
}
|
||||
gemConfigMapByType.get(sGemConfig.getType()).put(sGemConfig.getLevel(),sGemConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int[][] getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public int getUpgradeNum() {
|
||||
return upgradeNum;
|
||||
}
|
||||
|
||||
public int[] getUpgradeCost() {
|
||||
return upgradeCost;
|
||||
}
|
||||
|
||||
public int getNextGem() {
|
||||
return nextGem;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue