消耗增加负值判断

back_recharge
jiahuiwen 2020-09-04 10:31:21 +08:00
parent c3aa0b815f
commit b5feff687e
8 changed files with 31 additions and 14 deletions

View File

@ -57,7 +57,7 @@ public class FamilyFeteRequestHandler extends BaseHandler<Family.FamilyFeteReque
}
//check cost
boolean enough = ItemUtil.itemCost(user, sGuildSacrificeConfig.getExpend(), BIReason.FETE_CONSUME, 0);
boolean enough = ItemUtil.itemCost(user, sGuildSacrificeConfig.getExpend(), BIReason.FETE_CONSUME, type);
if (!enough) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}

View File

@ -349,12 +349,12 @@ public class EndlessMap extends AbstractMap{
mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution()+costNum);
int [] cost1 = new int[]{costId,costNum};
cost[0] = cost1;
boolean costResult = ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1);
boolean costResult = ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, mapManager.getCurMapId());
if(!costResult) {
costNum = user.getItemManager().getItem(costId).getItemNum();
cost1[1]= costNum;
cost[0] = cost1;
ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,1);
ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,mapManager.getCurMapId());
}
}

View File

@ -909,8 +909,8 @@ public class ActivityLogic implements IEventHandler{
temp[0] = costConfig[0][0];
temp[1] = (int) MathUtils.calABX(activityProgressInfoMap.get(BlessInfoConfig.BLESS_PROGRESS_STATUS).getProgrss(), costConfig[1]);
cost[0] = temp;
LOGGER.info("本次为第{}次抽取,消耗{}个数为{}", activityProgressInfoMap.get(BlessInfoConfig.BLESS_PROGRESS_STATUS).getProgrss(), temp[0], temp[1]);
boolean costResult = ItemUtil.itemCost(user, cost, BIReason.BLESS_CHOOSE_CONSUME, 1);
LOGGER.info("blessChoose uid=>{} 本次为第{}次抽取,消耗{}个数为{}", user.getId(), activityProgressInfoMap.get(BlessInfoConfig.BLESS_PROGRESS_STATUS).getProgrss(), temp[0], temp[1]);
boolean costResult = ItemUtil.itemCost(user, cost, BIReason.BLESS_CHOOSE_CONSUME, locationId);
if (!costResult) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
@ -930,7 +930,7 @@ public class ActivityLogic implements IEventHandler{
break;
}
}
LOGGER.info("本次抽取的Id为{}", resultRewardId);
LOGGER.info("blessChoose uid=>{}本次抽取的Id为{}", user.getId(), resultRewardId);
Map<Integer, SBlessingRewardPool> poolMap = STableManager.getConfig(SBlessingRewardPool.class);
int[][] dropItem = new int[1][];
for (Integer count : SBlessingConfig.blessingConfigMap.get(blessActivityId).getCounts()) {
@ -1266,7 +1266,7 @@ public class ActivityLogic implements IEventHandler{
int[][] costItems = new int[1][];
int[] costTemp = {cost[0][0],num};
costItems[0]=costTemp;
boolean result = ItemUtil.itemCost(user,costItems,BIReason.TREASURE_BUY_LEVEL_CONSUME,1);
boolean result = ItemUtil.itemCost(user,costItems,BIReason.TREASURE_BUY_LEVEL_CONSUME, level);
if(result) {
user.getPlayerInfoManager().setTreasureLevel(level);
}else{

View File

@ -411,7 +411,7 @@ public class ChampionshipLogic {
costs[0] = new int[2];
costs[0][0] = arenaItemId;
costs[0][1] = itemNum;
ItemUtil.itemCost(user, costs, BIReason.CHAMPIONM_EXCHANGE_CONSUME, 0);
ItemUtil.itemCost(user, costs, BIReason.CHAMPIONM_EXCHANGE_CONSUME, sendId);
Map<Integer, Integer> itemReward = new HashMap<>(1);
itemReward.put(rewardItemId, itemNum / sChampionshipSetting.getExchangeItem());
ItemUtil.addItem(user, itemReward, null, BIReason.CHAMPIONM_EXCHANGE_REWARD);

View File

@ -783,6 +783,9 @@ public class HeroLogic{
}
for(;oldLevel<targetLevel;oldLevel++){
SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(oldLevel);
if (sHeroLevlConfig == null) {
break;
}
consume = sHeroLevlConfig.getConsume();
combinedAttribute(consume,consumeMap);
}
@ -1854,8 +1857,11 @@ public class HeroLogic{
for(String equipId : equipIds){
int equip = Integer.parseInt(equipId);
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equip);
if (sEquipConfig == null) {
return false;
}
int position = sEquipConfig.getPosition();
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{equip, 1}}, BIReason.EQUIP_WEAR_CONSUME, 1);
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{equip, 1}}, BIReason.EQUIP_WEAR_CONSUME, equip);
if(!itemCost){
return false;
}
@ -2011,6 +2017,9 @@ public class HeroLogic{
int itemId = item.getItemId();
int itemNum = item.getItemNum();
SItem sItem = SItem.getsItemMap().get(itemId);
if (sItem == null || itemNum <= 0 || itemNum >= Integer.MAX_VALUE) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int composeNum = itemNum/sItem.getUsePerCount();
SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting();
if (composeNum <= 0 || composeNum > gameSetting.getHeroCompoundLimit()){
@ -2019,7 +2028,7 @@ public class HeroLogic{
if (hasHeroNum + composeNum > gameSetting.getHeroNumlimit()){
throw new ErrorCodeException(ErrorCode.HERO_HERO_MAX);
}
boolean result = ItemUtil.checkCost(user, sItem, itemNum,BIReason.COMPOS_HERO_CONSUME,0);
boolean result = ItemUtil.checkCost(user, sItem, itemNum,BIReason.COMPOS_HERO_CONSUME,itemId);
if (!result){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}

View File

@ -6,6 +6,8 @@ import com.ljsd.jieling.ktbeans.sendbeans.ReportServerEvent;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
@ -18,6 +20,9 @@ import java.util.Set;
* @discribe
*/
public class OnlineUserReportTask extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(OnlineUserReportTask.class);
public OnlineUserReportTask(){
setName("OnlineUserReportTask");
}
@ -53,7 +58,7 @@ public class OnlineUserReportTask extends Thread {
properties.put("platform","DEFAULT_platform");
properties.put("#time",new Date());
ReportServerEvent reportServerEvent = new ReportServerEvent("online_user_amount",properties);
System.out.println(reportServerEvent.toString());
LOGGER.info("OnlineUserReportTask reportServerEvent=>{}", reportServerEvent.toString());
ReportUtil.doReport(reportServerEvent);
}catch (Exception e){
e.printStackTrace();

View File

@ -1261,7 +1261,10 @@ public class ItemUtil {
}
return false;
}
if (entry.getValue() <= 0) {
LOGGER.info("checkCost uid=>{} use negative item itemId=>{} count=>{}", user.getId(), entry.getKey(), entry.getValue());
return false;
}
if (temporaryItem == null && item.getItemNum() < entry.getValue()) {
return false;
}

View File

@ -39,7 +39,7 @@ public class MessageUtil {
} else {
backMessage = generatedMessage.toByteArray();
if (backMessage.length != 0)
LOGGER.info("\r\n" + "uid:" + uid + ":\r\n" + JsonFormat.printToString(generatedMessage));
LOGGER.info("wrappedBuffer uid=>{}, generatedMessage=>{}", uid, JsonFormat.printToString(generatedMessage));
}
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
@ -64,7 +64,7 @@ public class MessageUtil {
int[] secretKey = Tea.KEY;
byte[] bytes1 = Tea.encrypt2(bytes, secretKey);
if (backMessage.length != 0) {
LOGGER.info("sendbyte"+bytes1.length);
LOGGER.info("wrappedBuffer uid=>{} sendbyte=>{}", uid, bytes1.length);
}
return bytes1;
}