back_recharge
wangyuan 2019-01-22 09:46:37 +08:00
parent 38080b502e
commit be088a61f9
2 changed files with 27 additions and 17 deletions

View File

@ -11,8 +11,8 @@ import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import org.apache.commons.lang.math.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -69,7 +69,7 @@ public class HeroLogic {
int[] poolWeightInfo = diamondBoxContain[i];
totalWeight += poolWeightInfo[1];
}
int randWeight = RandomUtils.nextInt(totalWeight) + 1;
int randWeight = MathUtils.randomInt(totalWeight) + 1;
int weight = 0;
for(int i=0;i<diamondBoxContain.length;i++){
int[] poolWeightInfo = diamondBoxContain[i];
@ -140,7 +140,7 @@ public class HeroLogic {
List<SLotteryRewardConfig> sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId);
int totalCountByPoolId = SLotteryRewardConfig.getTotalCountByPoolId(poolId);
int randCount = RandomUtils.nextInt(totalCountByPoolId) + 1;
int randCount = MathUtils.randomInt(totalCountByPoolId) + 1;
int weight =0;
for(SLotteryRewardConfig sLotteryRewardConfig :sLotteryRewardConfigListByPoolId){
weight += sLotteryRewardConfig.getWeight();
@ -154,42 +154,45 @@ public class HeroLogic {
}
public String extraReward(SLotterySetting sLotterySetting){
if(sLotterySetting.getTenTimesMustGetItem()!=null){
if(sLotterySetting.getTenTimesMustGetItem()!=null &&sLotterySetting.getTenTimesMustGetItem().length>0){
int[] tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem();
return tenTimesMustGetItem[0] + "#" + tenTimesMustGetItem[1];
// tenTimesMustGetItem
}
return "";
}
public void saveTeamPos(int uid,int teamId,List<String> heroIds ,List<Integer> pokenIds) throws Exception {
User user = UserManager.getUser(uid);
user.getTeamPosManager().changeTeamInfo(teamId,heroIds,pokenIds);
public void saveTeamPos(ISession iSession,int teamId,List<String> heroIds ,List<Integer> pokemonoIds) throws Exception {
User user = UserManager.getUser(iSession.getUid());
String err = checkTeamPos(user, teamId, heroIds);
if(!"".equals(err)){
MessageUtil.sendMessage(iSession,0,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,null,true);
return;
}
user.getTeamPosManager().changeTeamInfo(teamId,heroIds,pokemonoIds);
}
public boolean checkTeamPos(User user,int teamId,List<String> heroIds){
public String checkTeamPos(User user,int teamId,List<String> heroIds){
if(heroIds ==null || heroIds.isEmpty()){
return false;
return "";
}
Set<String> cacheHeroIds = new HashSet<>();
Collection<List<String>> values = user.getTeamPosManager().getTeamPosForHero().values();
for(String heroId : heroIds){
if(user.getHeroManager().getHero(heroId) == null) {
// 卡牌不存在
return false;
return "card not exists";
}
// 卡牌重复
if(cacheHeroIds.contains(heroId)){
return false;
return "card repeated";
}
// 卡牌已上阵
if(values.contains(heroId)){
return false;
return "card has already in teampos";
}
cacheHeroIds.add(heroId);
}
return true;
return "";
}

View File

@ -5,6 +5,8 @@ import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.PackageConstant;
import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -68,8 +70,13 @@ public class MessageUtil {
session.writeAndFlush(byteBuf);
}
public static void sendErrorCode(ISession session) {
public static void sendErrorCode(ISession session,int result,int msgId,String errMsg) throws Exception {
if(StringUtils.isEmpty(errMsg)){
sendMessage(session, result, msgId, null, true);
}else{
PlayerInfoProto.ErrorMsgResponse build = PlayerInfoProto.ErrorMsgResponse.newBuilder().setMsg(errMsg).build();
sendMessage(session, result, msgId, build, true);
}
}