推送巅峰赛进度信息
parent
2efcce2614
commit
f90796f702
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -106,10 +106,10 @@ public class CheckFight {
|
||||||
int[] resultCache = new int[7];
|
int[] resultCache = new int[7];
|
||||||
resultCache[0]=status;
|
resultCache[0]=status;
|
||||||
resultCache[1]=duration;
|
resultCache[1]=duration;
|
||||||
// LOGGER.info(" lua check test fight result : "+ status);
|
LOGGER.info(" lua check test fight result : "+ status);
|
||||||
for (int i = 1; i <= result.length(); i++) {
|
for (int i = 1; i <= result.length(); i++) {
|
||||||
resultCache[i+1] = result.rawget(i).toint();
|
resultCache[i+1] = result.rawget(i).toint();
|
||||||
// LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultCache;
|
return resultCache;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ljsd.jieling.core;
|
package com.ljsd.jieling.core;
|
||||||
|
|
||||||
import com.ljsd.jieling.core.function.ArenaFunction;
|
import com.ljsd.jieling.core.function.ArenaFunction;
|
||||||
|
import com.ljsd.jieling.core.function.ChampionFunction;
|
||||||
import com.ljsd.jieling.core.function.EndlessFunction;
|
import com.ljsd.jieling.core.function.EndlessFunction;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ public enum FunctionIdEnum {
|
||||||
SoulEquip(52,null,
|
SoulEquip(52,null,
|
||||||
MessageTypeProto.MessageType.SOUL_RAND_EQUIP_REQUEST_VALUE,
|
MessageTypeProto.MessageType.SOUL_RAND_EQUIP_REQUEST_VALUE,
|
||||||
MessageTypeProto.MessageType.SOUL_FORCE_RAND_EQUIP_REQUEST_VALUE),
|
MessageTypeProto.MessageType.SOUL_FORCE_RAND_EQUIP_REQUEST_VALUE),
|
||||||
TopBattle(57,null),
|
TopBattle(57,new ChampionFunction()),
|
||||||
WorkShopTech(101,null,MessageTypeProto.MessageType.WORKSHOP_TECHNOLOGY_LEVEL_REQUEST_VALUE),
|
WorkShopTech(101,null,MessageTypeProto.MessageType.WORKSHOP_TECHNOLOGY_LEVEL_REQUEST_VALUE),
|
||||||
WorkShopCreateEquip(102,null),
|
WorkShopCreateEquip(102,null),
|
||||||
WorkShopCreateProtectEquip(103,null),
|
WorkShopCreateProtectEquip(103,null),
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ public class RedisKey {
|
||||||
|
|
||||||
|
|
||||||
public final static String CHAMPION_CHOSE_TEAM_INFO = "CHAMPION_CHOSE_TEAM_INFO";
|
public final static String CHAMPION_CHOSE_TEAM_INFO = "CHAMPION_CHOSE_TEAM_INFO";
|
||||||
public final static String CHAMPION_FINAL_TEAM_INFO = "CHAMPION_CHOSE_TEAM_INFO";
|
public final static String CHAMPION_FINAL_TEAM_INFO = "CHAMPION_FINAL_TEAM_INFO";
|
||||||
|
|
||||||
public final static String CHAMPION_PROGRESS = "CHAMPION_PROGRESS"; //
|
public final static String CHAMPION_PROGRESS = "CHAMPION_PROGRESS"; //
|
||||||
public final static String CHAMPION_BET_MINE = "CHAMPION_BET_MINE"; // 我的竞猜
|
public final static String CHAMPION_BET_MINE = "CHAMPION_BET_MINE"; // 我的竞猜
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ljsd.jieling.db.redis;
|
package com.ljsd.jieling.db.redis;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.common.mogodb.util.GlobalData;
|
import com.ljsd.common.mogodb.util.GlobalData;
|
||||||
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
|
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
|
||||||
|
|
@ -15,6 +16,7 @@ import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import redis.clients.jedis.Protocol;
|
import redis.clients.jedis.Protocol;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
@ -1012,6 +1014,21 @@ public class RedisUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> T getMapEntry(String type,String key,String mapKey,Type parmsType){
|
||||||
|
String rkey = getKey(type, key);
|
||||||
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
|
try {
|
||||||
|
Object o = redisTemplate.opsForHash().get(rkey, mapKey);
|
||||||
|
if(o!=null){
|
||||||
|
return gson.fromJson(o.toString(),parmsType);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
TimeUtils.sleep(FAILED_SLEEP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T> T getMapValue(String type, String key, String mapKey, Class<T> clazz) {
|
public <T> T getMapValue(String type, String key, String mapKey, Class<T> clazz) {
|
||||||
String rkey = getKey(type, key);
|
String rkey = getKey(type, key);
|
||||||
|
|
@ -1060,6 +1077,18 @@ public class RedisUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <K,T> Map<K,T> getMapValues(String type,String key,Class<K> keyClazz,Type valueType){
|
||||||
|
Map<K,T> result = new HashMap<>();
|
||||||
|
String rkey = getKey(type, key);
|
||||||
|
Map<Object, Object> entries = redisTemplate.opsForHash().entries(rkey);
|
||||||
|
for(Map.Entry<Object,Object> item : entries.entrySet()){
|
||||||
|
Object key1 = item.getKey();
|
||||||
|
Object value = item.getValue();
|
||||||
|
result.put(gson.fromJson(gson.toJson(key1),keyClazz),gson.fromJson(value.toString(),valueType));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void removeMapEntrys(String type, String key, Object... mapKeys){
|
public void removeMapEntrys(String type, String key, Object... mapKeys){
|
||||||
String rkey = getKey(type, key);
|
String rkey = getKey(type, key);
|
||||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ljsd.jieling.handler.champion;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.ArenaInfoProto;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
public class ChampionBetInfoHandler extends BaseHandler<ArenaInfoProto.ChampionGetBetRequest> {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.CHAMPION_BET_INFO_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, ArenaInfoProto.ChampionGetBetRequest proto) throws Exception {
|
||||||
|
ChampionshipLogic.getChampionBetInfo(iSession,proto.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ljsd.jieling.handler.champion;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
public class ChampionGetMyAllBetHandler extends BaseHandler {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.CHAMPION_GET_MYALL_BET_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
ChampionshipLogic.viewMGuessHistory(iSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ljsd.jieling.handler.champion;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
public class ChampionGetMyHistoryHandler extends BaseHandler {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.CHAMPION_GET_MYHISTORY_REQEUST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
ChampionshipLogic.viewAllMyBattleInfo(iSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ljsd.jieling.handler.champion;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.ArenaInfoProto;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
|
public class ChampionGetWorldRankHandler extends BaseHandler<ArenaInfoProto.ChampionGetWorldRankRequest> {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.CHAMPION_GET_RANK_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, ArenaInfoProto.ChampionGetWorldRankRequest proto) throws Exception {
|
||||||
|
ChampionshipLogic.getWorldRankByPage(iSession,proto.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@ import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.protocols.ArenaInfoProto;
|
import com.ljsd.jieling.protocols.ArenaInfoProto;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
|
||||||
public class ChampionBetHandler extends BaseHandler<ArenaInfoProto.ChampionBetReqeust> {
|
public class ChampionGuessHandler extends BaseHandler<ArenaInfoProto.ChampionBetReqeust> {
|
||||||
@Override
|
@Override
|
||||||
public MessageTypeProto.MessageType getMessageCode() {
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
return MessageTypeProto.MessageType.CHAMPION_BET_GUESS_REQUEST;
|
return MessageTypeProto.MessageType.CHAMPION_BET_GUESS_REQUEST;
|
||||||
|
|
@ -11,6 +11,7 @@ import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.exception.ErrorCode;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
import com.ljsd.jieling.globals.BIReason;
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||||
|
|
@ -19,6 +20,7 @@ import com.ljsd.jieling.logic.dao.*;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.fight.*;
|
import com.ljsd.jieling.logic.fight.*;
|
||||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||||
|
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||||
|
|
@ -59,7 +61,7 @@ public class ChampionshipLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class MemberInfo{
|
public static class MemberInfo{
|
||||||
private int uid;
|
private int uid;
|
||||||
private int type;
|
private int type;
|
||||||
private int score; // 选拔积分
|
private int score; // 选拔积分
|
||||||
|
|
@ -114,16 +116,6 @@ public class ChampionshipLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static Map<String,ArenaRecord> arenaRecordMap = new HashMap<>();//历史对战队伍信息
|
|
||||||
|
|
||||||
// private static Map<String,ArenaRecord> curArenaRecordMap = new HashMap<>();//当前进行对战队伍信息
|
|
||||||
|
|
||||||
// private static List<String> finalRecodedIds = new ArrayList<>();
|
|
||||||
|
|
||||||
// private static List<List<Integer>> finalmemberOfTeam; // 决赛队伍信息
|
|
||||||
|
|
||||||
// private static String selectUid = "";
|
|
||||||
|
|
||||||
private static int schedule=1;
|
private static int schedule=1;
|
||||||
|
|
||||||
//提前把分数缓存进来
|
//提前把分数缓存进来
|
||||||
|
|
@ -198,6 +190,7 @@ public class ChampionshipLogic {
|
||||||
* 参赛队伍信息
|
* 参赛队伍信息
|
||||||
*/
|
*/
|
||||||
public static void start() {
|
public static void start() {
|
||||||
|
LOGGER.info("the champion start...");
|
||||||
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
||||||
int championshipPlayer = sChampionshipSetting.getChampionshipPlayer();
|
int championshipPlayer = sChampionshipSetting.getChampionshipPlayer();
|
||||||
int curSeason = ArenaLogic.getInstance().getCurSeason();
|
int curSeason = ArenaLogic.getInstance().getCurSeason();
|
||||||
|
|
@ -251,6 +244,11 @@ public class ChampionshipLogic {
|
||||||
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_JOIN, "");
|
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_JOIN, "");
|
||||||
RedisUtil.getInstence().del(key, RedisUtil.getInstence().getKey(RedisKey.CHAMPION_RANK, ""));
|
RedisUtil.getInstence().del(key, RedisUtil.getInstence().getKey(RedisKey.CHAMPION_RANK, ""));
|
||||||
RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK,"",arenaRankInfoForChampion);
|
RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK,"",arenaRankInfoForChampion);
|
||||||
|
Map<String,MemberInfo> memberInfoMap = new HashMap<>();
|
||||||
|
memberInfos.forEach(memberInfo -> {
|
||||||
|
memberInfoMap.put(Integer.toString(memberInfo.getUid()),memberInfo);
|
||||||
|
});
|
||||||
|
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_JOIN,"",memberInfoMap);
|
||||||
|
|
||||||
for(int i=0;i<memberOfTeamOfGroup.size();i++){
|
for(int i=0;i<memberOfTeamOfGroup.size();i++){
|
||||||
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "",Integer.toString(i),memberOfTeamOfGroup.get(i));
|
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "",Integer.toString(i),memberOfTeamOfGroup.get(i));
|
||||||
|
|
@ -258,7 +256,35 @@ public class ChampionshipLogic {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() {
|
public static void close() throws Exception {
|
||||||
|
Map<Integer, SChampionshipReward> config = STableManager.getConfig(SChampionshipReward.class);
|
||||||
|
Map<Integer,SChampionshipReward> rewardsMap = new HashMap<>();
|
||||||
|
config.forEach((k,v)->{
|
||||||
|
int minRank = v.getMinRank();
|
||||||
|
int maxRank = v.getMaxRank();
|
||||||
|
while (minRank<=maxRank){
|
||||||
|
rewardsMap.put(minRank++,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
int rank=1;
|
||||||
|
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CHAMPION_BET_RANK, Integer.toString(1), 0, -1);
|
||||||
|
Map<Integer, SArenaRobotConfig> robotConfigMap = STableManager.getConfig(SArenaRobotConfig.class);
|
||||||
|
int nowTime = (int)(TimeUtils.now()/1000);
|
||||||
|
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
|
||||||
|
String uidStr = item.getValue();
|
||||||
|
int uid = Integer.parseInt(uidStr);
|
||||||
|
if(robotConfigMap.containsKey(uid)){
|
||||||
|
rank++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
SChampionshipReward sChampionshipReward = rewardsMap.get(rank);
|
||||||
|
String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title");
|
||||||
|
String content = SErrorCodeEerverConfig.getI18NMessage("champion_reward_txt",new Object[]{rank++});
|
||||||
|
MailLogic.getInstance().sendMail(user.getId(),title,content,ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()),nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,11 +305,26 @@ public class ChampionshipLogic {
|
||||||
}.getType();
|
}.getType();
|
||||||
Object championJoins = RedisUtil.getInstence().get(key);*/
|
Object championJoins = RedisUtil.getInstence().get(key);*/
|
||||||
|
|
||||||
/* start();
|
// start();
|
||||||
List<Integer> memberIds = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "", Integer.toString(1), List.class);
|
/* for(int i=1;i<8;i++){
|
||||||
System.out.println();*/
|
roundTimes=i;
|
||||||
|
selectToBattle();
|
||||||
|
switchBet();
|
||||||
|
scoreToRedis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
selectToJoinFinal();
|
||||||
|
schedule=2;
|
||||||
|
for(int i=8;i<13;i++){
|
||||||
|
roundTimes=i;
|
||||||
|
selectToBattle();
|
||||||
|
switchBet();
|
||||||
|
scoreToRedis();
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,7 +377,7 @@ public class ChampionshipLogic {
|
||||||
enemyId = arenaRecord.getAttackId();
|
enemyId = arenaRecord.getAttackId();
|
||||||
fightResult=1^fightResult;
|
fightResult=1^fightResult;
|
||||||
}
|
}
|
||||||
if(progress%3 != 0){
|
if(progress%10%4 != 0){
|
||||||
fightResult =-1;
|
fightResult =-1;
|
||||||
}
|
}
|
||||||
builder.setChampionBattleInfo(CommonProto.ChampionBattleInfo.newBuilder()
|
builder.setChampionBattleInfo(CommonProto.ChampionBattleInfo.newBuilder()
|
||||||
|
|
@ -349,6 +390,38 @@ public class ChampionshipLogic {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void getChampionBetInfo(ISession session,int type) throws Exception {
|
||||||
|
int uid = session.getUid();
|
||||||
|
String selectIdForRedis = getSelectIdForRedis();
|
||||||
|
ArenaInfoProto.ChampionGetBetResponse.Builder builder = ArenaInfoProto.ChampionGetBetResponse.newBuilder();
|
||||||
|
if(!StringUtil.isEmpty(selectIdForRedis)){
|
||||||
|
builder.setChampionBetInfo(getBetOdds());
|
||||||
|
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_JOIN, "", selectIdForRedis, ArenaRecord.class);
|
||||||
|
if(type == 0){
|
||||||
|
int fightResult=arenaRecord.getFightResult();
|
||||||
|
if(progress%10%4 != 0){
|
||||||
|
fightResult =-1;
|
||||||
|
}
|
||||||
|
int myGuessID = arenaRecord.getAttackId();
|
||||||
|
Integer coins = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectIdForRedis + ":" +myGuessID, Integer.class);
|
||||||
|
if(coins == null) {
|
||||||
|
myGuessID = arenaRecord.getDefUid();
|
||||||
|
coins = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), selectIdForRedis + ":" +myGuessID, Integer.class);
|
||||||
|
}
|
||||||
|
if(coins == null){
|
||||||
|
myGuessID = 0;
|
||||||
|
}
|
||||||
|
builder.setChampionBattleInfo(CommonProto.ChampionBattleInfo.newBuilder()
|
||||||
|
.setMyInfo(getChampionBattleInfo(arenaRecord.getAttackId()))
|
||||||
|
.setEnemyInfo(getChampionBattleInfo(arenaRecord.getDefUid()))
|
||||||
|
.setResult(fightResult)
|
||||||
|
.build());
|
||||||
|
builder.setWinUid(myGuessID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) throws Exception {
|
private static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) throws Exception {
|
||||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid);
|
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid);
|
||||||
if(sArenaRobotConfig!=null){
|
if(sArenaRobotConfig!=null){
|
||||||
|
|
@ -356,6 +429,9 @@ public class ChampionshipLogic {
|
||||||
}
|
}
|
||||||
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){
|
||||||
|
return PlayerLogic.getInstance().getUserTeamOneInfo(uid,201);
|
||||||
|
}
|
||||||
|
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||||
|
|
@ -441,6 +517,7 @@ public class ChampionshipLogic {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ArenaInfoProto.ChampionGetMyTeamInfoResponse build = ArenaInfoProto.ChampionGetMyTeamInfoResponse.newBuilder().addAllChampionTeamPersonInfo(championTeamPersonInfoList).build();
|
ArenaInfoProto.ChampionGetMyTeamInfoResponse build = ArenaInfoProto.ChampionGetMyTeamInfoResponse.newBuilder().addAllChampionTeamPersonInfo(championTeamPersonInfoList).build();
|
||||||
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_MYTEAM_RESPONSE_VALUE,build,true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -449,16 +526,33 @@ public class ChampionshipLogic {
|
||||||
//查看我的战斗记录
|
//查看我的战斗记录
|
||||||
public static void viewAllMyBattleInfo(ISession session) throws Exception {
|
public static void viewAllMyBattleInfo(ISession session) throws Exception {
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
List<String> championshipIds = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_MY_BATTLLE_IDS,"",Integer.toString(uid),List.class);
|
Map<String, Integer> mapValues = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(uid), String.class, Integer.class);
|
||||||
List<Object> ids = new ArrayList<>(championshipIds);
|
List<Object> ids = new ArrayList<>(mapValues.keySet());
|
||||||
List<ArenaRecord> myArenaRecordInfos = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class);
|
List<ArenaRecord> myArenaRecordInfos = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class);
|
||||||
|
ArenaInfoProto.ChanpionGetAllMyBattleHistoryResponse.Builder builder = ArenaInfoProto.ChanpionGetAllMyBattleHistoryResponse.newBuilder();
|
||||||
for(ArenaRecord arenaRecord : myArenaRecordInfos){
|
for(ArenaRecord arenaRecord : myArenaRecordInfos){
|
||||||
ArenaLogic.getInstance().getArenaEnemy(arenaRecord.getAttackId(),arenaRecord.getType());
|
int enemyId = arenaRecord.getDefUid();
|
||||||
|
if(arenaRecord.getDefUid() == uid){
|
||||||
|
enemyId = arenaRecord.getAttackId();
|
||||||
|
}
|
||||||
|
|
||||||
int fightResult = arenaRecord.getFightResult();
|
int fightResult = arenaRecord.getFightResult();
|
||||||
if(fightResult == -1){
|
if(roundTimes == arenaRecord.getRoundTims()){
|
||||||
continue;
|
if(progress%10%4 != 0){
|
||||||
|
fightResult =-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(fightResult == -2){
|
||||||
|
fightResult =-1;
|
||||||
|
}
|
||||||
|
if(fightResult!=-1 && enemyId!=arenaRecord.getDefUid()){
|
||||||
|
fightResult = 1^0;
|
||||||
|
}
|
||||||
|
CommonProto.ArenaEnemy arenaEnemy = ArenaLogic.getInstance().getArenaEnemy(enemyId, arenaRecord.getType());
|
||||||
|
ArenaInfoProto.ChampionTwoEnemInfo build = ArenaInfoProto.ChampionTwoEnemInfo.newBuilder().setBlueEnemy(arenaEnemy).setRoundTimes(arenaRecord.getRoundTims()).setFightResult(fightResult).build();
|
||||||
|
builder.addEnemyPairInfo(build);
|
||||||
|
}
|
||||||
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_MYHISTORY_RESPONSE_VALUE,builder.build(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void snapPlayFightInfo() throws Exception {
|
public static void snapPlayFightInfo() throws Exception {
|
||||||
|
|
@ -480,9 +574,7 @@ public class ChampionshipLogic {
|
||||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(attackId,snapTeamId,warTime,"",gameFightTypeMap.get(arenaRecord.getType()),defUid,snapTeamId);
|
PVPFightEvent pvpFightEvent = new PVPFightEvent(attackId,snapTeamId,warTime,"",gameFightTypeMap.get(arenaRecord.getType()),defUid,snapTeamId);
|
||||||
FightDispatcher.dispatcherAsync(pvpFightEvent,id);
|
FightDispatcher.dispatcherAsync(pvpFightEvent,id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -550,7 +642,8 @@ public class ChampionshipLogic {
|
||||||
int defUid = arenaRecord.getDefUid();
|
int defUid = arenaRecord.getDefUid();
|
||||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectBetId +":" + attackId,guessNum);
|
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectBetId +":" + attackId,guessNum);
|
||||||
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, "");
|
||||||
|
RedisUtil.getInstence().set(key,selectBetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getForce( MemberInfo memberInfo, Map<Integer, SArenaRobotConfig> config){
|
public static int getForce( MemberInfo memberInfo, Map<Integer, SArenaRobotConfig> config){
|
||||||
|
|
@ -578,7 +671,7 @@ public class ChampionshipLogic {
|
||||||
public static void guess(ISession session, int winUid,int chip) throws Exception {
|
public static void guess(ISession session, int winUid,int chip) throws Exception {
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
String selectUid = getSelectIdForRedis();
|
String selectUid = getSelectIdForRedis();
|
||||||
if(progress%3!=2 || StringUtil.isEmpty(selectUid)){
|
if(progress%10%4!=2 || 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.SYS_ERROR_CODE);
|
||||||
}
|
}
|
||||||
|
|
@ -669,43 +762,75 @@ public class ChampionshipLogic {
|
||||||
*
|
*
|
||||||
* @param session
|
* @param session
|
||||||
*/
|
*/
|
||||||
public static void viewMGuessHistory(ISession session){
|
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, Integer> betHistorys = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), String.class, Integer.class);
|
||||||
|
ArenaInfoProto.ChampionGetAllMyBetInfoResponse.Builder builder = ArenaInfoProto.ChampionGetAllMyBetInfoResponse.newBuilder();
|
||||||
if(!betHistorys.isEmpty()){
|
if(!betHistorys.isEmpty()){
|
||||||
|
List<String> guessIds = new ArrayList<>(betHistorys.size());
|
||||||
betHistorys.forEach((idAndBet,coins)->{
|
betHistorys.forEach((idAndBet,coins)->{
|
||||||
String[] idAndBetSplit = idAndBet.split(":");
|
String[] idAndBetSplit = idAndBet.split(":");
|
||||||
String id = idAndBetSplit[0];
|
String id = idAndBetSplit[0];
|
||||||
Integer betUid = Integer.parseInt(idAndBetSplit[1]);
|
guessIds.add(id);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
List<Object> ids = new ArrayList<>(guessIds);
|
||||||
|
List<ArenaRecord> arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class);
|
||||||
|
String selectIdForRedis = getSelectIdForRedis();
|
||||||
|
for(ArenaRecord arenaRecord: arenaRecords){
|
||||||
|
CommonProto.ArenaEnemy attackEnemy = ArenaLogic.getInstance().getArenaEnemy(arenaRecord.getAttackId(), arenaRecord.getType());
|
||||||
|
CommonProto.ArenaEnemy defEnemy = ArenaLogic.getInstance().getArenaEnemy(arenaRecord.getDefUid(), arenaRecord.getType());
|
||||||
|
int fightResult = arenaRecord.getFightResult();
|
||||||
|
int guessState = 3;
|
||||||
|
if(arenaRecord.getId().equals(selectIdForRedis)){
|
||||||
|
if(progress%10%4!=0){
|
||||||
|
fightResult=-1;
|
||||||
}
|
}
|
||||||
|
if(progress%10%4 == 4){
|
||||||
|
guessState=0;
|
||||||
|
}
|
||||||
|
if(progress%10%4 == 3){
|
||||||
|
guessState=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(fightResult == -2){
|
||||||
|
fightResult =-1;
|
||||||
|
}
|
||||||
|
if(fightResult>=0){
|
||||||
|
int winner = arenaRecord.getAttackId();
|
||||||
|
if(fightResult == 0){
|
||||||
|
winner = arenaRecord.getDefUid();
|
||||||
|
}
|
||||||
|
Integer coins = betHistorys.get(arenaRecord.getId()+ ":" + winner);
|
||||||
|
if(coins!=null){
|
||||||
|
guessState = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.addChampionMyBetDetails(ArenaInfoProto.ChampionMyBetDetail.newBuilder().setBetResult(guessState).setEnemyPairInfo(
|
||||||
|
ArenaInfoProto.ChampionTwoEnemInfo.newBuilder().setRedEnemy(attackEnemy).setBlueEnemy(defEnemy).setFightResult(fightResult)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_MYALL_BET_RESPONSE_VALUE,builder.build(),true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 向全服玩家广播赔率
|
|
||||||
*/
|
|
||||||
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);
|
||||||
Double attackCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + arenaRecord.getAttackId());
|
Double attackCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + arenaRecord.getAttackId());
|
||||||
Double defCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + arenaRecord.getDefUid());
|
Double defCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + arenaRecord.getDefUid());
|
||||||
/* double totalCoins = attackCoins + defCoins;
|
|
||||||
double attackRate = totalCoins/attackCoins;
|
|
||||||
double defRate = totalCoins/defCoins;
|
|
||||||
DecimalFormat df = new DecimalFormat("0.00");
|
|
||||||
String attackRateStr = df.format(attackRate);
|
|
||||||
String defRateStr = df.format(defRate);*/
|
|
||||||
return CommonProto.ChampionBetInfo.newBuilder().setBlueCoins(defCoins.intValue()).setRedCoins(attackCoins.intValue()).setId(selectUid).build();
|
return CommonProto.ChampionBetInfo.newBuilder().setBlueCoins(defCoins.intValue()).setRedCoins(attackCoins.intValue()).setId(selectUid).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo
|
//todo
|
||||||
public static Map<Integer, List<Integer>> getMermberTeam(){
|
public static Map<Integer, List<Integer>> getMermberTeam(){
|
||||||
return new HashMap<>();
|
Type type = new TypeToken<List<Integer>>() {
|
||||||
|
}.getType();
|
||||||
|
return RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_CHOSE_TEAM_INFO,"",Integer.class,type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -741,15 +866,20 @@ public class ChampionshipLogic {
|
||||||
arenaRecord.setAttackId(attackUid);
|
arenaRecord.setAttackId(attackUid);
|
||||||
arenaRecord.setDefUid(defUid);
|
arenaRecord.setDefUid(defUid);
|
||||||
arenaRecord.setType(type);
|
arenaRecord.setType(type);
|
||||||
|
arenaRecord.setRoundTims(roundTimes);
|
||||||
arenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
arenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{ //决赛
|
}else{ //决赛
|
||||||
Map<Integer, List> finalmemberOfTeam = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_FINAL_TEAM_INFO, "", Integer.class, List.class);
|
Type valueType = new TypeToken<List<Integer>>() {
|
||||||
|
}.getType();
|
||||||
|
Map<Integer, List<Integer>> finalmemberOfTeam = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_FINAL_TEAM_INFO, "", Integer.class, valueType);
|
||||||
|
Map<Integer, MemberInfo> allJoinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class);
|
||||||
List<MemberInfo> possibleJoin = new ArrayList<>();
|
List<MemberInfo> possibleJoin = new ArrayList<>();
|
||||||
for(List<MemberInfo> memberOfOneTeam : finalmemberOfTeam.values()){
|
for(List<Integer> memberOfOneTeam : finalmemberOfTeam.values()){
|
||||||
memberOfOneTeam.forEach(memberInfo -> {
|
memberOfOneTeam.forEach(id -> {
|
||||||
|
MemberInfo memberInfo = allJoinMembers.get(id);
|
||||||
if(memberInfo.getFinalScore()>0){
|
if(memberInfo.getFinalScore()>0){
|
||||||
possibleJoin.add(memberInfo);
|
possibleJoin.add(memberInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -770,12 +900,24 @@ public class ChampionshipLogic {
|
||||||
arenaRecord.setAttackId(attackUid);
|
arenaRecord.setAttackId(attackUid);
|
||||||
arenaRecord.setDefUid(defUid);
|
arenaRecord.setDefUid(defUid);
|
||||||
arenaRecord.setType(type);
|
arenaRecord.setType(type);
|
||||||
|
arenaRecord.setRoundTims(roundTimes);
|
||||||
arenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
arenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_ARENA_RECORD,"",arenaRecordMap);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_ARENA_RECORD,"",arenaRecordMap);
|
||||||
arenaRecordIds.addAll(arenaRecordMap.keySet());
|
arenaRecordIds.addAll(arenaRecordMap.keySet());
|
||||||
RedisUtil.getInstence().lSet(RedisKey.CHAMPION_CUR_JOIN_IDS,"",arenaRecordIds);
|
RedisUtil.getInstence().lSet(RedisKey.CHAMPION_CUR_JOIN_IDS,"",arenaRecordIds);
|
||||||
|
Map<Integer, SArenaRobotConfig> robotConfigMap = STableManager.getConfig(SArenaRobotConfig.class);
|
||||||
|
arenaRecordMap.forEach((id,arenaRecord)->{
|
||||||
|
int defUid = arenaRecord.getDefUid();
|
||||||
|
int attackId = arenaRecord.getAttackId();
|
||||||
|
if(!robotConfigMap.containsKey(defUid)){
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(defUid),id, 0);
|
||||||
|
}
|
||||||
|
if(!robotConfigMap.containsKey(attackId)){
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(attackId),id, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -820,6 +962,12 @@ public class ChampionshipLogic {
|
||||||
for(int i=0;i<finalmemberOfTeam.size();i++){
|
for(int i=0;i<finalmemberOfTeam.size();i++){
|
||||||
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_FINAL_TEAM_INFO, "",Integer.toString(i),finalmemberOfTeam.get(i));
|
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_FINAL_TEAM_INFO, "",Integer.toString(i),finalmemberOfTeam.get(i));
|
||||||
}
|
}
|
||||||
|
Map<String,MemberInfo> finalMemberInfoMap = new HashMap<>();
|
||||||
|
canJoinFinal.forEach(memberInfo -> {
|
||||||
|
finalMemberInfoMap.put(Integer.toString(memberInfo.getUid()),memberInfo);
|
||||||
|
});
|
||||||
|
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_JOIN, "",finalMemberInfoMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -855,7 +1003,7 @@ public class ChampionshipLogic {
|
||||||
|
|
||||||
|
|
||||||
//获取排行榜信息
|
//获取排行榜信息
|
||||||
public void getWorldRankByPage(ISession session,int page) throws Exception {
|
public static void getWorldRankByPage(ISession session,int page) throws Exception {
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -953,7 +1101,7 @@ public class ChampionshipLogic {
|
||||||
long now = TimeUtils.now();
|
long now = TimeUtils.now();
|
||||||
long startTime = timeControllerOfFunction.getStartTime();
|
long startTime = timeControllerOfFunction.getStartTime();
|
||||||
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
||||||
int duration = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime();
|
int duration = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
||||||
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;
|
||||||
roundTimes = (int) round;
|
roundTimes = (int) round;
|
||||||
|
|
@ -961,7 +1109,7 @@ public class ChampionshipLogic {
|
||||||
int progressTmp;
|
int progressTmp;
|
||||||
|
|
||||||
if(diff<0){ //选拔赛
|
if(diff<0){ //选拔赛
|
||||||
progressTmp =9 + progressState;
|
progressTmp =100 + roundTimes*10 + progressState;
|
||||||
schedule=1;
|
schedule=1;
|
||||||
}else {//决赛
|
}else {//决赛
|
||||||
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
|
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
|
||||||
|
|
@ -969,7 +1117,7 @@ public class ChampionshipLogic {
|
||||||
if(roundTimes<2){
|
if(roundTimes<2){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
progressTmp =roundTimes*100 + progressState;
|
progressTmp = 200 + (int)diff*10 + progressState;
|
||||||
if(schedule==1){ // 刚开始进入决赛,选拔出选手
|
if(schedule==1){ // 刚开始进入决赛,选拔出选手
|
||||||
selectToJoinFinal();
|
selectToJoinFinal();
|
||||||
}
|
}
|
||||||
|
|
@ -983,14 +1131,20 @@ public class ChampionshipLogic {
|
||||||
progress = progressTmp;
|
progress = progressTmp;
|
||||||
RedisUtil.getInstence().set(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_PROGRESS,""),Integer.toString(progress));
|
RedisUtil.getInstence().set(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_PROGRESS,""),Integer.toString(progress));
|
||||||
|
|
||||||
if(progress%3==0){
|
if(progress%10%4==0){
|
||||||
selectToBattle();
|
selectToBattle();
|
||||||
}
|
}
|
||||||
if(progress%3==1){ //竞猜阶段 后台自动运行战斗
|
if(progress%10%4==1){ //竞猜阶段 后台自动运行战斗
|
||||||
switchBet();
|
switchBet();
|
||||||
}else if(progress%3==2){ //比赛阶段
|
}else if(progress%10%4==3){ //结算阶段
|
||||||
//等待玩家数据分数入redis
|
//等待玩家数据分数入redis
|
||||||
scoreToRedis();
|
scoreToRedis();
|
||||||
|
sendBetReward();
|
||||||
|
}
|
||||||
|
ArenaInfoProto.ChampionProgressUpdateIndication build = ArenaInfoProto.ChampionProgressUpdateIndication.newBuilder().setEndTime(endTime).setProgress(progress).build();
|
||||||
|
//向全服玩家广播进度变更信息
|
||||||
|
for(ISession session : OnlineUserManager.sessionMap.values()){
|
||||||
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.CHAMPION_PROGRESS_UPDATE_INDICATION_VALUE,build,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1002,8 +1156,11 @@ public class ChampionshipLogic {
|
||||||
if(progressState == 1){
|
if(progressState == 1){
|
||||||
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime();
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime();
|
||||||
}
|
}
|
||||||
|
if(progressState == 2){
|
||||||
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime();
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime();
|
||||||
}
|
}
|
||||||
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1012,10 +1169,13 @@ public class ChampionshipLogic {
|
||||||
if(progressTmp<sChampionshipSetting.getPrepareTime()){
|
if(progressTmp<sChampionshipSetting.getPrepareTime()){
|
||||||
return 0;// 准备
|
return 0;// 准备
|
||||||
}
|
}
|
||||||
if(progressTmp>=sChampionshipSetting.getPrepareTime() && progressTmp<sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime()){
|
if(progressTmp<sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime()){
|
||||||
return 1;//竞猜
|
return 1;//竞猜
|
||||||
}
|
}
|
||||||
|
if(progressTmp<sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime()+sChampionshipSetting.getBattleTime()){
|
||||||
return 2;//比赛
|
return 2;//比赛
|
||||||
}
|
}
|
||||||
|
return 3; //战斗结算
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,4 +97,12 @@ public class ArenaRecord {
|
||||||
public void setType(int type) {
|
public void setType(int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRoundTims() {
|
||||||
|
return roundTims;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoundTims(int roundTims) {
|
||||||
|
this.roundTims = roundTims;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ljsd.jieling.logic.fight;
|
package com.ljsd.jieling.logic.fight;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
import com.ljsd.jieling.logic.dao.ArenaRecord;
|
import com.ljsd.jieling.logic.dao.ArenaRecord;
|
||||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||||
|
|
@ -17,6 +19,7 @@ public class AreFightPro implements EndFightProcessor {
|
||||||
failerUid = arenaRecord.getAttackId();
|
failerUid = arenaRecord.getAttackId();
|
||||||
}
|
}
|
||||||
ChampionshipLogic.setScoreForSuccess(winnerUid,failerUid);
|
ChampionshipLogic.setScoreForSuccess(winnerUid,failerUid);
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_ARENA_RECORD,"",arenaRecord.getId(),arenaRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArenaRecord getArenaRecord() {
|
public ArenaRecord getArenaRecord() {
|
||||||
|
|
|
||||||
|
|
@ -444,6 +444,40 @@ public class PlayerLogic {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommonProto.TeamOneInfo.Builder getUserTeamOneInfo(int uid,int teamId) throws Exception {
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||||
|
CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder()
|
||||||
|
.setHead(playerManager.getHead())
|
||||||
|
.setHeadFrame(playerManager.getHeadFrame())
|
||||||
|
.setLevel(playerManager.getLevel())
|
||||||
|
.setName(playerManager.getNickName()).setUid(uid);
|
||||||
|
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||||
|
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
|
||||||
|
teamInfo.setTotalForce(HeroLogic.getInstance().calTeamTotalForce(user,teamId,false));
|
||||||
|
if(teamPosManager.getTeamPosForPoken().get(teamId)!=null&&teamPosManager.getTeamPosForPoken().get(teamId).size()>0){
|
||||||
|
for(TeamPosForPokenInfo posForPokenInfo:teamPosManager.getTeamPosForPoken().get(teamId)){
|
||||||
|
teamInfo.addPokemonInfos(posForPokenInfo.getPokenId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(teamPosManager.getTeamPosForHero().containsKey(teamId)){
|
||||||
|
for (TeamPosHeroInfo heroInfo:teamPosManager.getTeamPosForHero().get(teamId)) {
|
||||||
|
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
|
||||||
|
teamInfo.addTeam(CBean2Proto.getSimpleTeamInfoByHero(hero));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||||
|
if(guildId!=0){
|
||||||
|
if(GuilidManager.guildInfoMap.containsKey(guildId)){
|
||||||
|
String name = GuilidManager.guildInfoMap.get(guildId).getName();
|
||||||
|
oneInfo.setGuildName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
oneInfo.setTeam(teamInfo);
|
||||||
|
return oneInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public CommonProto.TeamOneInfo.Builder getRobotTeamInfo(SArenaRobotConfig sArenaRobotConfig){
|
public CommonProto.TeamOneInfo.Builder getRobotTeamInfo(SArenaRobotConfig sArenaRobotConfig){
|
||||||
CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder()
|
CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder()
|
||||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||||
|
|
@ -476,36 +510,7 @@ public class PlayerLogic {
|
||||||
if(sArenaRobotConfig!=null){
|
if(sArenaRobotConfig!=null){
|
||||||
oneInfo=getRobotTeamInfo(sArenaRobotConfig);
|
oneInfo=getRobotTeamInfo(sArenaRobotConfig);
|
||||||
}else{
|
}else{
|
||||||
User user = UserManager.getUser(id);
|
oneInfo = getUserTeamOneInfo(id, teamId);
|
||||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
|
||||||
oneInfo = CommonProto.TeamOneInfo.newBuilder()
|
|
||||||
.setHead(playerManager.getHead())
|
|
||||||
.setHeadFrame(playerManager.getHeadFrame())
|
|
||||||
.setLevel(playerManager.getLevel())
|
|
||||||
.setName(playerManager.getNickName()).setUid(id);
|
|
||||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
|
||||||
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
|
|
||||||
teamInfo.setTotalForce(HeroLogic.getInstance().calTeamTotalForce(user,teamId,false));
|
|
||||||
if(teamPosManager.getTeamPosForPoken().get(teamId)!=null&&teamPosManager.getTeamPosForPoken().get(teamId).size()>0){
|
|
||||||
for(TeamPosForPokenInfo posForPokenInfo:teamPosManager.getTeamPosForPoken().get(teamId)){
|
|
||||||
teamInfo.addPokemonInfos(posForPokenInfo.getPokenId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(teamPosManager.getTeamPosForHero().containsKey(teamId)){
|
|
||||||
for (TeamPosHeroInfo heroInfo:teamPosManager.getTeamPosForHero().get(teamId)) {
|
|
||||||
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
|
|
||||||
teamInfo.addTeam(CBean2Proto.getSimpleTeamInfoByHero(hero));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
|
||||||
if(guildId!=0){
|
|
||||||
if(GuilidManager.guildInfoMap.containsKey(guildId)){
|
|
||||||
String name = GuilidManager.guildInfoMap.get(guildId).getName();
|
|
||||||
oneInfo.setGuildName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
oneInfo.setTeam(teamInfo);
|
|
||||||
if(UserManager.getUser(session.getUid()).getFriendManager().getMyApplyFriends().contains(id)){
|
if(UserManager.getUser(session.getUid()).getFriendManager().getMyApplyFriends().contains(id)){
|
||||||
oneInfo.setIsApplyed(1);
|
oneInfo.setIsApplyed(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.util;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.protobuf.GeneratedMessage;
|
import com.google.protobuf.GeneratedMessage;
|
||||||
|
import com.googlecode.protobuf.format.JsonFormat;
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.chat.messge.MessageCache;
|
import com.ljsd.jieling.chat.messge.MessageCache;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
|
|
@ -39,7 +40,7 @@ public class MessageUtil {
|
||||||
backMessage = new byte[0];
|
backMessage = new byte[0];
|
||||||
} else {
|
} else {
|
||||||
backMessage = generatedMessage.toByteArray();
|
backMessage = generatedMessage.toByteArray();
|
||||||
//LOGGER.info(JsonFormat.printToString(generatedMessage));
|
LOGGER.info(JsonFormat.printToString(generatedMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
|
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public class SChampionshipSetting implements BaseConfig {
|
||||||
|
|
||||||
private int battleTime;
|
private int battleTime;
|
||||||
|
|
||||||
|
private int settleTime;
|
||||||
|
|
||||||
private int warTime;
|
private int warTime;
|
||||||
|
|
||||||
private int arenaPercent;
|
private int arenaPercent;
|
||||||
|
|
@ -104,4 +106,8 @@ public class SChampionshipSetting implements BaseConfig {
|
||||||
public int getKnockoutGroup() {
|
public int getKnockoutGroup() {
|
||||||
return knockoutGroup;
|
return knockoutGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSettleTime() {
|
||||||
|
return settleTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue