generated from root/miduo_server
提交礼物系统
parent
860a7e7edb
commit
d1b932ba6d
File diff suppressed because it is too large
Load Diff
|
@ -7574,6 +7574,30 @@ public final class MessageTypeProto {
|
|||
* </pre>
|
||||
*/
|
||||
GET_GOOGLE_COMMENT_REWARD(1197, 922022),
|
||||
/**
|
||||
* <code>GiftEquipWearRequest = 6000007;</code>
|
||||
*
|
||||
* <pre>
|
||||
* 礼物
|
||||
* </pre>
|
||||
*/
|
||||
GiftEquipWearRequest(1198, 6000007),
|
||||
/**
|
||||
* <code>GiftEquipWearResponse = 6000008;</code>
|
||||
*/
|
||||
GiftEquipWearResponse(1199, 6000008),
|
||||
/**
|
||||
* <code>GiftEquipUpStarRequest = 6000033;</code>
|
||||
*
|
||||
* <pre>
|
||||
* 礼物装备升星
|
||||
* </pre>
|
||||
*/
|
||||
GiftEquipUpStarRequest(1200, 6000033),
|
||||
/**
|
||||
* <code>GiftEquipUpStarResponse = 6000034;</code>
|
||||
*/
|
||||
GiftEquipUpStarResponse(1201, 6000034),
|
||||
;
|
||||
|
||||
/**
|
||||
|
@ -15137,6 +15161,30 @@ public final class MessageTypeProto {
|
|||
* </pre>
|
||||
*/
|
||||
public static final int GET_GOOGLE_COMMENT_REWARD_VALUE = 922022;
|
||||
/**
|
||||
* <code>GiftEquipWearRequest = 6000007;</code>
|
||||
*
|
||||
* <pre>
|
||||
* 礼物
|
||||
* </pre>
|
||||
*/
|
||||
public static final int GiftEquipWearRequest_VALUE = 6000007;
|
||||
/**
|
||||
* <code>GiftEquipWearResponse = 6000008;</code>
|
||||
*/
|
||||
public static final int GiftEquipWearResponse_VALUE = 6000008;
|
||||
/**
|
||||
* <code>GiftEquipUpStarRequest = 6000033;</code>
|
||||
*
|
||||
* <pre>
|
||||
* 礼物装备升星
|
||||
* </pre>
|
||||
*/
|
||||
public static final int GiftEquipUpStarRequest_VALUE = 6000033;
|
||||
/**
|
||||
* <code>GiftEquipUpStarResponse = 6000034;</code>
|
||||
*/
|
||||
public static final int GiftEquipUpStarResponse_VALUE = 6000034;
|
||||
|
||||
|
||||
public final int getNumber() { return value; }
|
||||
|
@ -16341,6 +16389,10 @@ public final class MessageTypeProto {
|
|||
case 922020: return POWER_CENTER_INFO_INDICATION;
|
||||
case 922021: return HERO_GET_INDICATION;
|
||||
case 922022: return GET_GOOGLE_COMMENT_REWARD;
|
||||
case 6000007: return GiftEquipWearRequest;
|
||||
case 6000008: return GiftEquipWearResponse;
|
||||
case 6000033: return GiftEquipUpStarRequest;
|
||||
case 6000034: return GiftEquipUpStarResponse;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
@ -16402,7 +16454,7 @@ public final class MessageTypeProto {
|
|||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n\026MessageTypeProto.proto\022\032com.ljsd.jieli" +
|
||||
"ng.protocols*\254\272\002\n\013MessageType\022\027\n\022HEART_B" +
|
||||
"ng.protocols*\246\273\002\n\013MessageType\022\027\n\022HEART_B" +
|
||||
"EAT_REQUEST\020\350\007\022\030\n\023HEART_BEAT_RESPONSE\020\351\007" +
|
||||
"\022\036\n\031ACTIVITE_WORKSHOP_REQUEST\020\224N\022\037\n\032ACTI" +
|
||||
"VITE_WORKSHOP_RESPONSE\020\225N\022\027\n\022ARENA_INFO_" +
|
||||
|
@ -17408,7 +17460,10 @@ public final class MessageTypeProto {
|
|||
"\022\"\n\034VOUCHER_PRICE_GOODS_RESPONSE\020\242\2438\022\"\n\034" +
|
||||
"POWER_CENTER_INFO_INDICATION\020\244\2438\022\031\n\023HERO" +
|
||||
"_GET_INDICATION\020\245\2438\022\037\n\031GET_GOOGLE_COMMEN" +
|
||||
"T_REWARD\020\246\2438B\002H\001"
|
||||
"T_REWARD\020\246\2438\022\033\n\024GiftEquipWearRequest\020\207\233\356" +
|
||||
"\002\022\034\n\025GiftEquipWearResponse\020\210\233\356\002\022\035\n\026GiftE" +
|
||||
"quipUpStarRequest\020\241\233\356\002\022\036\n\027GiftEquipUpSta",
|
||||
"rResponse\020\242\233\356\002B\002H\001"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
|
|
|
@ -328,4 +328,9 @@ public interface BIReason {
|
|||
int HERO_BACK_STAR_COST = 223; //英雄回溯
|
||||
|
||||
int BLITZ_HERO_RESURRECTION= 224;//遗忘之城英雄复活
|
||||
|
||||
int GIFT_EQUIP_UP_COST = 1333;//礼物穿戴消耗
|
||||
int GIFT_EQUIP_DOWN_REWARD = 1334;//礼物脱卸获得
|
||||
int GIFT_UP_STAR_COST = 1335;//礼物装备升星
|
||||
int GIFT_UP_STAR_GET = 1336;//礼物装备获得
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.ljsd.jieling.handler.gift;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 穿脱礼物装备
|
||||
*/
|
||||
@Component
|
||||
public class GiftEquipWearHandler extends BaseHandler<HeroInfoProto.GiftEquipWearRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GiftEquipWearRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.GiftEquipWearRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().wearGiftEquip(iSession, proto);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.ljsd.jieling.handler.gift;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 礼物装备升星
|
||||
*/
|
||||
@Component
|
||||
public class GiftUpStarEquipHandler extends BaseHandler<HeroInfoProto.GiftEquipUpStarRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GiftEquipUpStarRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.GiftEquipUpStarRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().giftUpStar(iSession, proto);
|
||||
}
|
||||
}
|
|
@ -72,6 +72,8 @@ public class Hero extends MongoBase implements Cloneable, Serializable {
|
|||
|
||||
private int totemId; //使用的 图腾ID
|
||||
|
||||
private Set<Integer> heroGiftEquipList = new HashSet<>();//礼物装备列表
|
||||
|
||||
public static class PosToMedal {
|
||||
public Integer siteType;
|
||||
public Integer medalId;
|
||||
|
@ -125,6 +127,7 @@ public class Hero extends MongoBase implements Cloneable, Serializable {
|
|||
combatPlanMap = new HashMap<>(2);
|
||||
medalMap = new HashMap<>(4);
|
||||
this.adjustByPositionMap = hero.adjustByPositionMap;
|
||||
this.heroGiftEquipList = new HashSet<>(hero.getHeroGiftEquipList());
|
||||
}
|
||||
|
||||
public Hero(int uid, int heroTid, int initStar) {
|
||||
|
@ -656,4 +659,18 @@ public class Hero extends MongoBase implements Cloneable, Serializable {
|
|||
", force=" + force +
|
||||
'}';
|
||||
}
|
||||
|
||||
public void setHeroGiftEquipList(Set<Integer> heroGiftEquipList) {
|
||||
this.heroGiftEquipList = heroGiftEquipList;
|
||||
updateString("heroGiftEquipList", heroGiftEquipList);
|
||||
}
|
||||
|
||||
public void addHeroGiftEquip(int giftEquip) {
|
||||
this.heroGiftEquipList.add(giftEquip);
|
||||
updateString("heroGiftEquipList", heroGiftEquipList);
|
||||
}
|
||||
|
||||
public Set<Integer> getHeroGiftEquipList() {
|
||||
return heroGiftEquipList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ public class PlayerManager extends MongoBase {
|
|||
*/
|
||||
private Date nextDailyRefreshTime = TimeUtils.Greenwich_Time;
|
||||
|
||||
private Set<Integer> playerGiftEquipList = new HashSet<>();//礼物装备列表
|
||||
|
||||
/**
|
||||
* 获取下次日刷新时间
|
||||
* @return
|
||||
|
@ -1374,4 +1376,17 @@ public class PlayerManager extends MongoBase {
|
|||
updateString("isGoogleCommentReward",isGoogleCommentReward);
|
||||
}
|
||||
|
||||
public Set<Integer> getPlayerGiftEquipList() {
|
||||
return playerGiftEquipList;
|
||||
}
|
||||
|
||||
public void setPlayerGiftEquipList(Set<Integer> playerGiftEquipList) {
|
||||
this.playerGiftEquipList = playerGiftEquipList;
|
||||
updateString("playerGiftEquipList", playerGiftEquipList);
|
||||
}
|
||||
|
||||
public void addPlayerGiftEquip(int giftEquip) {
|
||||
this.playerGiftEquipList.add(giftEquip);
|
||||
updateString("playerGiftEquipList", playerGiftEquipList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ import org.springframework.util.CollectionUtils;
|
|||
import util.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -3071,6 +3072,9 @@ public class HeroLogic {
|
|||
|
||||
}
|
||||
|
||||
// 礼物装备加成
|
||||
applyGiftEquipAttribute(heroAllAttribute, hero, user);
|
||||
|
||||
//被动技能加成
|
||||
Set<Integer> passiveskillEffect = new HashSet<>();
|
||||
List<Integer> heroSkillList = HeroLogic.getInstance().getHeroSkillList(user, hero);
|
||||
|
@ -6263,4 +6267,217 @@ public class HeroLogic {
|
|||
ret.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 穿脱礼物装备
|
||||
*/
|
||||
public void wearGiftEquip(ISession iSession, HeroInfoProto.GiftEquipWearRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int operate = proto.getOperate();
|
||||
String role = proto.getRole();
|
||||
List<Integer> giftIds = proto.getGiftIdsList();
|
||||
HashSet<Integer> set = new HashSet<>(giftIds);
|
||||
if (set.size() != giftIds.size()){
|
||||
String format = MessageFormat.format("gift error, gift has equip, uid:{0},list:{1}", user.getId(), giftIds);
|
||||
throw new ErrorCodeException("format");
|
||||
}
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
int[][] items = ToolsUtil.convertListTo2DArray(giftIds);
|
||||
if (operate == 1){
|
||||
// 穿戴
|
||||
boolean checked = ItemUtil.checkCostLong(user, items, 1);
|
||||
if (!checked){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
if (role.equals("0")){
|
||||
// 主角礼物
|
||||
Set<Integer> playerGifts = playerManager.getPlayerGiftEquipList();
|
||||
if (hasDuplicates(playerGifts, set)){
|
||||
String format = MessageFormat.format("gift error, gift has equip,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, playerGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
playerGifts.addAll(giftIds);
|
||||
playerManager.setPlayerGiftEquipList(playerGifts);
|
||||
}else {
|
||||
// 英雄礼物
|
||||
Hero hero = heroManager.getHero(role);
|
||||
if (hero == null){
|
||||
String format = MessageFormat.format("hero_gift error, hero not exist,uid:{0},role:{1}", user.getId(), role);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
Set<Integer> heroGifts = hero.getHeroGiftEquipList();
|
||||
if (hasDuplicates(heroGifts, set)){
|
||||
String format = MessageFormat.format("hero_gift error, hero has equip,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, heroGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
// int boxNum = getHeroGiftBoxNum(user);
|
||||
// if (heroGifts.size() + set.size() > boxNum){
|
||||
// String format = MessageFormat.format("礼物穿戴报错, 英雄礼物超出格子数量,uid:{0},wear:{1}, allow:{2}", user.getId(), heroGifts.size() + set.size(), boxNum);
|
||||
// throw new ErrorCodeException(format);
|
||||
// }
|
||||
int templateId = hero.getTemplateId();
|
||||
SCHero scHero = SCHero.getsCHero().get(templateId);
|
||||
if (scHero == null){
|
||||
String format = MessageFormat.format("hero_gift error hero not exist,uid:{0},id:{1}", user.getId(), templateId);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
Map<Integer, SEquipConfig> equipConfig = SEquipConfig.configMap;
|
||||
for (Integer id : set) {
|
||||
SEquipConfig config = equipConfig.get(id);
|
||||
if (config == null){
|
||||
String format = MessageFormat.format("hero_gift error, config not exist,uid:{0},id:{1}", user.getId(), id);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
if (config.getRangeHeroTids() != null && !config.getRangeHeroTids().contains(templateId)){
|
||||
String format = MessageFormat.format("hero_gift error, hero cannot eqip this gift,uid:{0},id:{1},hero:{2}", user.getId(), id, scHero.getId());
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
//暂时不做职业限制
|
||||
// boolean profession = EquipLogic.getInstance().verifyEquipProfessionLimit(templateId, id);
|
||||
// if (!profession){
|
||||
// throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH,"职业不满足条件:"+id);
|
||||
// }
|
||||
}
|
||||
heroGifts.addAll(giftIds);
|
||||
hero.setHeroGiftEquipList(heroGifts);
|
||||
}
|
||||
ItemUtil.itemCost(user, items, BIReason.GIFT_EQUIP_UP_COST ,1);
|
||||
}
|
||||
else {// 脱下
|
||||
// 主角礼物
|
||||
if (role.equals("0")){
|
||||
Set<Integer> playerGifts = playerManager.getPlayerGiftEquipList();
|
||||
if (!playerGifts.containsAll(set)){
|
||||
String format = MessageFormat.format("gift error gift not exist,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, playerGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
playerGifts.removeAll(set);
|
||||
playerManager.setPlayerGiftEquipList(playerGifts);
|
||||
}
|
||||
else {
|
||||
// 英雄礼物
|
||||
Hero hero = heroManager.getHero(role);
|
||||
if (hero == null){
|
||||
String format = MessageFormat.format("hero_gift error, hero not exist,uid:{0},role:{1}", user.getId(), role);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
Set<Integer> heroGifts = hero.getHeroGiftEquipList();
|
||||
if (!heroGifts.containsAll(set)){
|
||||
String format = MessageFormat.format("hero_gift error, hero_gift not exist,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, heroGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
heroGifts.removeAll(set);
|
||||
hero.setHeroGiftEquipList(heroGifts);
|
||||
}
|
||||
|
||||
ItemUtil.drop(user, items, BIReason.GIFT_EQUIP_DOWN_REWARD);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GiftEquipWearResponse_VALUE, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否满足装备条件,id或者类型重复
|
||||
* @param playerGift 玩家身上的
|
||||
* @param clientGift 想要装备的
|
||||
* @return true 不行 false 可以
|
||||
*/
|
||||
public static boolean hasDuplicates(Set<Integer> playerGift, Set<Integer> clientGift) {
|
||||
HashSet<Integer> set = new HashSet<>(playerGift);
|
||||
Map<Integer, SEquipConfig> configMap = SEquipConfig.configMap;
|
||||
// 验证添加的礼物是否重复装备过
|
||||
for (Integer id : clientGift) {
|
||||
if (set.contains(id)){
|
||||
LOGGER.error("玩家装备的礼物已装备过了 id:{}",id);
|
||||
return true;
|
||||
}
|
||||
set.add(id);
|
||||
}
|
||||
|
||||
for (Integer nextId : set) {
|
||||
SEquipConfig playerConfig = configMap.get(nextId);
|
||||
if (playerConfig == null){
|
||||
LOGGER.error("玩家身上有不存在配置表中的礼物id:{}",nextId);
|
||||
continue;
|
||||
}
|
||||
for (Integer id : clientGift) {
|
||||
if (id.equals(nextId)){
|
||||
continue;
|
||||
}
|
||||
SEquipConfig notConfig = configMap.get(id);
|
||||
if (notConfig == null){
|
||||
LOGGER.error("玩家装备的礼物不存在于配置表 id:{}",id);
|
||||
return true;
|
||||
}
|
||||
if ((notConfig.getSuiteID() != 0 && notConfig.getSuiteID() == playerConfig.getSuiteID())){
|
||||
LOGGER.error("玩家装备的礼物类型配置重复 id:{}",id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼物升星
|
||||
*/
|
||||
public void giftUpStar(ISession iSession, HeroInfoProto.GiftEquipUpStarRequest proto) throws Exception{
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int giftId = proto.getGiftId();
|
||||
SEquipConfig config = SEquipConfig.configMap.get(giftId);
|
||||
if (config == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
ArrayList<int[][]> costList = new ArrayList<>();
|
||||
costList.add(config.getFormula());
|
||||
costList.add(config.getResource());
|
||||
boolean cost = ItemUtil.checkCost(user, costList);
|
||||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{giftId, 1}}, BIReason.GIFT_UP_STAR_GET);
|
||||
ItemUtil.itemCost(user, costList, BIReason.GIFT_UP_STAR_COST, 0);
|
||||
HeroInfoProto.GiftEquipUpStarResponse.Builder builder = HeroInfoProto.GiftEquipUpStarResponse.newBuilder().setDrop(drop);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GiftEquipUpStarResponse_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼物装备属性加成
|
||||
*
|
||||
* @param heroAllAttribute
|
||||
* @param hero
|
||||
* @param user
|
||||
*/
|
||||
private void applyGiftEquipAttribute(Map<Integer, Long> heroAllAttribute, Hero hero, User user) {
|
||||
// ... 礼物装备 ...
|
||||
HashMap<Integer, Integer> giftAttrMap = new HashMap<>();
|
||||
Map<Integer, SEquipConfig> configMap = SEquipConfig.configMap;
|
||||
// 主角礼物(命石)属性计算
|
||||
Set<Integer> playerGiftEquipList = user.getPlayerInfoManager().getPlayerGiftEquipList();
|
||||
for (Integer id : playerGiftEquipList) {
|
||||
SEquipConfig config = configMap.get(id);
|
||||
if (config == null) {
|
||||
continue;
|
||||
}
|
||||
if (config.getProperty() != null) {
|
||||
for (int[] ints : config.getProperty()) {
|
||||
giftAttrMap.put(ints[0], giftAttrMap.getOrDefault(ints[0], 0) + ints[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 英雄礼物属性计算
|
||||
Set<Integer> heroGiftEquipList = hero.getHeroGiftEquipList();
|
||||
for (Integer id : heroGiftEquipList) {
|
||||
SEquipConfig config = configMap.get(id);
|
||||
if (config == null || config.getProperty() == null) {
|
||||
continue;
|
||||
}
|
||||
for (int[] ints : config.getProperty()) {
|
||||
giftAttrMap.put(ints[0], giftAttrMap.getOrDefault(ints[0], 0));
|
||||
}
|
||||
}
|
||||
|
||||
combinedAttribute(giftAttrMap, heroAllAttribute);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2224,4 +2224,34 @@ public class ItemUtil {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkCostLong(User user, int[][] itemList, int num) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
selectCost(itemList,itemMap,num);
|
||||
return checkCost(user, itemMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗道具
|
||||
*/
|
||||
public static boolean itemCost(User user,List<int[][]> itemArrs,int reason,int subReson) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
for(int[][] itemArr : itemArrs){
|
||||
selectCost(itemArr,itemMap);
|
||||
}
|
||||
boolean result = checkCost(user, itemMap);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
useItem(user, itemMap,reason,subReson);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean checkCost(User user, List<int[][]> item) throws Exception {
|
||||
HashMap<Integer, Integer> itemMap = new HashMap<>();
|
||||
for (int[][] ints : item) {
|
||||
selectCost(ints,itemMap);
|
||||
}
|
||||
return checkCost(user,itemMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import util.TimeUtils;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToolsUtil {
|
||||
|
@ -78,6 +79,25 @@ public class ToolsUtil {
|
|||
// return startTime;
|
||||
// }
|
||||
|
||||
/**
|
||||
* list转二位数组
|
||||
*/
|
||||
public static int[][] convertListTo2DArray(List<Integer> list) {
|
||||
int[][] array2D = new int[list.size()][2];
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
int num = list.get(i);
|
||||
|
||||
// 创建一个新的一维数组,并将数值添加到数组中
|
||||
int[] newArray = {num, 1};
|
||||
|
||||
// 将新的一维数组添加到二维数组中
|
||||
array2D[i] = newArray;
|
||||
}
|
||||
|
||||
return array2D;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue