1、巅峰赛部分逻辑添加日志

2、巅峰赛冗余逻辑优化
3、user缓存计数功能暂时注释
back_recharge
duhui 2023-04-14 15:26:04 +08:00
parent 55d0d11ae1
commit db8974a8c8
6 changed files with 236 additions and 354 deletions

View File

@ -61,7 +61,6 @@ public class ChampinGetHandler extends BaseHandler {
Object latestKey = RedisUtil.getInstence().lGetIndex(key, -1); Object latestKey = RedisUtil.getInstence().lGetIndex(key, -1);
if(latestKey!=null) { if(latestKey!=null) {
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", latestKey.toString(), ArenaRecord.class); ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", latestKey.toString(), ArenaRecord.class);
int enemyId = arenaRecord.getDefUid();
int attackId = arenaRecord.getAttackId(); int attackId = arenaRecord.getAttackId();
int fightResult = arenaRecord.getFightResult(); int fightResult = arenaRecord.getFightResult();
int roundTims = arenaRecord.getRoundTims(); int roundTims = arenaRecord.getRoundTims();
@ -110,110 +109,31 @@ public class ChampinGetHandler extends BaseHandler {
} }
if(ChampionshipLogic.getProgress()==-2){ if(ChampionshipLogic.getProgress()==-2){
if(arenaRecord.getRoundTims()-7==5){ if(arenaRecord.getRoundTims()-7==5){
if(state==0&&attackId==uid){ builder.setLoser(state == 0 && attackId == uid);
builder.setLoser(true);
}else {
builder.setLoser(false);
}
}else { }else {
builder.setLoser(true); builder.setLoser(true);
} }
}else { }else {
if(schedule==2){ if(schedule==2){
if( roundTims - 7 != realTimes) { builder.setLoser(roundTims - 7 != realTimes);
builder.setLoser(true);
}else {
builder.setLoser(false);
}
}else if(schedule==1){ }else if(schedule==1){
if(roundTims!=roundTimes){ builder.setLoser(roundTims != roundTimes);
builder.setLoser(true);
}else {
builder.setLoser(false);
}
} }
} }
builder.setProcess(state); builder.setProcess(state);
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(arenaRecord.getAttackId()); CommonProto.TeamOneInfo.Builder myInfo = ChampionshipLogic.getUserTeam(arenaRecord.getAttackId());
if (sArenaRobotConfig != null) { builder1.setMyInfo(myInfo);
builder1.setMyInfo( PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig)) ;
}else {
ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(arenaRecord.getAttackId()), ChampionshipLogic.MemberInfo.class);
FamilyFightInfo fightInfo = memberInfo.getFightInfo();
if(fightInfo == null){
builder1.setMyInfo( PlayerLogic.getInstance().getUserTeamOneInfo(arenaRecord.getAttackId(), TeamEnum.CHAMPION_TEAM.getTeamId()));
}else {
//fix 整个过程都不能调整编队
User user = UserManager.getUser(arenaRecord.getAttackId()); CommonProto.TeamOneInfo.Builder defInfo = ChampionshipLogic.getUserTeam(arenaRecord.getDefUid());
CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user); builder1.setEnemyInfo(defInfo);
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
teamInfo.setTotalForce(fightInfo.getForce());
if (!fightInfo.getPokenmonIds().isEmpty()) {
// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds());
}
// int i = 1; builder1.setResult(fightResult);
for (Map.Entry<String, FamilyHeroInfo> entry : fightInfo.getHeroAttribute().entrySet()) {
FamilyHeroInfo familyHeroInfo = entry.getValue();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder()
.setHeroid(entry.getKey())
.setHeroTid(familyHeroInfo.getTempleteId())
.setStar(familyHeroInfo.getStar())
.setLevel(familyHeroInfo.getLevel())
.setPosition(familyHeroInfo.getPosition())
.setGodSoulLv(familyHeroInfo.getGodSoulLv())
.build()
);
}
oneInfo.setTeam(teamInfo);
builder1.setMyInfo(oneInfo);
}
}
sArenaRobotConfig= SArenaRobotConfig.getsArenaRobotConfigById(arenaRecord.getDefUid()); builder.setChampionBattleInfo(builder1.build());
if (sArenaRobotConfig != null) {
builder1.setEnemyInfo( PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig)) ;
}else {
ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(arenaRecord.getDefUid()), ChampionshipLogic.MemberInfo.class);
FamilyFightInfo fightInfo = memberInfo.getFightInfo();
if(fightInfo == null){
builder1.setEnemyInfo( PlayerLogic.getInstance().getUserTeamOneInfo(arenaRecord.getDefUid(), TeamEnum.CHAMPION_TEAM.getTeamId()));
}else {
//fix 整个过程都不能调整编队
User user = UserManager.getUser(arenaRecord.getDefUid());
CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user);
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
teamInfo.setTotalForce(fightInfo.getForce());
if (!fightInfo.getPokenmonIds().isEmpty()) {
// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds());
} }
// int i = 1;
for (Map.Entry<String, FamilyHeroInfo> entry : fightInfo.getHeroAttribute().entrySet()) {
FamilyHeroInfo familyHeroInfo = entry.getValue();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder()
.setHeroid(entry.getKey())
.setHeroTid(familyHeroInfo.getTempleteId())
.setStar(familyHeroInfo.getStar())
.setLevel(familyHeroInfo.getLevel())
.setPosition(familyHeroInfo.getPosition())
.setGodSoulLv(familyHeroInfo.getGodSoulLv())
.build()
);
}
oneInfo.setTeam(teamInfo);
builder1.setEnemyInfo(oneInfo);
}}
builder.setChampionBattleInfo(builder1
.setResult(fightResult)
.build());
}
} }
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_RESPONSE_VALUE,builder.build(),true); MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_RESPONSE_VALUE,builder.build(),true);
} }

View File

