diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java index 45f46f563..2058d1f19 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java @@ -1,8 +1,7 @@ package com.ljsd.jieling.logic.arena; -import com.ljsd.fight.CheckFight; -import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig; + import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.core.VipPrivilegeType; import com.ljsd.jieling.db.mongo.MongoUtil; @@ -19,7 +18,6 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean; import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.activity.event.ArenaChallengeEvent; import com.ljsd.jieling.logic.activity.event.Poster; -import com.ljsd.jieling.logic.championship.ChampionshipLogic; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.*; @@ -38,7 +36,6 @@ import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.util.*; import config.*; import manager.STableManager; -import org.luaj.vm2.LuaValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.ZSetOperations; @@ -51,8 +48,8 @@ import java.util.*; public class ArenaLogic { private static final Logger LOGGER = LoggerFactory.getLogger(ArenaLogic.class); - private ArenaLogic() { - } + private ArenaLogic(){} + public static class Instance { @@ -62,7 +59,7 @@ public class ArenaLogic { public static ArenaLogic getInstance() { return ArenaLogic.Instance.instance; } - + private int curSeason; private int viewSeason; @@ -76,16 +73,16 @@ public class ArenaLogic { public List getArenaEnemyList(List arenaEnemies) throws Exception { List arenaEnemyList = new ArrayList<>(arenaEnemies.size()); - for (ArenaEnemy arenaEnemy : arenaEnemies) { + for(ArenaEnemy arenaEnemy : arenaEnemies){ int enemyId = arenaEnemy.getEnemyId(); int enemyType = arenaEnemy.getEnemyType(); - arenaEnemyList.add(getArenaEnemy(enemyId, enemyType)); + arenaEnemyList.add(getArenaEnemy(enemyId,enemyType)); } return arenaEnemyList; } - public CommonProto.ArenaEnemy getArenaEnemy(int enemyId, int enemyType) throws Exception { - if (enemyType == 0) { //机器人 + public CommonProto.ArenaEnemy getArenaEnemy( int enemyId ,int enemyType) throws Exception { + if(enemyType == 0){ //机器人 SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(enemyId); CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).build(); CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder() @@ -99,19 +96,19 @@ public class ArenaLogic { .setPersonInfo(personInfoBuild) .setTeam(teamBuild) .build(); - } else { + }else{ User user = UserManager.getUser(enemyId); - int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, GlobalsDef.TEAM_ARENA_DEFENSE, false); + int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, GlobalsDef.TEAM_ARENA_DEFENSE,false); List teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.TEAM_ARENA_DEFENSE); Map heroMap = user.getHeroManager().getHeroMap(); List heroTids = new ArrayList<>(teamPosHeroInfoList.size()); - for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) { + for(TeamPosHeroInfo teamPosHeroInfo:teamPosHeroInfoList){ heroTids.add(heroMap.get(teamPosHeroInfo.getHeroId()).getTemplateId()); } CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(heroTids).build(); PlayerManager playerInfoManager = user.getPlayerInfoManager(); int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(curSeason), Integer.toString(enemyId)).intValue(); - if (score == -1) { + if(score == -1){ score = SArenaSetting.getSArenaSetting().getScore(); } CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder() @@ -122,7 +119,7 @@ public class ArenaLogic { .setHead(playerInfoManager.getHead()) .setTotalForce(totalForce) .build(); - return CommonProto.ArenaEnemy.newBuilder() + return CommonProto.ArenaEnemy.newBuilder() .setPersonInfo(personInfoBuild) .setTeam(teamBuild) .build(); @@ -130,47 +127,50 @@ public class ArenaLogic { } - public void setMyArenaEnemys(int uid, User user) { - int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(curSeason), Integer.toString(uid)).intValue(); - if (score == -1) { + + public void setMyArenaEnemys(int uid,User user){ + int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue(); + if(score == -1){ score = SArenaSetting.getSArenaSetting().getScore(); } ArenaManager arenaManager = user.getArenaManager(); - List arenaEnemies = new ArrayList<>(); - if (curSeason == 1 && arenaManager.getFlushNums() < SArenaSetting.getSArenaSetting().getPveNum()) { + List arenaEnemies = new ArrayList<>(); + if(curSeason ==1 && arenaManager.getFlushNums() robotIds = randomRobot(score, 5); - toArenaEnemy(uid, robotIds, arenaEnemies, GlobalsDef.ARENA_ROBOT_TYPE); - } else { - Set robotIds = randomPerson(uid, score, true); + toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE); + }else{ + Set robotIds = randomPerson(uid,score,true); int type = GlobalsDef.ARENA_PLAYER_TYPE; - toArenaEnemy(uid, robotIds, arenaEnemies, type); - if (robotIds.isEmpty()) { - if (curSeason > 1) { - robotIds = randomPerson(uid, score, false); + toArenaEnemy(uid,robotIds,arenaEnemies,type); + if(robotIds.isEmpty()){ + if(curSeason>1){ + robotIds = randomPerson(uid,score,false); } - toArenaEnemy(uid, robotIds, arenaEnemies, type); + toArenaEnemy(uid,robotIds,arenaEnemies,type); } int size = robotIds.size(); - if (size < 5) { - robotIds = randomRobot(score, 5 - size); - type = GlobalsDef.ARENA_ROBOT_TYPE; - toArenaEnemy(uid, robotIds, arenaEnemies, type); + if(size<5){ + robotIds = randomRobot(score, 5-size); + type = GlobalsDef.ARENA_ROBOT_TYPE; + toArenaEnemy(uid,robotIds,arenaEnemies,type); } } arenaManager.setArenaEnemies(arenaEnemies); } - public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception { - PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(), myteamId, SArenaSetting.getSArenaSetting().getMostTime(), "", GameFightType.ArenaPersonFight, defUser.getId(), defTeamId); + + + public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception { + PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", GameFightType.ArenaPersonFight,defUser.getId(),defTeamId); int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, GlobalsDef.TEAM_ARENA_DEFENSE, false); int defForce = HeroLogic.getInstance().calTeamTotalForce(defUser, GlobalsDef.TEAM_ARENA_DEFENSE, false); arenaRecord.setAttackForce(myforce); - if (myforce < defForce) { + if(myforce randomRobot(int userSscore, int nums) { + public static Set randomRobot(int userSscore,int nums){ Set robotIds = new HashSet<>(5); Map config = STableManager.getConfig(SArenaRobotSetting.class); - for (SArenaRobotSetting sArenaRobotSetting : config.values()) { + for(SArenaRobotSetting sArenaRobotSetting : config.values()){ int playerLevelMin = sArenaRobotSetting.getPlayerScoreMin(); int playerLevelMax = sArenaRobotSetting.getPlayerScoreMax(); - if (userSscore >= playerLevelMin && userSscore <= playerLevelMax) { + if(userSscore>=playerLevelMin && userSscore<=playerLevelMax){ int poolId = sArenaRobotSetting.getPool(); List sArenaRobotConfigsByPool = SArenaRobotConfig.getSArenaRobotConfigsByPool(poolId); int size = sArenaRobotConfigsByPool.size(); - while (robotIds.size() < nums) { + while (robotIds.size() < nums){ robotIds.add(sArenaRobotConfigsByPool.get(MathUtils.randomInt(size)).getId()); } } @@ -288,22 +289,22 @@ public class ArenaLogic { return robotIds; } - public Set randomPerson(int uid, int myScore, boolean useCurSeason) { + public Set randomPerson(int uid,int myScore,boolean useCurSeason){ Set result = new HashSet<>(5); int[][] interval = SArenaSetting.getSArenaSetting().getInterval(); int matchSeason = curSeason; - if (!useCurSeason) { + if(!useCurSeason){ matchSeason = curSeason - 1; } - for (int[] item : interval) { + for(int[] item: interval){ int low = item[0]; int high = item[1]; - Set arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK, Integer.toString(matchSeason), myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1); - LOGGER.info("curSeason={},matchSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},", curSeason, matchSeason, uid, myScore, low, high, myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1); - if (arenaRank != null && !arenaRank.isEmpty()) { + Set arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK,Integer.toString(matchSeason), myScore * low / 10000.0f-1, myScore * high / 10000.0f +1); + LOGGER.info("curSeason={},matchSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},",curSeason,matchSeason,uid,myScore,low,high,myScore * low / 10000.0f-1,myScore * high / 10000.0f +1); + if(arenaRank!=null && !arenaRank.isEmpty()){ arenaRank.remove(Integer.toString(uid)); String s = randomSet(arenaRank); - if (!StringUtil.isEmpty(s)) { + if(!StringUtil.isEmpty(s)){ result.add(Integer.parseInt(s)); } } @@ -311,31 +312,31 @@ public class ArenaLogic { return result; } - private String randomSet(Set infos) { - if (infos == null || infos.isEmpty()) { + private String randomSet(Set infos){ + if(infos == null || infos.isEmpty()){ return null; } int num = MathUtils.randomInt(infos.size()); - for (String id : infos) { - if (num-- == 0) { - return id; + for(String id : infos){ + if(num-- == 0){ + return id; } } return null; } - public void toArenaEnemy(int uid, Set enemyList, List arenaEnemies, int type) { - for (Integer enemyId : enemyList) { - if (1 == type && enemyId == uid) { + public void toArenaEnemy(int uid,Set enemyList,List arenaEnemies,int type){ + for(Integer enemyId: enemyList){ + if(1 == type && enemyId == uid){ continue; } - arenaEnemies.add(new ArenaEnemy(enemyId, type, type)); + arenaEnemies.add(new ArenaEnemy(enemyId,type,type)); } } - public void getWorldRankByPage(ISession session, int page) throws Exception { + public void getWorldRankByPage(ISession session,int page) throws Exception { if (page == 0) { page = 1; } @@ -343,13 +344,13 @@ public class ArenaLogic { List arenaRankMemberInfo = new ArrayList<>(20); int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.ARENA_RANKINGSHOWNUM); - if (end < rankEndLine) { + if(end> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(viewSeason), start, end); for (ZSetOperations.TypedTuple item : arenaRankInfo) { String value = item.getValue(); int score = item.getScore().intValue(); int uid = Integer.parseInt(value); - User user = UserManager.getUser(uid, true); + User user = UserManager.getUser(uid,true); if (null == user) { continue; } @@ -379,12 +380,12 @@ public class ArenaLogic { } } int uid = session.getUid(); - int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(viewSeason), Integer.toString(uid)).intValue(); - int myRank = -1; - if (score == -1) { + int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(viewSeason), Integer.toString(uid)).intValue(); + int myRank =-1; + if(score == -1){ score = SArenaSetting.getSArenaSetting().getScore(); - } else { - myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.ARENA_RANK, Integer.toString(viewSeason), Integer.toString(uid)).intValue(); + }else{ + myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ARENA_RANK,Integer.toString(viewSeason),Integer.toString(uid)).intValue(); } ArenaInfoProto.GetArenaRankInfoResponse buildResponse = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder() @@ -392,222 +393,120 @@ public class ArenaLogic { .setMyRank(myRank) .setMyscore(score) .build(); - MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE, buildResponse, true); + MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE,buildResponse,true); } + + /** - * Sa: 实际胜负值, 胜 = 1 负=0 - *

- * Ra: A选手比赛前的分 Rb: B选手比赛前的分数 - * R'a: A选手比赛完的分数 R'b: B选手比赛完的分数 - *

- * Ea:EA = 1/(1+10^[(Rb-Ra)/400]) - * Eb: EB = 1/(1+10^[(Ra-Rb)/400]) - * R'a = Ra + K(Sa-Ea) - * R'b = Rb + K(Sb-Eb) + * + Sa: 实际胜负值, 胜 = 1 负=0 + + Ra: A选手比赛前的分 Rb: B选手比赛前的分数 + R'a: A选手比赛完的分数 R'b: B选手比赛完的分数 + + Ea:EA = 1/(1+10^[(Rb-Ra)/400]) + Eb: EB = 1/(1+10^[(Ra-Rb)/400]) + R'a = Ra + K(Sa-Ea) + R'b = Rb + K(Sb-Eb) + * */ - public int calScore(int myScore, int defScore, int result) { + public int calScore(int myScore,int defScore,int result){ SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting(); int k = sArenaSetting.getK(); - double ea = 1.0 / (1 + Math.pow(10, (defScore - myScore) / 400.0f)); - int parm = result == 1 ? 1 : -1; - return (int) (k * (result - ea) + 0.5 * parm); + double ea = 1.0/(1 + Math.pow(10,(defScore - myScore)/400.0f)); + int parm = result == 1?1:-1; + return (int)(k*(result-ea) + 0.5*parm); } - public void getFightReplayData(ISession iSession, int type, String fightId) throws Exception { + public void getFightReplayData(ISession iSession,int type,String fightId) throws Exception { int uid = iSession.getUid(); - ArenaRecord arenaRecord = null; - if (type == 2) { - arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_ARENA_RECORD, "", fightId, ArenaRecord.class); - } else if (type == 1) { - arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.ARENA_RRECORD, Integer.toString(uid), fightId, ArenaRecord.class); - } else if (type == 3) { + ArenaRecord arenaRecord=null; + if(type == 2){ + arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_ARENA_RECORD,"", fightId, ArenaRecord.class); + }else if(type == 1){ + arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.ARENA_RRECORD, Integer.toString(uid), fightId, ArenaRecord.class); + }else if(type == 3){ arenaRecord = RedisUtil.getInstence().get(RedisKey.GUILDBOSS_ARENA_RECORD, fightId, ArenaRecord.class); } - if (arenaRecord == null) { + if(arenaRecord == null){ throw new ErrorCodeException(ErrorCode.newDefineCode("arena_rrecord null")); } - byte[] fightData = arenaRecord.getFightData(); + byte[] fightData = arenaRecord.getFightData(); CommonProto.FightData fightDataProto = CommonProto.FightData.parseFrom(fightData); - - - - - LuaValue getFightData; - int snapTeamId = GlobalsDef.CHAMPION_ATTACK_TEAM; - RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, "")); - int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime(); - Map memberInfoMap = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, ChampionshipLogic.MemberInfo.class); - int attackId = arenaRecord.getAttackId(); - int defUid = arenaRecord.getDefUid(); - ChampionshipLogic.snapOneFightInfo(attackId, memberInfoMap); - ChampionshipLogic.snapOneFightInfo(defUid, memberInfoMap); - - long id = FightDispatcher.getFIghtId(); - EndFightProcessor endFightProcessor = new AreFightPro(); - ((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord); - FightDispatcher.getMap().put(id, endFightProcessor); - Map gameFightTypeMap = new HashMap<>(); - - gameFightTypeMap.put(0, GameFightType.TOPArenaPersonFight); - gameFightTypeMap.put(1, GameFightType.TOPArenaRobotFight); - gameFightTypeMap.put(2, GameFightType.TOPArena2RobotFight); - PVPFightEvent pvpFightEvent = new PVPFightEvent(attackId, snapTeamId, warTime, "", gameFightTypeMap.get(arenaRecord.getType()), defUid, snapTeamId); - - ChampionshipLogic.MemberInfo attackMemberInfo = memberInfoMap.get(attackId); - ChampionshipLogic.MemberInfo defMemberInfo = memberInfoMap.get(defUid); - int minForce = 0; - int defForce = 0; - - if (defMemberInfo.getType() == 0) { - FamilyFightInfo fightInfo = defMemberInfo.getFightInfo(); - pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), defUid)); - defForce = fightInfo.getForce(); - } else { - SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(defUid); - if (sArenaRobotConfig != null) { - defForce = sArenaRobotConfig.getTotalForce(); - } - } - if (attackMemberInfo.getType() == 0) { - FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo(); - pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), attackId)); - minForce = fightInfo.getForce(); - } else { - SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(attackId); - if (sArenaRobotConfig != null) { - minForce = sArenaRobotConfig.getTotalForce(); - } - } - if (minForce > defForce) { - if (arenaRecord.getTurn() == 2) { - pvpFightEvent.setRever(true); - } - } else { - if (arenaRecord.getTurn() == 1 || arenaRecord.getTurn() == 3) { - pvpFightEvent.setRever(true); - } - } - - CommonProto.FightTeamInfo fightTeamInfo = null; - CommonProto.FightTeamInfo deffightTeamInfo = null; - if(pvpFightEvent.getAttackFightSnapData()!=null){ - fightTeamInfo = FightUtil.makeFightWithSnapData(pvpFightEvent.getAttackFightSnapData()); - } - if(pvpFightEvent.getDefFightSnapData()!=null){ - deffightTeamInfo = FightUtil.makeFightWithSnapData(pvpFightEvent.getDefFightSnapData()); - } else{ - if(pvpFightEvent.getFightType() == GameFightType.ArenaPersonFight ||pvpFightEvent.getFightType() == GameFightType.CarPersonChallenge ){ - User defInMem = UserManager.getUserInMem(pvpFightEvent.getDefUid()); - deffightTeamInfo = FightUtil.makePersonFightData(defInMem, pvpFightEvent.getDefTeamId(),null,null); - }else{ - deffightTeamInfo =FightUtil. makeRobotFightData(pvpFightEvent.getDefUid()); - } - - } - if(fightTeamInfo==null){ - if( pvpFightEvent.getFightType()!=GameFightType.TOPArena2RobotFight){ - if( SArenaRobotConfig.getsArenaRobotConfigById(pvpFightEvent.getAttackUid()) !=null){ - fightTeamInfo =FightUtil. makeRobotFightData(pvpFightEvent.getAttackUid()); - }else{ - User userInMem = UserManager.getUserInMem(pvpFightEvent.getAttackUid()); - fightTeamInfo = FightUtil.makePersonFightData(userInMem, pvpFightEvent.getTeamId(),pvpFightEvent.getAttackBloodMap(),null); - } - }else{ - fightTeamInfo = FightUtil.makeRobotFightData(pvpFightEvent.getAttackUid()); - } - } - - - - - if (pvpFightEvent.isRever()) { - deffightTeamInfo = CommonProto.FightTeamInfo.newBuilder().mergeFrom(deffightTeamInfo).setFirstCamp(1).build(); - getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo, true);//对方先手 - } else { - getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo); - } - LuaValue getOptionData = FightDataUtil.getOptionData(pvpFightEvent.getAttackUid() + ""); - int[] fightResult = CheckFight.getInstance().checkFight(fightDataProto.getFightSeed(), pvpFightEvent.getMostTime(), getFightData, getOptionData, pvpFightEvent.getFightType().getFightType()); - - - String string = Arrays.toString(fightData); - LOGGER.error("__________________________"+fightResult[0]+":::"+string); - System.out.println("string = " + string); FightInfoProto.FightRePlayResponse build = FightInfoProto.FightRePlayResponse.newBuilder().setFightData(fightDataProto).build(); - MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.VIEW_FIGHTREPLAY_RESPONSE_VALUE, build, true); + MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.VIEW_FIGHTREPLAY_RESPONSE_VALUE,build,true); } /** * 发送结算奖励 - * * @param type * @throws Exception */ public void sendReward(int type) throws Exception { - if (curSeason == 0) { + if(curSeason == 0){ return; } String title; String content; - if (type == GlobalsDef.ARENA_DAILY_REWARD) { + if(type == GlobalsDef.ARENA_DAILY_REWARD){ title = SErrorCodeEerverConfig.getI18NMessage("arena_daily_reward_title"); - } else { + }else{ title = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title"); } - Set> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, -1); - if (type == GlobalsDef.ARENA_SEASON_REWARD) { - curSeason = 0; + Set> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,Integer.toString(curSeason), 0, -1); + if(type == GlobalsDef.ARENA_SEASON_REWARD){ + curSeason=0; } int rank = 1; - int nowTime = (int) (TimeUtils.now() / 1000); - for (ZSetOperations.TypedTuple item : arenaRankInfo) { + int nowTime =(int) (TimeUtils.now()/1000); + for(ZSetOperations.TypedTuple item : arenaRankInfo){ String value = item.getValue(); int uid = Integer.parseInt(value); User user = UserManager.getUser(uid, true); if (null == user) { continue; } - if (type == GlobalsDef.ARENA_DAILY_REWARD) { + if(type == GlobalsDef.ARENA_DAILY_REWARD){ MissionEventDistributor.requestStart(); - user.getUserMissionManager().onGameEvent(user, GameEvent.ARENA_UPDATE_RANK, rank); + user.getUserMissionManager().onGameEvent(user,GameEvent.ARENA_UPDATE_RANK,rank); ISession sessionByUid = OnlineUserManager.getSessionByUid(uid); - if (sessionByUid != null) { - MissionEventDistributor.requestEnd(sessionByUid, true); + if(sessionByUid!=null){ + MissionEventDistributor.requestEnd(sessionByUid,true); } } - if (type == GlobalsDef.ARENA_DAILY_REWARD) { - content = SErrorCodeEerverConfig.getI18NMessage("arena_daily_reward_txt", new Object[]{rank}); - } else { - content = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_txt", new Object[]{rank}); + if(type == GlobalsDef.ARENA_DAILY_REWARD){ + content = SErrorCodeEerverConfig.getI18NMessage("arena_daily_reward_txt",new Object[]{rank}); + }else{ + content = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_txt",new Object[]{rank}); user.getPlayerInfoManager().removeRed(GlobalsDef.ARENA_CHALLENGE_TYPE); String key = RedisUtil.getInstence().getKey(RedisKey.ARENA_RRECORD, Integer.toString(uid)); RedisUtil.getInstence().del(key); } String rewardByRank = getRewardByRank(rank++, type); - if (!"".equals(rewardByRank)) { - MailLogic.getInstance().sendMail(user.getId(), title, content, rewardByRank, nowTime, Global.MAIL_EFFECTIVE_TIME); + if(!"".equals(rewardByRank)){ + MailLogic.getInstance().sendMail(user.getId(),title,content,rewardByRank,nowTime, Global.MAIL_EFFECTIVE_TIME); } } MongoUtil.getInstence().lastUpdate(); } - public String getRewardByRank(int rank, int type) { + public String getRewardByRank(int rank,int type){ Map config = STableManager.getConfig(SArenaReward.class); - for (SArenaReward sArenaReward : config.values()) { + for(SArenaReward sArenaReward : config.values()){ int minRank = sArenaReward.getMinRank(); int maxRank = sArenaReward.getMaxRank(); - if (rank >= minRank && rank <= maxRank) { - if (type == GlobalsDef.ARENA_DAILY_REWARD) { + if(rank>=minRank && rank<=maxRank){ + if(type == GlobalsDef.ARENA_DAILY_REWARD){ int[][] dailyReward = sArenaReward.getDailyReward(); return StringUtil.parseArrayToString(dailyReward); - } else { + }else{ int[][] seasonReward = sArenaReward.getSeasonReward(); return StringUtil.parseArrayToString(seasonReward); } @@ -615,33 +514,33 @@ public class ArenaLogic { } return ""; } - - public void updateArenaSeason(int curSeason) { + + public void updateArenaSeason(int curSeason){ this.curSeason = curSeason; - if (this.curSeason != 0) { + if(this.curSeason!=0){ viewSeason = this.curSeason; } } - public void playWithSb(ISession session, int challengeUid, int myteamId) throws Exception { + public void playWithSb(ISession session,int challengeUid,int myteamId) throws Exception { User mine = UserManager.getUser(session.getUid()); User defUser = UserManager.getUser(challengeUid); - if (!defUser.getTeamPosManager().getTeamPosForHero().containsKey(1)) { + if(!defUser.getTeamPosManager().getTeamPosForHero().containsKey(1)){ throw new ErrorCodeException(ErrorCode.newDefineCode("对方未设置阵容")); } int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, myteamId, false); int deforce = HeroLogic.getInstance().calTeamTotalForce(defUser, 1, false); - CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine, myteamId, true); - CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser, 1, false); + CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,true); + CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,1,false); - if (myforce < deforce) { + if(myforce