抽卡校验消耗

back_recharge
wangyuan 2019-01-25 18:33:38 +08:00
parent 887183aac8
commit 4f45aa9c5d
4 changed files with 29 additions and 13 deletions

View File

@ -1,6 +1,6 @@
Id OrderBoxOpenTime OrderBoxContinue OrderBoxInterval OrderBoxPool DiamondBoxInterval Cost GetHerosInterval DiamondBoxContain TenTimesMustGetItem PerCount Id OrderBoxOpenTime OrderBoxContinue OrderBoxInterval OrderBoxPool DiamondBoxInterval CostItem GetHerosInterval DiamondBoxContain TenTimesMustGetItem PerCount
int int int int mut,int#int,1 int mut,int#int,1 int mut,int#int,2 mut,int#int,2 int int int int int mut,int#int,1 int mut,int#int,1 int mut,int#int,2 mut,int#int,2 int
1 56 48 120 11#12#13#14 0 3#10 0 null null 10 1 56 48 120 11#12#13#14 0 20#10 0 null null 10
2 56 48 120 11#12#13#14 0 3#1 0 null null 1 2 56 48 120 11#12#13#14 0 20#1 0 null null 1
11 0 0 0 null 0 220 150 1#100 3#1 10 11 0 0 0 null 0 19#10 150 1#100 3#1 10
12 0 0 0 null 2160 2200 0 1#100 null 1 12 0 0 0 null 2160 19#1 0 1#100 null 1

View File

@ -28,6 +28,8 @@ public class SLotterySetting implements BaseConfig {
private int[][] tenTimesMustGetItem; private int[][] tenTimesMustGetItem;
private int[] costItem;
private int perCount; private int perCount;
private static Map<Integer,SLotterySetting> sLotterySettingByType; private static Map<Integer,SLotterySetting> sLotterySettingByType;
@ -89,5 +91,7 @@ public class SLotterySetting implements BaseConfig {
return perCount; return perCount;
} }
public int[] getCostItem() {
return costItem;
}
} }

View File

@ -28,10 +28,11 @@ public class HeroLogic {
} }
public void random(ISession session,int type) throws Exception { public void random(ISession session,int type) throws Exception {
int uid = session.getUid(); int uid = session.getUid();
User user = UserManager.getUser(uid);
SLotterySetting sLotterySetting = SLotterySetting.getsLotterySettingMap().get(type); SLotterySetting sLotterySetting = SLotterySetting.getsLotterySettingMap().get(type);
//检验消耗
//筛选卡池 //筛选卡池
StringBuilder reward = new StringBuilder(); StringBuilder reward = new StringBuilder();
@ -40,8 +41,21 @@ public class HeroLogic {
boolean isSpecial = false; boolean isSpecial = false;
if(sLotterySetting.getOrderBoxPool()!=null && sLotterySetting.getOrderBoxPool().length>0){ if(sLotterySetting.getOrderBoxPool()!=null && sLotterySetting.getOrderBoxPool().length>0){
pooId = getOrderBoxPoolId(sLotterySetting); pooId = getOrderBoxPoolId(sLotterySetting);
if(pooId == 0){
MessageUtil.sendErrorResponse(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE,"");
return;
}
isSpecial = true; isSpecial = true;
} }
//检验消耗
int [][] costItems = new int[][]{sLotterySetting.getCostItem()};
boolean enoughCost = ItemUtil.itemCost(user, costItems);
if(!enoughCost){
MessageUtil.sendErrorResponse(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE,"道具不足");
return;
}
for(int i=0;i<perCount;i++){ for(int i=0;i<perCount;i++){
if(!isSpecial){ if(!isSpecial){
pooId = getPooId(sLotterySetting, pooId); pooId = getPooId(sLotterySetting, pooId);
@ -52,7 +66,7 @@ public class HeroLogic {
//额外获取 //额外获取
reward.append( extraReward(sLotterySetting)); reward.append( extraReward(sLotterySetting));
User user = UserManager.getUser(uid);
HeroInfoProto.HeroRandResponse heroRandResponse = addItem(user, reward.toString()); HeroInfoProto.HeroRandResponse heroRandResponse = addItem(user, reward.toString());
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, heroRandResponse, true); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, heroRandResponse, true);
@ -111,8 +125,6 @@ public class HeroLogic {
} }
builder.addAllHeroList(heros); builder.addAllHeroList(heros);
builder.addAllItemList(items); builder.addAllItemList(items);
//todo 为了测试 日后要删掉
UserManager.ljsdMongoTemplate.lastUpdate();
return builder.build(); return builder.build();
} }
@ -122,8 +134,8 @@ public class HeroLogic {
int orderBoxContinue = sLotterySetting.getOrderBoxContinue(); int orderBoxContinue = sLotterySetting.getOrderBoxContinue();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
ServerConfig serverConfig = GameApplication.serverConfig; ServerConfig serverConfig = GameApplication.serverConfig;
int diffHours = (int)((now - serverConfig.getCacheOpenTime())%( (orderBoxContinue + orderBoxContinue) * 1000*60*60)); int diffHours = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60%( (orderBoxContinue + orderBoxContinue)));
int diffSeaseon = (int)((now - serverConfig.getCacheOpenTime())/( (orderBoxContinue + orderBoxContinue) * 1000*60*60)); int diffSeaseon = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60/( (orderBoxContinue + orderBoxContinue)));
if(diffHours<=orderBoxOpenTime){ if(diffHours<=orderBoxOpenTime){
return orderBoxPool[diffSeaseon%orderBoxPool.length]; return orderBoxPool[diffSeaseon%orderBoxPool.length];
} }

View File

@ -88,7 +88,7 @@ public class MessageUtil {
if(errorCode!=1 && !StringUtil.isEmpty(errMsg)){ if(errorCode!=1 && !StringUtil.isEmpty(errMsg)){
generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build(); generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build();
} }
LOGGER.error("send error msg,the uid={},the msgId={},the errMsg={}",session.getId(),msgId,errMsg); LOGGER.error("send error msg,the uid={},the msgId={},the errMsg={}",session.getUid(),msgId,errMsg);
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(), byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
errorCode,msgId, generatedMessage); errorCode,msgId, generatedMessage);
session.writeAndFlush(byteBuf); session.writeAndFlush(byteBuf);