@ -141,10 +141,10 @@ public class ChampionBetInfoHandler extends BaseHandler<ArenaInfoProto.ChampionG
CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder(); CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder();
CommonProto.TeamOneInfo.Builder attTeam = getUserTeam(arenaRecord.getAttackId()); CommonProto.TeamOneInfo.Builder attTeam = ChampionshipLogic.getUserTeam(arenaRecord.getAttackId());
builder1.setMyInfo(attTeam); builder1.setMyInfo(attTeam);
CommonProto.TeamOneInfo.Builder defTeam = getUserTeam(arenaRecord.getDefUid()); CommonProto.TeamOneInfo.Builder defTeam = ChampionshipLogic.getUserTeam(arenaRecord.getDefUid());
builder1.setEnemyInfo(defTeam); builder1.setEnemyInfo(defTeam);
builder1.setResult(fightResult); builder1.setResult(fightResult);
@ -163,41 +163,4 @@ public class ChampionBetInfoHandler extends BaseHandler<ArenaInfoProto.ChampionG
} }
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CHAMPION_BET_INFO_RESPONSE_VALUE, builder.build(), true); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CHAMPION_BET_INFO_RESPONSE_VALUE, builder.build(), true);
} }
public CommonProto.TeamOneInfo.Builder getUserTeam(int robotId) throws Exception {
CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder();
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
if (sArenaRobotConfig != null) {
builder = PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig);
} else {
ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(robotId), ChampionshipLogic.MemberInfo.class);
FamilyFightInfo fightInfo = memberInfo.getFightInfo();
if (fightInfo == null) {
builder = PlayerLogic.getInstance().getUserTeamOneInfo(robotId, TeamEnum.CHAMPION_TEAM.getTeamId());
} else {
//fix 整个过程都不能调整编队
User user = UserManager.getUser(robotId);
CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user);
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
teamInfo.setTotalForce(fightInfo.getForce());
// int i = 1;
for (Map.Entry<String, FamilyHeroInfo> entry : fightInfo.getHeroAttribute().entrySet()) {
FamilyHeroInfo familyHeroInfo = entry.getValue();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder()
.setHeroid(entry.getKey())
.setHeroTid(familyHeroInfo.getTempleteId())
.setStar(familyHeroInfo.getStar())
.setLevel(familyHeroInfo.getLevel())
.setPosition(familyHeroInfo.getPosition())
.setGodSoulLv(familyHeroInfo.getGodSoulLv())
.build()
);
}
oneInfo.setTeam(teamInfo);
builder = oneInfo;
}
}
return builder;
}
} }

View File

@ -63,8 +63,8 @@ public class ChampionshipLogic {
private static volatile int realTimes; //比赛进行第几轮 比赛轮 private static volatile int realTimes; //比赛进行第几轮 比赛轮
private static Map<Integer, Boolean> fightAll = new ConcurrentHashMap<>(); private static Map<Integer, Boolean> fightAll = new ConcurrentHashMap<>();
private static volatile int fightTime=1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 private static volatile int fightTime = 1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束
private static volatile int fightTime_temp=1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 private static volatile int fightTime_temp = 1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束
private static volatile int schedule = 1;//1 选拔赛 private static volatile int schedule = 1;//1 选拔赛
public static final int PROCESS_PRE = 1;//准备竞猜 public static final int PROCESS_PRE = 1;//准备竞猜
public static final int PROCESS_BATTLE = 3;//战斗结算 public static final int PROCESS_BATTLE = 3;//战斗结算
@ -81,18 +81,19 @@ public class ChampionshipLogic {
} }
public static void init(){ public static void init() {
try { try {
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_SCHEDULE, ""); String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_SCHEDULE, "");
Object result = RedisUtil.getInstence().get(key); Object result = RedisUtil.getInstence().get(key);
if (result != null) { if (result != null) {
schedule = Integer.parseInt((String) result); schedule = Integer.parseInt((String) result);
} }
}catch (Exception e){ } catch (Exception e) {
LOGGER.info("Exception the init={}"); LOGGER.info("Exception the init={}", e);
} }
} }
public static int getProgress() { public static int getProgress() {
return progress; return progress;
} }
@ -181,26 +182,26 @@ public class ChampionshipLogic {
//提前把分数缓存进来 //提前把分数缓存进来
public static void setScoreForSuccess(int winnerUid, int failerUid,boolean result) { // public static void setScoreForSuccess(int winnerUid, int failerUid,boolean result) {
MemberInfo memberInfo = getJoinMemberInfo(winnerUid); // MemberInfo memberInfo = getJoinMemberInfo(winnerUid);
if (schedule == 2 ) { // if (schedule == 2 ) {
if(!result){//第二阶段没出结果直接返回 // if(!result){//第二阶段没出结果直接返回
return;
}
// if(3!=fightTime){
// return; // return;
// } // }
memberInfo.setFinalScore(memberInfo.getFinalScore() + 1); //// if(3!=fightTime){
MemberInfo failMemberInfo = getJoinMemberInfo(failerUid); //// return;
failMemberInfo.setFinalScore(memberInfo.getFinalScore() * -1); //// }
LOGGER.info("the falid={}", failerUid); // memberInfo.setFinalScore(memberInfo.getFinalScore() + 1);
updateJoinMemberInfo(memberInfo); // MemberInfo failMemberInfo = getJoinMemberInfo(failerUid);
updateJoinMemberInfo(failMemberInfo); // failMemberInfo.setFinalScore(memberInfo.getFinalScore() * -1);
return; // LOGGER.info("the falid={}", failerUid);
} // updateJoinMemberInfo(memberInfo);
memberInfo.setScore(memberInfo.getScore() + 1); // updateJoinMemberInfo(failMemberInfo);
updateJoinMemberInfo(memberInfo); // return;
} // }
// memberInfo.setScore(memberInfo.getScore() + 1);
// updateJoinMemberInfo(memberInfo);
// }
private static MemberInfo getJoinMemberInfo(int joinUid) { private static MemberInfo getJoinMemberInfo(int joinUid) {
return RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_JOIN, "", Integer.toString(joinUid), MemberInfo.class); return RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_JOIN, "", Integer.toString(joinUid), MemberInfo.class);
@ -224,9 +225,9 @@ public class ChampionshipLogic {
// } // }
// } // }
if(schedule==2){ if (schedule == 2) {
// if(fightTime!=0||realTimes!=1){ // if(fightTime!=0||realTimes!=1){
if(ChampionshipLogic.fightTime!=3) return; if (ChampionshipLogic.fightTime != 3) return;
// } // }
} }
@ -239,14 +240,14 @@ public class ChampionshipLogic {
int winnerUid = v.getAttackId(); int winnerUid = v.getAttackId();
int failerUid = v.getDefUid(); int failerUid = v.getDefUid();
if(schedule==2){ if (schedule == 2) {
String key = String.valueOf(v.getAttackId() * 2222 + String.valueOf(v.getDefUid())); String key = v.getAttackId() * 2222 + String.valueOf(v.getDefUid());
Integer state = states.get(key); Integer state = states.get(key);
if (null!=state&&state == 0) { if (null != state && state == 0) {
winnerUid = v.getDefUid(); winnerUid = v.getDefUid();
failerUid = v.getAttackId(); failerUid = v.getAttackId();
} }
}else { } else {
if (v.getFightResult() == 0) { if (v.getFightResult() == 0) {
winnerUid = v.getDefUid(); winnerUid = v.getDefUid();
failerUid = v.getAttackId(); failerUid = v.getAttackId();
@ -256,7 +257,7 @@ public class ChampionshipLogic {
MemberInfo joinMemberInfo = getJoinMemberInfo(winnerUid); MemberInfo joinMemberInfo = getJoinMemberInfo(winnerUid);
int score ; int score;
if (schedule == 2) { if (schedule == 2) {
joinMemberInfo.setFinalScore(joinMemberInfo.getFinalScore() + 1); joinMemberInfo.setFinalScore(joinMemberInfo.getFinalScore() + 1);
MemberInfo failMemberInfo = getJoinMemberInfo(failerUid); MemberInfo failMemberInfo = getJoinMemberInfo(failerUid);
@ -265,12 +266,12 @@ public class ChampionshipLogic {
updateJoinMemberInfo(failMemberInfo); updateJoinMemberInfo(failMemberInfo);
score = joinMemberInfo.getFinalScore(); score = joinMemberInfo.getFinalScore();
finalArenaIds.add(v.getId()); finalArenaIds.add(v.getId());
}else { } else {
joinMemberInfo.setScore(joinMemberInfo.getScore() + 1); joinMemberInfo.setScore(joinMemberInfo.getScore() + 1);
score = joinMemberInfo.getScore(); score = joinMemberInfo.getScore();
updateJoinMemberInfo(joinMemberInfo); updateJoinMemberInfo(joinMemberInfo);
} }
integerIntegerHashMap.putIfAbsent(winnerUid,new DefaultTypedTuple(Integer.toString(winnerUid), (double) score)); integerIntegerHashMap.putIfAbsent(winnerUid, new DefaultTypedTuple(Integer.toString(winnerUid), (double) score));
}); });
RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK, "", new HashSet<>(integerIntegerHashMap.values())); RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK, "", new HashSet<>(integerIntegerHashMap.values()));
if (schedule == 2) { if (schedule == 2) {
@ -312,18 +313,16 @@ public class ChampionshipLogic {
//获取竞技场排行榜 //获取竞技场排行榜
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = new HashSet<>(championshipPlayer); Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = new HashSet<>(championshipPlayer);
//start-end为0 127 才能拿到第128 不然会多拿到129 //start-end为0 127 才能拿到第128 不然会多拿到129
Set<ZSetOperations.TypedTuple<String>> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, championshipPlayer-1); Set<ZSetOperations.TypedTuple<String>> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, championshipPlayer - 1);
if (arenaRankInfoOne != null && !arenaRankInfoOne.isEmpty()) { if (arenaRankInfoOne != null && !arenaRankInfoOne.isEmpty()) {
arenaRankInfo.addAll(arenaRankInfoOne); arenaRankInfo.addAll(arenaRankInfoOne);
} }
Set<ZSetOperations.TypedTuple<String>> arenaRankInfoForChampion = new HashSet<>(); //存入排行榜 Set<ZSetOperations.TypedTuple<String>> arenaRankInfoForChampion = new HashSet<>(); //存入排行榜
List<MemberInfo> joinMembers = new ArrayList<>(championshipPlayer); //TODO 应该没用
List<MemberInfo> memberInfos = new ArrayList<>(championshipPlayer); List<MemberInfo> memberInfos = new ArrayList<>(championshipPlayer);
arenaRankInfo.forEach(item -> { arenaRankInfo.forEach(item -> {
String uidStr = item.getValue(); String uidStr = item.getValue();
MemberInfo memberInfo = new MemberInfo(Integer.parseInt(uidStr), 0); MemberInfo memberInfo = new MemberInfo(Integer.parseInt(uidStr), 0);
joinMembers.add(memberInfo);
ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(uidStr, 0D); ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(uidStr, 0D);
arenaRankInfoForChampion.add(typedTuple); arenaRankInfoForChampion.add(typedTuple);
memberInfos.add(memberInfo); memberInfos.add(memberInfo);
@ -349,11 +348,10 @@ public class ChampionshipLogic {
break; break;
} }
MemberInfo memberInfo = new MemberInfo(sArenaRobotConfig.getId(), 1); MemberInfo memberInfo = new MemberInfo(sArenaRobotConfig.getId(), 1);
joinMembers.add(memberInfo);
ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(Integer.toString(sArenaRobotConfig.getId()), 0D); ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(Integer.toString(sArenaRobotConfig.getId()), 0D);
arenaRankInfoForChampion.add(typedTuple); arenaRankInfoForChampion.add(typedTuple);
memberInfos.add(memberInfo); memberInfos.add(memberInfo);
LOGGER.info("the end={},the robotID={},the size={}", end, sArenaRobotConfig.getId(), joinMembers.size()); LOGGER.info("the end={},the robotID={},the size={}", end, sArenaRobotConfig.getId(), memberInfos.size());
} }
} }
@ -415,17 +413,17 @@ public class ChampionshipLogic {
user.getArenaManager().setTopMaxRank(rank); user.getArenaManager().setTopMaxRank(rank);
} }
user.getUserMissionManager().onGameEvent(user, GameEvent.CHAMPIONSHIP_RANK, rank); user.getUserMissionManager().onGameEvent(user, GameEvent.CHAMPIONSHIP_RANK, rank);
if(rank == 1){ if (rank == 1) {
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(),1)); Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(), 1));
} }
rank++; rank++;
String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title"); String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()},new int[]{1},"#"); String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()}, new int[]{1}, "#");
MailLogic.getInstance().sendMail(user.getId(), title, content, ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()), nowTime, Global.MAIL_EFFECTIVE_TIME); MailLogic.getInstance().sendMail(user.getId(), title, content, ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()), nowTime, Global.MAIL_EFFECTIVE_TIME);
} }
}catch (Exception e){ } catch (Exception e) {
LOGGER.info("Exception e = "+"size"+ arenaRankInfo.size()+ e.toString()); LOGGER.info("Exception e = " + "size" + arenaRankInfo.size() + e.toString());
} }
MongoUtil.getLjsdMongoTemplate().lastUpdate(); MongoUtil.getLjsdMongoTemplate().lastUpdate();
@ -438,35 +436,29 @@ public class ChampionshipLogic {
Item item = user.getItemManager().getItem(arenaItemId); Item item = user.getItemManager().getItem(arenaItemId);
int itemNum = 0; int itemNum = 0;
if (item != null) { if (item != null) {
itemNum =(int)item.getItemNum(); itemNum = (int) item.getItemNum();
} }
if (item != null && itemNum > 0) { if (item != null && itemNum > 0) {
int[][] costs = new int[1][]; int[][] costs = new int[1][];
costs[0] = new int[2]; costs[0] = new int[2];
costs[0][0] = arenaItemId; costs[0][0] = arenaItemId;
costs[0][1] = itemNum; costs[0][1] = itemNum;
// Map<Integer, Long> itemReward = new HashMap<>(1);
// itemReward.put(rewardItemId, (long) (itemNum / sChampionshipSetting.getExchangeItem()));
String title = SErrorCodeEerverConfig.getI18NMessage("champion_bet_title"); String title = SErrorCodeEerverConfig.getI18NMessage("champion_bet_title");
String content = SErrorCodeEerverConfig.getI18NMessage("champion_bet_content"); String content = SErrorCodeEerverConfig.getI18NMessage("champion_bet_content");
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardItemId+"#"+(itemNum / sChampionshipSetting.getExchangeItem()),TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME); MailLogic.getInstance().sendMail(user.getId(), title, content, rewardItemId + "#" + (itemNum / sChampionshipSetting.getExchangeItem()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
ItemUtil.itemCost(user, costs, BIReason.CHAMPIONM_EXCHANGE_CONSUME, sendId); ItemUtil.itemCost(user, costs, BIReason.CHAMPIONM_EXCHANGE_CONSUME, sendId);
// ItemUtil.addItem(user, itemReward, null, BIReason.CHAMPIONM_EXCHANGE_REWARD);
} }
LOGGER.info("the uid={}, send rewardnum={}",user.getId(), itemNum / sChampionshipSetting.getExchangeItem()); LOGGER.info("the uid={}, send rewardnum={}", user.getId(), itemNum / sChampionshipSetting.getExchangeItem());
} }
MongoUtil.getLjsdMongoTemplate().lastUpdate(); MongoUtil.getLjsdMongoTemplate().lastUpdate();
//clearReidsWhenEnd(joinUids);
} }
/** /**
* 使 * 使
*/ */
public static void whenStart() throws Exception { // public static void whenStart() throws Exception {
// schedule=1; // schedule=1;
// start(); // start();
// for(int i=1;i<8;i++){ // for(int i=1;i<8;i++){
@ -491,9 +483,7 @@ public class ChampionshipLogic {
// progress=-2; // progress=-2;
// //
// // close(); // // close();
// }
}
/** /**
@ -525,55 +515,33 @@ public class ChampionshipLogic {
} }
public static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) throws Exception { public static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) {
CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder();
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid); SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid);
if (sArenaRobotConfig != null) { if (sArenaRobotConfig != null) {
return CommonProto.TeamOneInfo.newBuilder() builder.setUid(sArenaRobotConfig.getId()).setLevel(sArenaRobotConfig.getRobotLevel()).setName(sArenaRobotConfig.getRobotName());
.setLevel(sArenaRobotConfig.getRobotLevel()) }else {
.setName(sArenaRobotConfig.getRobotName())
.setUid(sArenaRobotConfig.getId());
// return PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig);
}
MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), MemberInfo.class); MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), MemberInfo.class);
FamilyFightInfo fightInfo = memberInfo.getFightInfo(); FamilyFightInfo fightInfo = memberInfo.getFightInfo();
if(fightInfo == null){ if (fightInfo == null) {
return PlayerLogic.getInstance().getUserTeamOneInfo(uid,TeamEnum.CHAMPION_TEAM.getTeamId()); builder = PlayerLogic.getInstance().getUserTeamOneInfo(uid, TeamEnum.CHAMPION_TEAM.getTeamId());
} }else {
//fix 整个过程都不能调整编队 //fix 整个过程都不能调整编队
builder = CBean2Proto.getTeamOneInfo(uid);
}
}
return builder;
}
User user = UserManager.getUser(uid); // private static String getMyCurJoinBattleId(int uid) {
return CBean2Proto.getTeamOneInfo(user); // List<ArenaRecord> curArenaRecordList = getCurArenaRecordList();
// CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); // for (ArenaRecord arenaRecord : curArenaRecordList) {
// teamInfo.setTotalForce(fightInfo.getForce()); // if (arenaRecord.getDefUid() == uid || arenaRecord.getAttackId() == uid) {
// if (!fightInfo.getPokenmonIds().isEmpty()) { // return arenaRecord.getId();
// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds());
// } // }
//
//// int i = 1;
// for (Map.Entry<String, FamilyHeroInfo> entry : fightInfo.getHeroAttribute().entrySet()) {
// FamilyHeroInfo familyHeroInfo = entry.getValue();
// teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder()
// .setHeroid(entry.getKey())
// .setHeroTid(familyHeroInfo.getTempleteId())
// .setStar(familyHeroInfo.getStar())
// .setLevel(familyHeroInfo.getLevel())
// .setPosition(familyHeroInfo.getPosition())
// .build()
// );
// } // }
// oneInfo.setTeam(teamInfo); // return null;
} // }
private static String getMyCurJoinBattleId(int uid) {
List<ArenaRecord> curArenaRecordList = getCurArenaRecordList();
for (ArenaRecord arenaRecord : curArenaRecordList) {
if (arenaRecord.getDefUid() == uid || arenaRecord.getAttackId() == uid) {
return arenaRecord.getId();
}
}
return null;
}
/** /**
* *
@ -630,8 +598,7 @@ public class ChampionshipLogic {
} }
public static void snapPlayFightInfo(boolean fight) throws Exception {
public static void snapPlayFightInfo( boolean fight) throws Exception {
int snapTeamId = TeamEnum.CHAMPION_ATTACK_TEAM.getTeamId(); int snapTeamId = TeamEnum.CHAMPION_ATTACK_TEAM.getTeamId();
RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, "")); RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, ""));
int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime(); int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime();
@ -643,7 +610,7 @@ public class ChampionshipLogic {
snapOneFightInfo(attackId, memberInfoMap); snapOneFightInfo(attackId, memberInfoMap);
snapOneFightInfo(defUid, memberInfoMap); snapOneFightInfo(defUid, memberInfoMap);
if(fight){ if (fight) {
long id = FightDispatcher.getFIghtId(); long id = FightDispatcher.getFIghtId();
EndFightProcessor endFightProcessor = new AreFightPro(); EndFightProcessor endFightProcessor = new AreFightPro();
((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord); ((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord);
@ -657,30 +624,30 @@ public class ChampionshipLogic {
if (defMemberInfo.getType() == 0) { if (defMemberInfo.getType() == 0) {
FamilyFightInfo fightInfo = defMemberInfo.getFightInfo(); FamilyFightInfo fightInfo = defMemberInfo.getFightInfo();
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(),defUid)); pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), defUid));
defForce = fightInfo.getForce(); defForce = fightInfo.getForce();
}else { } else {
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(defUid); SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(defUid);
if(sArenaRobotConfig!=null){ if (sArenaRobotConfig != null) {
defForce = sArenaRobotConfig.getTotalForce(); defForce = sArenaRobotConfig.getTotalForce();
} }
} }
if (attackMemberInfo.getType() == 0) { if (attackMemberInfo.getType() == 0) {
FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo(); FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo();
pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(),attackId)); pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), attackId));
minForce = fightInfo.getForce(); minForce = fightInfo.getForce();
}else { } else {
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(attackId); SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(attackId);
if(sArenaRobotConfig!=null){ if (sArenaRobotConfig != null) {
minForce = sArenaRobotConfig.getTotalForce(); minForce = sArenaRobotConfig.getTotalForce();
} }
} }
if(minForce>defForce){ if (minForce > defForce) {
if(arenaRecord.getTurn()==2){ if (arenaRecord.getTurn() == 2) {
pvpFightEvent.setRever(true); pvpFightEvent.setRever(true);
} }
}else { } else {
if(arenaRecord.getTurn()==1||arenaRecord.getTurn()==3){ if (arenaRecord.getTurn() == 1 || arenaRecord.getTurn() == 3) {
pvpFightEvent.setRever(true); pvpFightEvent.setRever(true);
} }
} }
@ -761,6 +728,7 @@ public class ChampionshipLogic {
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL, "", selectBetId + ":" + defUid, guessNum); RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL, "", selectBetId + ":" + defUid, guessNum);
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_BETID, ""); String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_BETID, "");
RedisUtil.getInstence().set(key, selectBetId); RedisUtil.getInstence().set(key, selectBetId);
LOGGER.info("巅峰赛比赛队伍信息竞赛id{},攻击者:{},防御者:{}",selectBetId, attackId, defUid);
} }
public static int getForce(MemberInfo memberInfo, Map<Integer, SArenaRobotConfig> config) { public static int getForce(MemberInfo memberInfo, Map<Integer, SArenaRobotConfig> config) {
@ -774,13 +742,6 @@ public class ChampionshipLogic {
return force; return force;
} }
// public static void guess(ISession session, int winUid,int chip) throws Exception {
//
//
// }
/** /**
* *
*/ */
@ -816,8 +777,8 @@ public class ChampionshipLogic {
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(uid))); delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(uid)));
}); });
RedisUtil.getInstence().del(delKeys.toArray(new String[0])); RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
realTimes=1; realTimes = 1;
fightTime=1; fightTime = 1;
fightAll.clear(); fightAll.clear();
} }
@ -828,7 +789,8 @@ public class ChampionshipLogic {
*/ */
public static void sendBetReward() { public static void sendBetReward() {
String selectUid = getSelectIdForRedis(); String selectUid = getSelectIdForRedis();
if(selectUid.isEmpty()){ LOGGER.info("巅峰赛开始发奖,轮次:{}",selectUid);
if (selectUid.isEmpty()) {
return; return;
} }
int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem(); int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem();
@ -847,7 +809,7 @@ public class ChampionshipLogic {
AtomicBoolean winner = new AtomicBoolean(true); AtomicBoolean winner = new AtomicBoolean(true);
if (schedule == 2) { if (schedule == 2) {
Map<String, Integer> states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class); Map<String, Integer> states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class);
String key = String.valueOf(arenaRecord.getAttackId() * 2222 + String.valueOf(arenaRecord.getDefUid())); String key = arenaRecord.getAttackId() * 2222 + String.valueOf(arenaRecord.getDefUid());
Integer state = states.get(key); Integer state = states.get(key);
if (null != state && state == 0) { if (null != state && state == 0) {
winnerUid = arenaRecord.getDefUid(); winnerUid = arenaRecord.getDefUid();
@ -871,23 +833,21 @@ public class ChampionshipLogic {
betPersonInfoMap.forEach((betUid, coins) -> { betPersonInfoMap.forEach((betUid, coins) -> {
try { try {
User user = UserManager.getUser(betUid); User user = UserManager.getUser(betUid);
AyyncWorker ayyncWorker = new AyyncWorker(user, true, new AyncWorkerRunnable() { AyyncWorker ayyncWorker = new AyyncWorker(user, true, user1 -> {
@Override
public void work(User user) throws Exception {
int mineWinCoins = (int) (winRate * coins); int mineWinCoins = (int) (winRate * coins);
int[][] drop = new int[1][]; int[][] drop = new int[1][];
drop[0] = new int[2]; drop[0] = new int[2];
drop[0][0] = arenaItem[0]; drop[0][0] = arenaItem[0];
drop[0][1] = mineWinCoins; drop[0][1] = mineWinCoins;
ItemUtil.drop(user, drop, BIReason.CHAMPIION_BET_WIN_REWARD); LOGGER.info("巅峰赛结束给玩家发奖uid{},奖品:{}",user1.getId(),drop);
ItemUtil.drop(user1, drop, BIReason.CHAMPIION_BET_WIN_REWARD);
MongoUtil.getLjsdMongoTemplate().lastUpdate(); MongoUtil.getLjsdMongoTemplate().lastUpdate();
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId()); ISession sessionByUid = OnlineUserManager.getSessionByUid(user1.getId());
if (sessionByUid != null) { if (sessionByUid != null) {
ArenaInfoProto.ChampionGuessSuccessIndication build = ArenaInfoProto.ChampionGuessSuccessIndication.newBuilder().setItemId(arenaItem[0]).setItemNum(mineWinCoins).setRoundTimes(roundTimes).build(); ArenaInfoProto.ChampionGuessSuccessIndication build = ArenaInfoProto.ChampionGuessSuccessIndication.newBuilder().setItemId(arenaItem[0]).setItemNum(mineWinCoins).setRoundTimes(roundTimes).build();
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.CHAMPION_GUESS_SUCCESS_INDICATION_VALUE, build, true); MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.CHAMPION_GUESS_SUCCESS_INDICATION_VALUE, build, true);
} }
ReportUtil.onReportEvent(user, ReportEventEnum.GUESS_OVER.getType(),openTimeOfFuntionCacheByType.getTimes(),getSchedule()==1?getRealTimes():getRealTimes()+7,winner.get()?1:2,mineWinCoins); ReportUtil.onReportEvent(user1, ReportEventEnum.GUESS_OVER.getType(), openTimeOfFuntionCacheByType.getTimes(), getSchedule() == 1 ? getRealTimes() : getRealTimes() + 7, winner.get() ? 1 : 2, mineWinCoins);
}
}); });
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker); ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
@ -899,7 +859,6 @@ public class ChampionshipLogic {
} }
public static CommonProto.ChampionBetInfo getBetOdds() { public static CommonProto.ChampionBetInfo getBetOdds() {
String selectUid = getSelectIdForRedis(); String selectUid = getSelectIdForRedis();
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", selectUid, ArenaRecord.class); ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", selectUid, ArenaRecord.class);
@ -916,21 +875,53 @@ public class ChampionshipLogic {
return RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "", Integer.class, type); return RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "", Integer.class, type);
} }
public static CommonProto.TeamOneInfo.Builder getUserTeam(int robotId) {
CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder();
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
if (sArenaRobotConfig != null) {
builder = PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig);
} else {
ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(robotId), ChampionshipLogic.MemberInfo.class);
FamilyFightInfo fightInfo = memberInfo.getFightInfo();
if (fightInfo == null) {
builder = PlayerLogic.getInstance().getUserTeamOneInfo(robotId, TeamEnum.CHAMPION_TEAM.getTeamId());
} else {
//fix 整个过程都不能调整编队
CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(robotId);
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
teamInfo.setTotalForce(fightInfo.getForce());
// int i = 1;
for (Map.Entry<String, FamilyHeroInfo> entry : fightInfo.getHeroAttribute().entrySet()) {
FamilyHeroInfo familyHeroInfo = entry.getValue();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder()
.setHeroid(entry.getKey())
.setHeroTid(familyHeroInfo.getTempleteId())
.setStar(familyHeroInfo.getStar())
.setLevel(familyHeroInfo.getLevel())
.setPosition(familyHeroInfo.getPosition())
.setGodSoulLv(familyHeroInfo.getGodSoulLv())
.build()
);
}
oneInfo.setTeam(teamInfo);
builder = oneInfo;
}
}
return builder;
}
/** /**
* 1. * 1.
* * <p>
* arenaRecordMap * arenaRecordMap
* CHAMPION_ARENA_RECORD * CHAMPION_ARENA_RECORD
* CHAMPION_CUR_JOIN_IDS id * CHAMPION_CUR_JOIN_IDS id
* CHAMPION_JOIN * CHAMPION_JOIN
*
*
*/ */
public static void selectToBattle() { public static void selectToBattle() {
RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_JOIN_IDS, "")); RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_JOIN_IDS, ""));
Map<String, ArenaRecord> arenaRecordMap = new HashMap<>(); Map<String, ArenaRecord> arenaRecordMap = new HashMap<>();
List<String> arenaRecordIds = new ArrayList<>();
if (schedule == 1) { if (schedule == 1) {
List<int[]> joinIndexs = STableManager.getFigureConfig(CommonStaticConfig.class).getMatrixforGroupInfo().get(roundTimes); List<int[]> joinIndexs = STableManager.getFigureConfig(CommonStaticConfig.class).getMatrixforGroupInfo().get(roundTimes);
Map<Integer, MemberInfo> joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class); Map<Integer, MemberInfo> joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class);
@ -975,12 +966,12 @@ public class ChampionshipLogic {
} }
}); });
} }
Map<Integer, Integer> memberPerOfTeam = new HashMap<>(); // Map<Integer, Integer> memberPerOfTeam = new HashMap<>();
finalmemberOfTeam.forEach((k, v) -> { // finalmemberOfTeam.forEach((k, v) -> {
v.forEach(memberId -> { // v.forEach(memberId -> {
memberPerOfTeam.put(memberId, k); // memberPerOfTeam.put(memberId, k);
}); // });
}); // });
int times = 0; int times = 0;
int length = possibleJoin.size(); int length = possibleJoin.size();
if (length < 8) { if (length < 8) {
@ -999,7 +990,7 @@ public class ChampionshipLogic {
arenaRecord.setAttackId(attackUid); arenaRecord.setAttackId(attackUid);
arenaRecord.setDefUid(defUid); arenaRecord.setDefUid(defUid);
arenaRecord.setType(type); arenaRecord.setType(type);
arenaRecord.setRoundTims(realTimes+7); arenaRecord.setRoundTims(realTimes + 7);
arenaRecord.setTurn(fightTime); arenaRecord.setTurn(fightTime);
if (realTimes > 2) { if (realTimes > 2) {
arenaRecord.setNums(times++); arenaRecord.setNums(times++);
@ -1007,7 +998,7 @@ public class ChampionshipLogic {
arenaRecord.setNums(times++ % length); arenaRecord.setNums(times++ % length);
} }
arenaRecordMap.put(arenaRecord.getId(), arenaRecord); arenaRecordMap.put(arenaRecord.getId(), arenaRecord);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1016,7 +1007,7 @@ public class ChampionshipLogic {
} }
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", arenaRecordMap); RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", arenaRecordMap);
arenaRecordIds.addAll(arenaRecordMap.keySet()); List<String> arenaRecordIds = new ArrayList<>(arenaRecordMap.keySet());
RedisUtil.getInstence().lSet(RedisKey.CHAMPION_CUR_JOIN_IDS, "", arenaRecordIds); RedisUtil.getInstence().lSet(RedisKey.CHAMPION_CUR_JOIN_IDS, "", arenaRecordIds);
if (schedule == 2) { if (schedule == 2) {
//记录4强 8强的人 方便索引 //记录4强 8强的人 方便索引
@ -1032,15 +1023,10 @@ public class ChampionshipLogic {
arenaRecordMap.forEach((id, arenaRecord) -> { arenaRecordMap.forEach((id, arenaRecord) -> {
int defUid = arenaRecord.getDefUid(); int defUid = arenaRecord.getDefUid();
int attackId = arenaRecord.getAttackId(); int attackId = arenaRecord.getAttackId();
// if (!robotConfigMap.containsKey(defUid)) {
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(defUid)); String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(defUid));
RedisUtil.getInstence().lSet(key, id); RedisUtil.getInstence().lSet(key, id);
// }
// if (!robotConfigMap.containsKey(attackId)) {
String key2 = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(attackId)); String key2 = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(attackId));
RedisUtil.getInstence().lSet(key2, id); RedisUtil.getInstence().lSet(key2, id);
// }
}); });
} }
@ -1132,7 +1118,7 @@ public class ChampionshipLogic {
Map<String, Integer> sendIds = new HashMap<>(); Map<String, Integer> sendIds = new HashMap<>();
snapPlayFightInfo(false); snapPlayFightInfo(false);
if (schedule == 2 && fightTime!=1) { if (schedule == 2 && fightTime != 1) {
return; return;
} }
OnlineUserManager.sessionMap.values().forEach(session -> { OnlineUserManager.sessionMap.values().forEach(session -> {
@ -1151,7 +1137,7 @@ public class ChampionshipLogic {
int[][] reward = new int[1][]; int[][] reward = new int[1][];
int[] temp2 = new int[2]; int[] temp2 = new int[2];
temp2[0] = itemNum[0][0]; temp2[0] = itemNum[0][0];
temp2[1] = item == null ? itemNum[0][1] : itemNum[0][1] - (int)item.getItemNum(); temp2[1] = item == null ? itemNum[0][1] : itemNum[0][1] - (int) item.getItemNum();
reward[0] = temp2; reward[0] = temp2;
// fix 发放代币 只补充到阈值 // fix 发放代币 只补充到阈值
ItemUtil.drop(user, reward, BIReason.CHAMPIION_BET_REWARD); ItemUtil.drop(user, reward, BIReason.CHAMPIION_BET_REWARD);
@ -1167,8 +1153,6 @@ public class ChampionshipLogic {
}); });
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS, "", sendIds); RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS, "", sendIds);
selectBetTeam(); selectBetTeam();
} }
@ -1240,10 +1224,10 @@ public class ChampionshipLogic {
return; return;
} }
Map<Integer, MemberInfo> joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class); Map<Integer, MemberInfo> joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class);
if(joinMembers.size()==0){ if (joinMembers.size() == 0) {
return; return;
} }
if(progress == -2){ if (progress == -2) {
return; return;
} }
long now = TimeUtils.now(); long now = TimeUtils.now();
@ -1252,8 +1236,8 @@ public class ChampionshipLogic {
int duration = sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime(); //fix 只有竞猜和战斗 int duration = sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime(); //fix 只有竞猜和战斗
int progressState = getProgress((int) ((now - startTime) / 1000 % duration + 1)); //阶段 int progressState = getProgress((int) ((now - startTime) / 1000 % duration + 1)); //阶段
long round = (now - startTime) / 1000 / duration + 1;//轮数 long round = (now - startTime) / 1000 / duration + 1;//轮数
if(round>30){ if (round > 30) {
progress=-2; progress = -2;
//sendAllProgressUpdate(); //sendAllProgressUpdate();
return; return;
} }
@ -1267,13 +1251,13 @@ public class ChampionshipLogic {
// progressState = progressState==1?2:progressState; // progressState = progressState==1?2:progressState;
progressTmp = 100 + roundTimes * 10 + progressState; progressTmp = 100 + roundTimes * 10 + progressState;
setSchedule(1); setSchedule(1);
fightTime=2; fightTime = 2;
if (progressTmp == progress) { if (progressTmp == progress) {
return; return;
} }
} else {//决赛 } else {//决赛
if (realTimes>5) { if (realTimes > 5) {
setSchedule(2); setSchedule(2);
if (progress != -2) { if (progress != -2) {
progress = -2; progress = -2;
@ -1286,8 +1270,8 @@ public class ChampionshipLogic {
if (schedule == 1) { // 刚开始进入决赛,选拔出选手 if (schedule == 1) { // 刚开始进入决赛,选拔出选手
scoreToRedis(); scoreToRedis();
realTimes=1; realTimes = 1;
fightTime=0; fightTime = 0;
setSchedule(2); setSchedule(2);
selectToJoinFinal(); selectToJoinFinal();
} }
@ -1306,18 +1290,18 @@ public class ChampionshipLogic {
if (progressState == 1) { //竞猜阶段 后台自动运行战斗 if (progressState == 1) { //竞猜阶段 后台自动运行战斗
if(schedule == 2 ){ if (schedule == 2) {
if(fightTime==2&&fightTime_temp==3){ if (fightTime == 2 && fightTime_temp == 3) {
fightTime=3; fightTime = 3;
scoreToRedis(); scoreToRedis();
realTimes++; realTimes++;
fightTime=0; fightTime = 0;
return; return;
} }
if(fightTime==3){ if (fightTime == 3) {
scoreToRedis(); scoreToRedis();
realTimes++; realTimes++;
fightTime=0; fightTime = 0;
return; return;
} }
} }
@ -1332,7 +1316,7 @@ public class ChampionshipLogic {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
},0, TimeUnit.MILLISECONDS); }, 0, TimeUnit.MILLISECONDS);
sendAllProgressUpdate(); sendAllProgressUpdate();
} else if (progressState == 3) { //结算阶段 } else if (progressState == 3) { //结算阶段
@ -1355,33 +1339,32 @@ public class ChampionshipLogic {
} }
} }
ChampionshipLogic.fightTime_temp=1; ChampionshipLogic.fightTime_temp = 1;
if(ChampionshipLogic.schedule==2&&(ChampionshipLogic.fightTime==2||ChampionshipLogic.fightTime==3)){ if (ChampionshipLogic.schedule == 2 && (ChampionshipLogic.fightTime == 2 || ChampionshipLogic.fightTime == 3)) {
boolean isAllWin=true; boolean isAllWin = true;
Map<String, Integer> states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class); Map<String, Integer> states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class);
for (int i = 0; i <arenaRecords.size() ; i++) { for (ArenaRecord record : arenaRecords) {
ArenaRecord record = arenaRecords.get(i); String key = record.getAttackId() * 2222 + String.valueOf(record.getDefUid());
String key = String.valueOf(record.getAttackId() * 2222 + String.valueOf(record.getDefUid()));
Integer state = states.get(key); Integer state = states.get(key);
if(state!=null&&state>1){ if (state != null && state > 1) {
isAllWin=false; isAllWin = false;
break; break;
} }
} }
if(isAllWin){ if (isAllWin) {
ChampionshipLogic.fightTime_temp=3; ChampionshipLogic.fightTime_temp = 3;
} }
} }
if (schedule == 2 && (fightTime !=3&&fightTime_temp!=3)) { if (schedule == 2 && (fightTime != 3 && fightTime_temp != 3)) {
}else { } else {
sendBetReward(); sendBetReward();
} }
sendAllProgressUpdate(); sendAllProgressUpdate();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
},0, TimeUnit.MILLISECONDS); }, 0, TimeUnit.MILLISECONDS);
sendAllProgressUpdate(); sendAllProgressUpdate();
} }

