公会技能升级修改,道具数量改long
parent
7c536a5c08
commit
7cda83d0f0
|
@ -19,7 +19,13 @@ class StaminaExpectRankActivity extends ExpectRankActivity {
|
|||
public void onEvent(IEvent event) throws Exception {
|
||||
if (!(event instanceof UseItemEvent))
|
||||
return;
|
||||
int changeNum = ((UseItemEvent) event).getUseItemMap().getOrDefault(Global.STAMINA, 0);
|
||||
update(UserManager.getUser(((UseItemEvent) event).getUseId()), changeNum);
|
||||
UseItemEvent event1 = (UseItemEvent) event;
|
||||
// 只获取体力的消耗
|
||||
Long aLong = event1.getUseItemMap().getOrDefault(Global.STAMINA, 0L);
|
||||
if (aLong > Integer.MAX_VALUE){
|
||||
LOGGER.error("体力消耗数量大于int最大值,需要修改数据库活动功能存储相关参数");
|
||||
return;
|
||||
}
|
||||
update(UserManager.getUser(((UseItemEvent) event).getUseId()), aLong.intValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,14 @@ import java.util.Map;
|
|||
public class UseItemEvent implements IEvent {
|
||||
|
||||
private int useId;
|
||||
Map<Integer, Integer> useItemMap;
|
||||
Map<Integer, Long> useItemMap;
|
||||
|
||||
public UseItemEvent(int useId, Map<Integer, Integer> useItemMap) {
|
||||
public UseItemEvent(int useId, Map<Integer, Long> useItemMap) {
|
||||
this.useId = useId;
|
||||
this.useItemMap = useItemMap;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getUseItemMap() {
|
||||
public Map<Integer, Long> getUseItemMap() {
|
||||
return useItemMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -1530,7 +1530,7 @@ public class GuildLogic {
|
|||
}
|
||||
int size = typeMap.size();
|
||||
|
||||
Map<Integer,Integer> consumeMap = new HashMap<>(2);
|
||||
Map<Integer,Long> consumeMap = new HashMap<>(2);
|
||||
int baseLevel = beforeLevel / size;//100->16
|
||||
int nextIndex = beforeLevel % size;//100->4
|
||||
|
||||
|
@ -1541,29 +1541,26 @@ public class GuildLogic {
|
|||
// 消耗道具获取
|
||||
int[][] consume = typeMap.get(nextIndex+1).get(baseLevel).getConsume();
|
||||
for(int[] consumeOnce:consume) {
|
||||
consumeMap.put(consumeOnce[0],consumeMap.getOrDefault(consumeOnce[0], 0)+consumeOnce[1]);
|
||||
consumeMap.put(consumeOnce[0],consumeMap.getOrDefault(consumeOnce[0], 0L)+consumeOnce[1]);
|
||||
}
|
||||
// 道具消耗
|
||||
boolean itemCost = ItemUtil.itemCost(user, ItemUtil.mapToArray(consumeMap), BIReason.GUILD_SKILL_LEVEL_UP_CONSUME, 1);
|
||||
if(!itemCost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
// 清理道具map
|
||||
consumeMap.clear();
|
||||
// 次数增加
|
||||
if(nextIndex+1==size){
|
||||
nextIndex=0;
|
||||
baseLevel++;
|
||||
}else{
|
||||
}
|
||||
nextIndex++;
|
||||
}
|
||||
|
||||
// 道具消耗
|
||||
boolean itemCost = ItemUtil.itemCostLong(user, consumeMap, BIReason.GUILD_SKILL_LEVEL_UP_CONSUME, 1);
|
||||
if(!itemCost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
Family.GuildSkillLevelUpResponse response = Family.GuildSkillLevelUpResponse.newBuilder().setType(type).setCurlevel(baseLevel*size+nextIndex).build();
|
||||
|
||||
user.getGuildMyInfo().setGuildSkillByType(type,baseLevel*size+nextIndex);
|
||||
|
||||
int count = baseLevel * size + nextIndex;
|
||||
user.getGuildMyInfo().setGuildSkillByType(type,count);
|
||||
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
|
||||
|
||||
Family.GuildSkillLevelUpResponse response = Family.GuildSkillLevelUpResponse.newBuilder().setType(type).setCurlevel(count).build();
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,15 +30,14 @@ import com.ljsd.jieling.logic.player.PlayerLogic;
|
|||
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import config.SGameSetting;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.MathUtils;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
@ -1028,6 +1027,12 @@ public class ItemUtil {
|
|||
}
|
||||
|
||||
private static void useItem(User user,Map<Integer,Integer> useItemMap,int reason,int subReason) throws Exception{
|
||||
HashMap<Integer, Long> longMap = new HashMap<>();
|
||||
useItemMap.forEach((k,v)->longMap.put(k,v.longValue()));
|
||||
useItemLong(user,longMap,reason,subReason);
|
||||
}
|
||||
|
||||
private static void useItemLong(User user,Map<Integer,Long> useItemMap,int reason,int subReason) throws Exception{
|
||||
if(useItemMap.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
@ -1039,7 +1044,7 @@ public class ItemUtil {
|
|||
}
|
||||
List<CommonProto.Item> sendToFront = new ArrayList<>();
|
||||
List<CommonProto.Item> sendTemToFront = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> userItem : useItemMap.entrySet()) {
|
||||
for (Map.Entry<Integer, Long> userItem : useItemMap.entrySet()) {
|
||||
Item temporaryItem = temporaryItemList.get(userItem.getKey());
|
||||
long needCount = userItem.getValue();
|
||||
if (temporaryItem != null) {
|
||||
|
@ -1058,22 +1063,15 @@ public class ItemUtil {
|
|||
if (null == myItem) {
|
||||
continue;
|
||||
}
|
||||
// int eventType = ParamEventBean.UserItemEvent;
|
||||
// if(currencyMap.contains(myItem.getItemId())){
|
||||
// eventType = ParamEventBean.UserCurrencyEvent;
|
||||
// }
|
||||
|
||||
if (myItem.getItemNum() <= needCount && !STableManager.getFigureConfig(CommonStaticConfig.class).getNotDelete().contains(userItem.getKey())) {
|
||||
ReportUtil.onReportEvent(user,ReportEventEnum.COST_ITEM.getType(),myItem.getItemNum(),String.valueOf(reason),String.valueOf(myItem.getItemId()));
|
||||
baseItemReport(user,myItem.getItemId(),(int)myItem.getItemNum(),2,reason);
|
||||
myItem.setItemNum(0);
|
||||
itemManager.removeItem(userItem.getKey());
|
||||
// KtEventUtils.onKtEvent(user, eventType,reason,GlobalsDef.subReason,myItem.getItemId(),needCount,0,subReason);
|
||||
} else {
|
||||
ReportUtil.onReportEvent(user,ReportEventEnum.COST_ITEM.getType(),needCount,String.valueOf(reason),String.valueOf(myItem.getItemId()));
|
||||
baseItemReport(user,myItem.getItemId(),(int)needCount,2,reason);
|
||||
myItem.setItemNum(myItem.getItemNum() - needCount);
|
||||
// KtEventUtils.onKtEvent(user, eventType,reason,GlobalsDef.subReason,myItem.getItemId(),needCount,myItem.getItemNum(),subReason);
|
||||
}
|
||||
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),1,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,myItem.getItemId(),needCount,myItem.getItemNum()));
|
||||
|
||||
|
@ -1409,6 +1407,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 itemCost(User user,int[][] costItems,int times,int reason,int subReason) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
selectCost(costItems,itemMap,times);
|
||||
|
@ -1421,6 +1428,12 @@ public class ItemUtil {
|
|||
}
|
||||
|
||||
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()));
|
||||
return checkCostLong(user,longMap);
|
||||
}
|
||||
|
||||
public static boolean checkCostLong(User user, Map<Integer, Long> itemMap) throws Exception {
|
||||
if (itemMap == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1429,30 +1442,33 @@ public class ItemUtil {
|
|||
if (temporaryItems != null) {
|
||||
temporaryItemList = temporaryItems.items;
|
||||
}
|
||||
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
|
||||
Item temporaryItem = temporaryItemList.get(entry.getKey());
|
||||
if (temporaryItem == null || temporaryItem.getItemNum() < entry.getValue()) {
|
||||
if ((entry.getKey() == Global.STAMINA)){
|
||||
for (Map.Entry<Integer, Long> entry : itemMap.entrySet()) {
|
||||
int key = entry.getKey();
|
||||
long value = entry.getValue();
|
||||
|
||||
Item temporaryItem = temporaryItemList.get(key);
|
||||
if (temporaryItem == null || temporaryItem.getItemNum() < key) {
|
||||
if (key == Global.STAMINA){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if (STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getItemRecoveryMap().containsKey(entry.getKey()) ){
|
||||
MapManager.getTimesRecoveryTicket(user,entry.getKey());
|
||||
if (STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getItemRecoveryMap().containsKey(key)){
|
||||
MapManager.getTimesRecoveryTicket(user,key);
|
||||
}
|
||||
Item item = user.getItemManager().getItem(entry.getKey());
|
||||
Item item = user.getItemManager().getItem(key);
|
||||
if (item == null) {
|
||||
if(entry.getValue()==0){
|
||||
if(value==0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (entry.getValue() < 0) {
|
||||
LOGGER.info("checkCost uid=>{} use negative item itemId=>{} count=>{}", user.getId(), entry.getKey(), entry.getValue());
|
||||
if (value < 0) {
|
||||
LOGGER.info("checkCost uid=>{} use negative item itemId=>{} count=>{}", user.getId(), key, value);
|
||||
return false;
|
||||
}
|
||||
if (temporaryItem == null && item.getItemNum() < entry.getValue()) {
|
||||
if (temporaryItem == null && item.getItemNum() < value) {
|
||||
return false;
|
||||
}
|
||||
if (temporaryItem != null && temporaryItem.getItemNum() + item.getItemNum() < entry.getValue()) {
|
||||
if (temporaryItem != null && temporaryItem.getItemNum() + item.getItemNum() < value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue