add pokemon

back_recharge
wangyuan 2019-12-16 20:19:55 +08:00
parent 1b6811a4be
commit 00cf1b77da
2 changed files with 33 additions and 27 deletions

View File

@ -211,8 +211,9 @@ public class RedisKey {
public final static String CHAMPION_FINAL_TEAM_INFO = "CHAMPION_FINAL_TEAM_INFO"; public final static String CHAMPION_FINAL_TEAM_INFO = "CHAMPION_FINAL_TEAM_INFO";
public final static String CHAMPION_BET_MINE = "CHAMPION_BET_MINE"; // 我的竞猜 public final static String CHAMPION_BET_MINE = "CHAMPION_BET_MINE"; // 我的竞猜 selectIdForRedis value: winUid
public final static String CHAMPION_BET_ALL = "CHAMPION_BET_ALL"; // 竞猜信息 public final static String CHAMPION_BET_DETAIL = "CHAMPION_BET_DETAIL"; // 我的竞猜 selectUid + ":" +winUid
public final static String CHAMPION_BET_ALL = "CHAMPION_BET_ALL"; // 竞猜信息 selectUid + ":" +winUid
public final static String CHAMPION_FINAL_RECODED_IDS = "CHAMPION_FINAL_RECODED_IDS"; // 巅峰赛決賽信息 public final static String CHAMPION_FINAL_RECODED_IDS = "CHAMPION_FINAL_RECODED_IDS"; // 巅峰赛決賽信息
public final static String PIDGIDTEMP = "PIDGIDTEMP"; public final static String PIDGIDTEMP = "PIDGIDTEMP";

View File

@ -469,14 +469,10 @@ public class ChampionshipLogic {
if(progress%10%4 != 0){ if(progress%10%4 != 0){
fightResult =-1; fightResult =-1;
} }
int myGuessID = arenaRecord.getAttackId(); int myGuessID = 0;
Integer coins = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectIdForRedis + ":" +myGuessID, Integer.class); String guessUidStr = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectIdForRedis, String.class);
if(coins == null) { if(!StringUtil.isEmpty(guessUidStr)) {
myGuessID = arenaRecord.getDefUid(); myGuessID = Integer.parseInt(guessUidStr);
coins = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectIdForRedis + ":" +myGuessID, Integer.class);
}
if(coins == null){
myGuessID = 0;
} }
CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder() CommonProto.ChampionBattleInfo.Builder builder1 = CommonProto.ChampionBattleInfo.newBuilder()
.setMyInfo(getChampionBattleInfo(arenaRecord.getAttackId())) .setMyInfo(getChampionBattleInfo(arenaRecord.getAttackId()))
@ -695,7 +691,17 @@ public class ChampionshipLogic {
} }
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId); String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
fightInfo.setPokenmonSkills(pokenmonSkills); fightInfo.setPokenmonSkills(pokenmonSkills);
// RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_FIGHT, "", String.valueOf(uid), fightInfo); List<TeamPosForPokenInfo> teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(snapTeamId);
if(teamPosForPokenInfos!=null){
List<Integer> pokens = new ArrayList<>();
for(TeamPosForPokenInfo teamPosForPokenInfo : teamPosForPokenInfos){
pokens.add(teamPosForPokenInfo.getPokenId());
}
fightInfo.setPokenmonIds(pokens);
}
memberInfo.setFightInfo(fightInfo); memberInfo.setFightInfo(fightInfo);
joinMembers.put(memberInfo.getUid(),memberInfo); joinMembers.put(memberInfo.getUid(),memberInfo);
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_JOIN,"",String.valueOf(uid),memberInfo); RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_JOIN,"",String.valueOf(uid),memberInfo);
@ -760,12 +766,17 @@ public class ChampionshipLogic {
String selectUid = getSelectIdForRedis(); String selectUid = getSelectIdForRedis();
if(progress%10%4!=1 || StringUtil.isEmpty(selectUid)){ if(progress%10%4!=1 || StringUtil.isEmpty(selectUid)){
LOGGER.error("the uid={} not in time",uid); LOGGER.error("the uid={} not in time",uid);
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
String alreadyCoins = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectUid, String.class);
if(!StringUtil.isEmpty(alreadyCoins)){
LOGGER.error("the uid={} guess winner={} had guessed",uid,winUid);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} }
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", selectUid, ArenaRecord.class); ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", selectUid, ArenaRecord.class);
if(arenaRecord.getAttackId()!=winUid && arenaRecord.getDefUid()!=winUid){ if(arenaRecord.getAttackId()!=winUid && arenaRecord.getDefUid()!=winUid){
LOGGER.error("the uid={} guess winner={} is not exists",uid,winUid); LOGGER.error("the uid={} guess winner={} is not exists",uid,winUid);
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} }
User user = UserManager.getUser(uid); User user = UserManager.getUser(uid);
int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem(); int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem();
@ -776,9 +787,9 @@ public class ChampionshipLogic {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
} }
//我下注信息 //我下注信息
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_BET_MINE,Integer.toString(uid),selectUid +":" + winUid,chip); RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_BET_MINE,Integer.toString(uid),selectUid,winUid);
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectUid +":" + winUid,chip); RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectUid +":" + winUid,chip);
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_BET_MINE,selectUid +":" + winUid,Integer.toString(uid),chip); RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_BET_DETAIL,selectUid +":" + winUid,Integer.toString(uid),chip);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_BET_GUESS_RESPONSE_VALUE,null,true); MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_BET_GUESS_RESPONSE_VALUE,null,true);
@ -793,7 +804,7 @@ public class ChampionshipLogic {
String betAllKey = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_ALL, ""); String betAllKey = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_ALL, "");
Set<String> betDetails = RedisUtil.getInstence().getZset(betAllKey, 0, -1); Set<String> betDetails = RedisUtil.getInstence().getZset(betAllKey, 0, -1);
for(String betInfo : betDetails){ for(String betInfo : betDetails){
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_MINE, betInfo)); delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_DETAIL, betInfo));
} }
delKeys.add(betAllKey); delKeys.add(betAllKey);
} }
@ -820,7 +831,7 @@ public class ChampionshipLogic {
Double failCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + failUid); Double failCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + failUid);
double winRate = (winCoins + failCoins) / winCoins; double winRate = (winCoins + failCoins) / winCoins;
Map<Integer, Integer> betPersonInfoMap = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, selectUid + ":" + winUid, Integer.class, Integer.class); Map<Integer, Integer> betPersonInfoMap = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_DETAIL, selectUid + ":" + winUid, Integer.class, Integer.class);
betPersonInfoMap.forEach((betUid,coins)->{ betPersonInfoMap.forEach((betUid,coins)->{
try { try {
User user = UserManager.getUser(betUid); User user = UserManager.getUser(betUid);
@ -851,16 +862,10 @@ public class ChampionshipLogic {
*/ */
public static void viewMGuessHistory(ISession session) throws Exception { public static void viewMGuessHistory(ISession session) throws Exception {
int uid = session.getUid(); int uid = session.getUid();
Map<String, Integer> betHistorys = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), String.class, Integer.class); Map<String, String> betHistorys = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), String.class, String.class);
ArenaInfoProto.ChampionGetAllMyBetInfoResponse.Builder builder = ArenaInfoProto.ChampionGetAllMyBetInfoResponse.newBuilder(); ArenaInfoProto.ChampionGetAllMyBetInfoResponse.Builder builder = ArenaInfoProto.ChampionGetAllMyBetInfoResponse.newBuilder();
if(!betHistorys.isEmpty()){ if(!betHistorys.isEmpty()){
List<String> guessIds = new ArrayList<>(betHistorys.size()); List<Object> ids = new ArrayList<>(betHistorys.keySet());
betHistorys.forEach((idAndBet,coins)->{
String[] idAndBetSplit = idAndBet.split(":");
String id = idAndBetSplit[0];
guessIds.add(id);
});
List<Object> ids = new ArrayList<>(guessIds);
List<ArenaRecord> arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class); List<ArenaRecord> arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class);
String selectIdForRedis = getSelectIdForRedis(); String selectIdForRedis = getSelectIdForRedis();
Map<Integer, SArenaRobotConfig> arenaRobotConfigMap = STableManager.getConfig(SArenaRobotConfig.class); Map<Integer, SArenaRobotConfig> arenaRobotConfigMap = STableManager.getConfig(SArenaRobotConfig.class);
@ -891,8 +896,8 @@ public class ChampionshipLogic {
if(fightResult == 0){ if(fightResult == 0){
winner = arenaRecord.getDefUid(); winner = arenaRecord.getDefUid();
} }
Integer coins = betHistorys.get(arenaRecord.getId()+ ":" + winner); String guessUid = betHistorys.get(arenaRecord.getId());
if(coins!=null){ if(!StringUtil.isEmpty(guessUid) && guessUid.equals(winner)){
guessState = 2; guessState = 2;
} }
// betDetailBuilder.setFightData(CommonProto.FightData.parseFrom(arenaRecord.getFightData())); // betDetailBuilder.setFightData(CommonProto.FightData.parseFrom(arenaRecord.getFightData()));