View File

@ -91,27 +91,27 @@ public class UserManager {
} }
public static void userClear(){ public static void userClear(){
try { // try {
Iterator<Map.Entry<Integer, User>> iterator = userMap.entrySet().iterator(); // Iterator<Map.Entry<Integer, User>> iterator = userMap.entrySet().iterator();
while (iterator.hasNext()){ // while (iterator.hasNext()){
Map.Entry<Integer, User> next = iterator.next(); // Map.Entry<Integer, User> next = iterator.next();
Integer uid = next.getKey(); // Integer uid = next.getKey();
if (OnlineUserManager.checkUidOnline(uid)){ // if (OnlineUserManager.checkUidOnline(uid)){
continue; // continue;
} // }
Integer count = userCount.getOrDefault(uid, 0); // Integer count = userCount.getOrDefault(uid, 0);
if (count-- <= 0){ // if (count-- <= 0){
MongoUtil.getLjsdMongoTemplate().lastUpdate(); // MongoUtil.getLjsdMongoTemplate().lastUpdate();
LOGGER.info("离线玩家{}被请求次数为{},剔除缓存",uid,count); // LOGGER.info("离线玩家{}被请求次数为{},剔除缓存",uid,count);
iterator.remove(); // iterator.remove();
removeUser(uid); // removeUser(uid);
}else { // }else {
userCount.put(uid,count); // userCount.put(uid,count);
} // }
} // }
}catch (Exception e){ // }catch (Exception e){
LOGGER.error("userClear报错{}",e); // LOGGER.error("userClear报错{}",e);
} // }
} }

View File

@ -543,7 +543,7 @@ public class PlayerLogic {
} }
public CommonProto.TeamOneInfo.Builder getUserTeamOneInfo(int uid,int teamId) throws Exception { public CommonProto.TeamOneInfo.Builder getUserTeamOneInfo(int uid,int teamId) {
User user = PlayerLogic.getInstance().getUserByRpc(uid); User user = PlayerLogic.getInstance().getUserByRpc(uid);
CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user); CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user);
TeamPosManager teamPosManager = user.getTeamPosManager(); TeamPosManager teamPosManager = user.getTeamPosManager();

View File

@ -893,6 +893,22 @@ public class CBean2Proto {
.setUserTitle(user.getPlayerInfoManager().getUserTitle()); .setUserTitle(user.getPlayerInfoManager().getUserTitle());
} }
public static CommonProto.TeamOneInfo.Builder getTeamOneInfo(int uid){
CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder();
CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
if (player == null){
return builder;
}
builder.setHead(player.getHead())
.setHeadFrame(player.getHeadFrame())
.setLevel(player.getLevel())
.setName(player.getName())
.setUid(player.getUserId())
.setPracticeLevel(player.getPracticeLevel())
.setUserTitle(player.getUserTitle());
return builder;
}
public static CommonProto.FamilyBaseInfo getFamilyBaseInfo(GuildInfo guildInfo){ public static CommonProto.FamilyBaseInfo getFamilyBaseInfo(GuildInfo guildInfo){
CommonProto.FamilyContribute familyContribute = CommonProto.FamilyContribute.newBuilder() CommonProto.FamilyContribute familyContribute = CommonProto.FamilyContribute.newBuilder()
.setWin(guildInfo.getResult(1)) .setWin(guildInfo.getResult(1))