巅峰赛
parent
106af8c853
commit
b28d31d8ae
|
|
@ -0,0 +1,4 @@
|
|||
package com.ljsd.fight;
|
||||
|
||||
public class CheckFightData {
|
||||
}
|
||||
|
|
@ -24,6 +24,8 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
private Set<Integer> notDelete;
|
||||
private int initPos;
|
||||
private SGameSetting gameSetting;
|
||||
private SChampionshipSetting sChampionshipSetting;
|
||||
|
||||
|
||||
private int maxLevel; //百味居、工坊相关
|
||||
public Map<Integer, Map<Integer, SWorkShopTechnology>> sWorkTechMapByTechIdAndLevelTmp;
|
||||
|
|
@ -31,6 +33,8 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
|
||||
private Map<Integer, Map<Integer, List<SGlobalSystemConfig>>> sGlobalSystemConfigMapByTypeAndConditionMap;
|
||||
|
||||
public Map<Integer, List<int[]>> matrixforGroupInfo;
|
||||
|
||||
@Override
|
||||
public void registConfigs(Set<String> registConfigs) {
|
||||
registConfigs.add(SGameSetting.class.getAnnotation(Table.class).name());
|
||||
|
|
@ -39,6 +43,7 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
registConfigs.add(SGuildSetting.class.getAnnotation(Table.class).name());
|
||||
registConfigs.add(SWorkShopSetting.class.getAnnotation(Table.class).name());
|
||||
registConfigs.add(SWorkShopSetting.class.getAnnotation(Table.class).name());
|
||||
registConfigs.add(SChampionshipSetting.class.getAnnotation(Table.class).name());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -176,6 +181,9 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
}
|
||||
}
|
||||
|
||||
sChampionshipSetting = STableManager.getConfig(SChampionshipSetting.class).get(1);
|
||||
gen(sChampionshipSetting.getTrialsGroup());
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("SWorkShopTechnology init fail",e);
|
||||
}
|
||||
|
|
@ -183,10 +191,55 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void gen(int nums){
|
||||
int[][] result = new int[nums*nums/2][];
|
||||
int j=0;
|
||||
for(int i=1;i<=nums/2;i++){
|
||||
Set<Integer> cache = new HashSet<>();
|
||||
for(int k=1;k<=nums;k++){
|
||||
while (cache.add(k)){
|
||||
result[j] = new int[2];
|
||||
result[j][0] =k;
|
||||
result[j][1] =(k+i)%nums;
|
||||
if( result[j][1] ==0){
|
||||
result[j][1]=nums;
|
||||
}
|
||||
k= result[j][1];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Integer, List<int[]>> matrix = new HashMap<>();
|
||||
for(int i=0;i<result.length;i++){
|
||||
int position =2*(i / nums) +1 + i%2;
|
||||
if(position == nums){
|
||||
continue;
|
||||
}
|
||||
if(!matrix.containsKey(position)){
|
||||
matrix.put(position,new ArrayList<>());
|
||||
}
|
||||
List<int[]> ints = matrix.get(position);
|
||||
ints.add(result[i]);
|
||||
}
|
||||
|
||||
matrixforGroupInfo = matrix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<Integer, Map<Integer, List<SGlobalSystemConfig>>> getsGlobalSystemConfigMapByTypeAndConditionMap() {
|
||||
return sGlobalSystemConfigMapByTypeAndConditionMap;
|
||||
}
|
||||
|
||||
public SChampionshipSetting getsChampionshipSetting() {
|
||||
return sChampionshipSetting;
|
||||
}
|
||||
|
||||
public Map<Integer, List<int[]>> getMatrixforGroupInfo() {
|
||||
return matrixforGroupInfo;
|
||||
}
|
||||
|
||||
public Set<Integer> getNotDelete() {
|
||||
return notDelete;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public interface GlobalsDef {
|
|||
//队伍
|
||||
int TEAM_ARENA_DEFENSE =101;
|
||||
int BLOODY_TEAM =701; //血战队伍
|
||||
int CHAMPION_ATTACK_TEAM =801; //血战队伍
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,14 @@ public class RedisKey {
|
|||
public final static String CDKEY = "CDKEY";
|
||||
public final static String GLOBAL_SYS_PRO = "GLOBAL_SYS_PRO";
|
||||
|
||||
public final static String CHAMPION_FIGHT = "CHAMPION_FIGHT";
|
||||
public final static String CHAMPION_RANK = "CHAMPION_RANK";
|
||||
public final static String CHAMPION_JOIN = "CHAMPION_JOIN";
|
||||
|
||||
public final static String CHAMPION_BET_MINE = "CHAMPION_BET_MINE"; // 我的竞猜
|
||||
public final static String CHAMPION_BET_ALL = "CHAMPION_BET_ALL"; // 竞猜信息
|
||||
public final static String CHAMPION_BET_RANK = "CHAMPION_BET_RANK"; // 巅峰赛排名
|
||||
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ public interface BIReason {
|
|||
|
||||
int VIP_LEVEL_REWARD=59;// VIP等級提升补发道具
|
||||
|
||||
int CHAMPIION_BET_REWARD = 60 ; // 巅峰赛竞猜系统赠送
|
||||
|
||||
int CHAMPIION_BET_WIN_REWARD = 60 ; // 巅峰赛竞猜赢取
|
||||
|
||||
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
|
||||
int SECRETBOX_CONSUME = 1001;//秘盒抽卡
|
||||
|
|
@ -182,4 +186,9 @@ public interface BIReason {
|
|||
int FAMILY_RENAME = 1045;//公会改名
|
||||
|
||||
|
||||
int CHAMPIION_BET_CONSUME = 1046; //巅峰赛竞猜消耗
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler;
|
|||
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
|
|
@ -84,6 +85,10 @@ public class GlobalDataManaager implements IManager {
|
|||
return openTimeOfFuntionCache.containsKey(id);
|
||||
}
|
||||
|
||||
public TimeControllerOfFunction getTimeControllerOfFunctionByFunctinoId(int functionId){
|
||||
return openTimeOfFuntionCache.get(functionId);
|
||||
}
|
||||
|
||||
public void checkSystemFunctioIsOpen() throws Exception {
|
||||
long now = TimeUtils.now();
|
||||
Map<Integer, SGlobalSystemConfig> sGlobalSystemConfigMap = STableManager.getConfig(SGlobalSystemConfig.class);
|
||||
|
|
@ -229,6 +234,7 @@ public class GlobalDataManaager implements IManager {
|
|||
new UserLevelEventHandler();
|
||||
new RemoveEventHeroHandler();
|
||||
new FightMainEventHandler();
|
||||
ChampionshipLogic.whenStart();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@ public class ArenaLogic {
|
|||
private int curSeason;
|
||||
private int viewSeason;
|
||||
|
||||
|
||||
|
||||
public int getCurSeason() {
|
||||
return curSeason;
|
||||
}
|
||||
|
||||
public void getArenaInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
|
|
@ -104,52 +105,56 @@ public class ArenaLogic {
|
|||
for(ArenaEnemy arenaEnemy : arenaEnemies){
|
||||
int enemyId = arenaEnemy.getEnemyId();
|
||||
int enemyType = arenaEnemy.getEnemyType();
|
||||
if(enemyType == 0){ //机器人
|
||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(enemyId);
|
||||
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).build();
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(enemyId)
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(sArenaRobotConfig.getRobotName())
|
||||
.setScore(sArenaRobotConfig.getRobotScore())
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.build();
|
||||
arenaEnemyList.add(CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build());
|
||||
}else{
|
||||
User user = UserManager.getUser(enemyId);
|
||||
int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, GlobalsDef.TEAM_ARENA_DEFENSE,false);
|
||||
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.TEAM_ARENA_DEFENSE);
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
List<Integer> heroTids = new ArrayList<>(teamPosHeroInfoList.size());
|
||||
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){
|
||||
score = SArenaSetting.getSArenaSetting().getScore();
|
||||
}
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(enemyId)
|
||||
.setLevel(playerInfoManager.getLevel())
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setScore(score)
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setTotalForce(totalForce)
|
||||
.build();
|
||||
arenaEnemyList.add(CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build());
|
||||
}
|
||||
arenaEnemyList.add(getArenaEnemy(enemyId,enemyType));
|
||||
}
|
||||
return arenaEnemyList;
|
||||
}
|
||||
|
||||
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()
|
||||
.setUid(enemyId)
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(sArenaRobotConfig.getRobotName())
|
||||
.setScore(sArenaRobotConfig.getRobotScore())
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.build();
|
||||
return CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build();
|
||||
}else{
|
||||
User user = UserManager.getUser(enemyId);
|
||||
int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, GlobalsDef.TEAM_ARENA_DEFENSE,false);
|
||||
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.TEAM_ARENA_DEFENSE);
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
List<Integer> heroTids = new ArrayList<>(teamPosHeroInfoList.size());
|
||||
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){
|
||||
score = SArenaSetting.getSArenaSetting().getScore();
|
||||
}
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(enemyId)
|
||||
.setLevel(playerInfoManager.getLevel())
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setScore(score)
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setTotalForce(totalForce)
|
||||
.build();
|
||||
return CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void challenge(ISession session,int challengeUid,int teamId,int skipFight) throws Exception {
|
||||
if(curSeason == 0){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,636 @@
|
|||
package com.ljsd.jieling.logic.championship;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.*;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.ArenaInfoProto;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import config.*;
|
||||
;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.DefaultTypedTuple;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class ChampionshipLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class);
|
||||
private static int progress = -1; //阶段
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
private static int startTime;
|
||||
private static int endTime;
|
||||
private static int roundTimes;
|
||||
|
||||
private static Map<Integer,GameFightType> gameFightTypeMap = new HashMap<>();
|
||||
static {
|
||||
gameFightTypeMap.put(0,GameFightType.ArenaRobotFight);
|
||||
gameFightTypeMap.put(1,GameFightType.ArenaPersonFight);
|
||||
gameFightTypeMap.put(2,GameFightType.Arena2RobotFight);
|
||||
}
|
||||
|
||||
|
||||
static class MemberInfo{
|
||||
private int uid;
|
||||
private int type;
|
||||
private int score; // 选拔积分
|
||||
private FamilyFightInfo fightInfo;
|
||||
|
||||
public MemberInfo( int uid, int type) {
|
||||
this.uid = uid;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public FamilyFightInfo getFightInfo() {
|
||||
return fightInfo;
|
||||
}
|
||||
|
||||
public void setFightInfo(FamilyFightInfo fightInfo) {
|
||||
this.fightInfo = fightInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<Integer,MemberInfo> joinMembers;
|
||||
|
||||
private static List<List<MemberInfo>> memberOfTeam;
|
||||
|
||||
private static Map<String,ArenaRecord> arenaRecordMap = new HashMap<>();
|
||||
|
||||
private static Map<String,ArenaRecord> curArenaRecordMap = new HashMap<>();
|
||||
|
||||
private static String selectUid = "";
|
||||
|
||||
|
||||
/**
|
||||
* 巅峰赛开始准备工作
|
||||
* 1.数据准备:制作参与巅峰赛
|
||||
* 2.告知前端现在是准备阶段,并告诉我是否加入了巅峰赛
|
||||
*/
|
||||
public static void whenStart() throws Exception {
|
||||
progress = 0;
|
||||
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
||||
int championshipPlayer = sChampionshipSetting.getChampionshipPlayer();
|
||||
int curSeason = ArenaLogic.getInstance().getCurSeason();
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = new HashSet<>(championshipPlayer);
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, championshipPlayer);
|
||||
if(arenaRankInfoOne!=null&&!arenaRankInfoOne.isEmpty()){
|
||||
arenaRankInfo.addAll(arenaRankInfoOne);
|
||||
}
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfoForChampion= new HashSet<>();
|
||||
joinMembers = new HashMap<>(championshipPlayer);
|
||||
List<MemberInfo> memberInfos = new ArrayList<>(championshipPlayer);
|
||||
arenaRankInfo.forEach(item->{
|
||||
String uidStr = item.getValue();
|
||||
MemberInfo memberInfo = new MemberInfo(Integer.parseInt(uidStr), 0);
|
||||
joinMembers.put(Integer.parseInt(uidStr),memberInfo);
|
||||
ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(uidStr,0D);
|
||||
arenaRankInfoForChampion.add(typedTuple);
|
||||
memberInfos.add(memberInfo);
|
||||
});
|
||||
if(arenaRankInfo.size()<championshipPlayer){
|
||||
//补发机器人
|
||||
Map<Integer, SArenaRobotConfig> config = STableManager.getConfig(SArenaRobotConfig.class);
|
||||
TreeMap<Integer, SArenaRobotConfig> sArenaRobotConfigMap = new TreeMap<Integer, SArenaRobotConfig>(new Comparator<Integer>() {
|
||||
|
||||
public int compare(Integer a, Integer b) {
|
||||
int randomOne = (int) (Math.random() * 10);
|
||||
int randomTwo = (int) (Math.random() * 10);
|
||||
if(randomOne == randomTwo){
|
||||
randomOne+=1;
|
||||
}
|
||||
return randomOne - randomTwo;
|
||||
}
|
||||
});
|
||||
sArenaRobotConfigMap.putAll(config);
|
||||
int end = championshipPlayer - arenaRankInfo.size();
|
||||
for(SArenaRobotConfig sArenaRobotConfig : sArenaRobotConfigMap.values()){
|
||||
if(end--<=0){
|
||||
break;
|
||||
}
|
||||
MemberInfo memberInfo = new MemberInfo(sArenaRobotConfig.getId(), 1);
|
||||
joinMembers.put(sArenaRobotConfig.getId(),memberInfo);
|
||||
ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(Integer.toString(sArenaRobotConfig.getId()),0D);
|
||||
arenaRankInfoForChampion.add(typedTuple);
|
||||
memberInfos.add(memberInfo);
|
||||
LOGGER.info("the end={},the robotID={},the size={}",end,sArenaRobotConfig.getId(),joinMembers.size());
|
||||
}
|
||||
}
|
||||
Collections.shuffle(memberInfos);
|
||||
int index=0;
|
||||
int trialsGroup = sChampionshipSetting.getTrialsGroup();
|
||||
int nums = championshipPlayer / trialsGroup;
|
||||
List<List<MemberInfo>> memberOfTeamTmp = new ArrayList<>();
|
||||
while (nums-->0){
|
||||
memberOfTeamTmp.add(new ArrayList<>());
|
||||
}
|
||||
nums = championshipPlayer / trialsGroup;
|
||||
for(MemberInfo memberInfo : memberInfos){
|
||||
int teamId = (index++ % nums);
|
||||
memberOfTeamTmp.get(teamId).add(memberInfo);
|
||||
}
|
||||
memberOfTeam = memberOfTeamTmp;
|
||||
|
||||
|
||||
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_JOIN, "");
|
||||
RedisUtil.getInstence().del(key, RedisUtil.getInstence().getKey(RedisKey.CHAMPION_RANK, ""));
|
||||
RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK,"",arenaRankInfoForChampion);
|
||||
RedisUtil.getInstence().set(key, gson.toJson(joinMembers));
|
||||
|
||||
|
||||
//
|
||||
for(int i=1;i<8;i++){
|
||||
roundTimes=i;
|
||||
selectToBattle();
|
||||
switchBet();
|
||||
LOGGER.info("i------------------------------------->>>>>>>>>>>>>>>>>>>>{},size={}",i,curArenaRecordMap.size());
|
||||
curArenaRecordMap.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 告知前端基本信息
|
||||
* 战斗信息
|
||||
* 时间信息
|
||||
* 我是否有资格本次比赛
|
||||
* @param session
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void getChampionInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
List<String> championshipIds = new ArrayList<>();
|
||||
boolean isJoin = joinMembers.containsKey(uid);
|
||||
if(!championshipIds.isEmpty()){
|
||||
String championshipId = championshipIds.get(championshipIds.size() - 1);
|
||||
ArenaRecord arenaRecord = arenaRecordMap.get(championshipId);
|
||||
int enemyId = arenaRecord.getDefUid();
|
||||
if(enemyId == uid){
|
||||
enemyId = arenaRecord.getAttackId();
|
||||
}
|
||||
CommonProto.ArenaEnemy arenaEnemy = ArenaLogic.getInstance().getArenaEnemy(enemyId, arenaRecord.getType());
|
||||
int fightResult = arenaRecord.getFightResult(); // 0
|
||||
}
|
||||
//组装数据
|
||||
}
|
||||
|
||||
//查看我的战斗记录
|
||||
public static void viewAllMyBattleInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
List<String> championshipIds = new ArrayList<>();
|
||||
for(String championshipId : championshipIds){
|
||||
ArenaRecord arenaRecord = arenaRecordMap.get(championshipId);
|
||||
ArenaLogic.getInstance().getArenaEnemy(arenaRecord.getAttackId(),arenaRecord.getType());
|
||||
int fightResult = arenaRecord.getFightResult();
|
||||
if(fightResult == -1){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void snapPlayFightInfo() throws Exception {
|
||||
int snapTeamId = GlobalsDef.CHAMPION_ATTACK_TEAM;
|
||||
RedisUtil.getInstence().del( RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, ""));
|
||||
int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime();
|
||||
|
||||
for(ArenaRecord arenaRecord : curArenaRecordMap.values()){
|
||||
int attackId = arenaRecord.getAttackId();
|
||||
int defUid = arenaRecord.getDefUid();
|
||||
snapOneFightInfo(attackId);
|
||||
snapOneFightInfo(defUid);
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(attackId,snapTeamId,warTime,"",gameFightTypeMap.get(arenaRecord.getType()),defUid,snapTeamId);
|
||||
|
||||
long id =FightDispatcher.dispatcherAsync(pvpFightEvent);
|
||||
|
||||
EndFightProcessor endFightProcessor = new AreFightPro();
|
||||
((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord);
|
||||
FightDispatcher.getMap().put(id, endFightProcessor) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void snapOneFightInfo(int uid) throws Exception {
|
||||
int snapTeamId = 201;
|
||||
MemberInfo memberInfo = joinMembers.get(uid);
|
||||
Map<Integer, SArenaRobotConfig> config = STableManager.getConfig(SArenaRobotConfig.class);
|
||||
if(config.containsKey(uid)){
|
||||
SArenaRobotConfig sArenaRobotConfig = config.get(uid);
|
||||
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getUser(uid);
|
||||
FamilyFightInfo fightInfo = new FamilyFightInfo();
|
||||
//血量处理,buff处理
|
||||
int force = HeroLogic.getInstance().calTeamTotalForce(user, snapTeamId, false);
|
||||
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = BloodLogic.getInstance().battleRecord(user,snapTeamId, null);
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
fightInfo.setForce(force);
|
||||
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(snapTeamId);
|
||||
if(teamPosHeroInfoList==null||teamPosHeroInfoList.size()<1){
|
||||
teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(1);
|
||||
}
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
for(TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList){
|
||||
String heroId = teamPosHeroInfo.getHeroId();
|
||||
Hero hero = heroMap.get(heroId);
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero,skillSb ).toString();
|
||||
fightInfo.updateHeroSkill(heroId,heroSkill.substring(0, heroSkill.length() - 1));
|
||||
}
|
||||
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
|
||||
fightInfo.setPokenmonSkills(pokenmonSkills);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_FIGHT, "", String.valueOf(uid), fightInfo);
|
||||
memberInfo.setFightInfo(fightInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出一组用于竞猜比赛队伍信息,并向前端广播
|
||||
*/
|
||||
public static void selectBetTeam(){
|
||||
int min = Integer.MAX_VALUE;
|
||||
String selectBetId = "";
|
||||
Map<Integer, SArenaRobotConfig> config = STableManager.getConfig(SArenaRobotConfig.class);
|
||||
for(ArenaRecord arenaRecord : curArenaRecordMap.values()){
|
||||
int attackId = arenaRecord.getAttackId();
|
||||
int defUid = arenaRecord.getDefUid();
|
||||
MemberInfo attackMemberInfo = joinMembers.get(attackId);
|
||||
MemberInfo defkMemberInfo = joinMembers.get(defUid);
|
||||
int attackForce = getForce(attackMemberInfo,config);
|
||||
int defForce = getForce(defkMemberInfo,config);
|
||||
int differForce = Math.abs(attackForce - defForce);
|
||||
if(min>differForce){
|
||||
min = differForce;
|
||||
selectBetId = arenaRecord.getId();
|
||||
}
|
||||
}
|
||||
int guessNum = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getGuessNum();
|
||||
ArenaRecord arenaRecord = arenaRecordMap.get(selectBetId);
|
||||
int attackId = arenaRecord.getAttackId();
|
||||
int defUid = arenaRecord.getDefUid();
|
||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectBetId +":" + attackId,guessNum);
|
||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL,"",selectBetId +":" + defUid,guessNum);
|
||||
selectUid = selectBetId;
|
||||
|
||||
}
|
||||
|
||||
public static int getForce( MemberInfo memberInfo, Map<Integer, SArenaRobotConfig> config){
|
||||
int force = 0;
|
||||
SArenaRobotConfig sArenaRobotConfig = config.get(memberInfo.getUid());
|
||||
if(sArenaRobotConfig!=null){
|
||||
force = sArenaRobotConfig.getTotalForce();
|
||||
}else{
|
||||
force = memberInfo.getFightInfo().getForce();
|
||||
}
|
||||
return force;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 竞猜
|
||||
* 1.是否在竞猜阶段
|
||||
* 2.chip是否足够
|
||||
* @param session`
|
||||
* @param winUid 押注x胜利
|
||||
* @chip chip 筹码
|
||||
*/
|
||||
public static void guess(ISession session, int winUid,int chip) throws Exception {
|
||||
if(progress%3!=2 || StringUtil.isEmpty(selectUid)){
|
||||
return;
|
||||
}
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem();
|
||||
Map<Integer,Integer> itemCost = new HashMap<>(1);
|
||||
itemCost.put(arenaItem[0], chip);
|
||||
boolean enough = ItemUtil.itemCost(user, itemCost, BIReason.CHAMPIION_BET_CONSUME, winUid);
|
||||
if(!enough){
|
||||
return;
|
||||
}
|
||||
//我下注信息
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CHAMPION_BET_MINE,Integer.toString(uid),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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送竞猜奖
|
||||
*/
|
||||
public static void sendBetReward(){
|
||||
List<String> delKeys = new ArrayList<>(128);
|
||||
int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem();
|
||||
for(ArenaRecord arenaRecord : curArenaRecordMap.values()){
|
||||
int fightResult = arenaRecord.getFightResult();
|
||||
int winUid = arenaRecord.getDefUid();
|
||||
int failUid = arenaRecord.getAttackId();
|
||||
if(fightResult == 1){
|
||||
winUid = arenaRecord.getAttackId();
|
||||
failUid = arenaRecord.getDefUid();
|
||||
}
|
||||
Double winCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" +winUid);
|
||||
Double failCoins = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_ALL, "", selectUid + ":" + failUid);
|
||||
|
||||
double winRate = (winCoins + failCoins) / winCoins;
|
||||
Map<Integer, Integer> betPersonInfoMap = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, selectUid + ":" + winUid, Integer.class, Integer.class);
|
||||
betPersonInfoMap.forEach((betUid,coins)->{
|
||||
try {
|
||||
User user = UserManager.getUser(betUid);
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user, true, new AyncWorkerRunnable() {
|
||||
@Override
|
||||
public void work(User user) throws Exception {
|
||||
int mineWinCoins = (int) (winRate * coins);
|
||||
int[][] drop = new int[1][];
|
||||
drop[0] = new int[2];
|
||||
drop[0][0] = arenaItem[0];
|
||||
drop[0][1] = mineWinCoins;
|
||||
ItemUtil.drop(user, drop, BIReason.CHAMPIION_BET_WIN_REWARD);
|
||||
}
|
||||
});
|
||||
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
/* delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_MINE, selectUid + ":" + winUid));
|
||||
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_BET_MINE, selectUid + ":" + failUid));*/
|
||||
}
|
||||
//RedisUtil.getInstence().del();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看竞猜历史记录
|
||||
*
|
||||
* @param session
|
||||
*/
|
||||
public static void viewMGuessHistory(ISession session){
|
||||
int uid = session.getUid();
|
||||
Map<String, Integer> betHistorys = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_BET_MINE, Integer.toString(uid), String.class, Integer.class);
|
||||
if(!betHistorys.isEmpty()){
|
||||
betHistorys.forEach((idAndBet,coins)->{
|
||||
String[] idAndBetSplit = idAndBet.split(":");
|
||||
String id = idAndBetSplit[0];
|
||||
Integer betUid = Integer.parseInt(idAndBetSplit[1]);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 向全服玩家广播赔率
|
||||
*/
|
||||
public static CommonProto.ChampionBetInfo getBetOdds(){
|
||||
ArenaRecord arenaRecord = arenaRecordMap.get(selectUid);
|
||||
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 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().setRedRate(attackRateStr).setBlueRate(defRateStr).setId(selectUid).build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 1.发给战斗处理器处理。
|
||||
* 2.选择本场次竞猜队伍id
|
||||
* 3.给参战玩家记录
|
||||
*
|
||||
*/
|
||||
public static void selectToBattle(){
|
||||
List<int[]> joinIndexs = STableManager.getFigureConfig(CommonStaticConfig.class).getMatrixforGroupInfo().get(roundTimes);
|
||||
if(joinIndexs != null){
|
||||
for(int[] joinIndex : joinIndexs){
|
||||
int joinIndexRed = joinIndex[0]-1;
|
||||
int joinIndexBlue = joinIndex[1]-1;
|
||||
for(List<MemberInfo> memberOfOneTeam : memberOfTeam){
|
||||
MemberInfo memberInfoAttack = memberOfOneTeam.get(joinIndexRed);
|
||||
MemberInfo memberInfoDef = memberOfOneTeam.get(joinIndexBlue);
|
||||
int attackUid = memberInfoAttack.getUid();
|
||||
int defUid = memberInfoDef.getUid();
|
||||
int type = memberInfoAttack.getType() + memberInfoDef.getType();
|
||||
if(memberInfoAttack.getType() == 1){
|
||||
attackUid = memberInfoDef.getUid();
|
||||
defUid = memberInfoAttack.getUid();
|
||||
}
|
||||
ArenaRecord arenaRecord = new ArenaRecord();
|
||||
arenaRecord.setId(KeyGenUtils.produceIdByModule(UUIDEnum.ARENARECORD,memberInfoAttack.getUid()));
|
||||
arenaRecord.setAttackId(attackUid);
|
||||
arenaRecord.setDefUid(defUid);
|
||||
arenaRecord.setType(type);
|
||||
arenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
||||
curArenaRecordMap.put(arenaRecord.getId(),arenaRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1.向玩家发送竞猜币。
|
||||
* 2.做玩家战斗数据快照。
|
||||
* 3.筛选出竞猜队伍。
|
||||
* 4开启定时广播操作。
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void switchBet() throws Exception {
|
||||
int[][] itemNum = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getItemNum();
|
||||
InnerMessageUtil.broadcastWithRandom(user1 -> {
|
||||
if(user1==null){
|
||||
return;
|
||||
}
|
||||
ISession session = OnlineUserManager.getSessionByUid(user1.getId());
|
||||
if(null ==session){
|
||||
return;
|
||||
}
|
||||
Map<Integer, SGlobalSystemConfig> sGlobalSystemConfigMap = STableManager.getConfig(SGlobalSystemConfig.class);
|
||||
if(!HandlerLogicThread.checkOpen(user1, sGlobalSystemConfigMap.get(8))){
|
||||
return;
|
||||
}
|
||||
MissionEventDistributor.requestStart();
|
||||
ItemUtil.drop(user1,itemNum, BIReason.CHAMPIION_BET_REWARD);
|
||||
|
||||
MissionEventDistributor.requestEnd(session,true);
|
||||
}, new LinkedList<>(OnlineUserManager.sessionMap.keySet()),1);
|
||||
snapPlayFightInfo();
|
||||
selectBetTeam();
|
||||
selectToBattle();
|
||||
|
||||
//每隔ns向前端广播赔率
|
||||
CommonProto.ChampionBetInfo betOdds = getBetOdds();
|
||||
ArenaInfoProto.ChampionBetBroadIndication build = ArenaInfoProto.ChampionBetBroadIndication.newBuilder().setChampionBetInfo(betOdds).build();
|
||||
OnlineUserManager.sessionMap.forEach((id,session)->{
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.CHAMPION_BET_BROAD_INDICATION_VALUE,build,true);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取排行榜信息
|
||||
public void getWorldRankByPage(ISession session,int page) throws Exception {
|
||||
if (page == 0) {
|
||||
page = 1;
|
||||
}
|
||||
int start = (page - 1) * 20, end = page * 20 - 1;
|
||||
List<CommonProto.ArenaEnemy> arenaRankMemberInfo = new ArrayList<>(20);
|
||||
|
||||
int rankEndLine = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getChampionshipPlayer();
|
||||
Map<Integer, SArenaRobotConfig> robotConfigMap = STableManager.getConfig(SArenaRobotConfig.class);
|
||||
if(end<rankEndLine) {
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CHAMPION_BET_RANK, Integer.toString(1), start, end);
|
||||
for (ZSetOperations.TypedTuple<String> item : arenaRankInfo) {
|
||||
String value = item.getValue();
|
||||
int score = item.getScore().intValue();
|
||||
int uid = Integer.parseInt(value);
|
||||
if(robotConfigMap.containsKey(uid)){
|
||||
SArenaRobotConfig sArenaRobotConfig = robotConfigMap.get(uid);
|
||||
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).build();
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(uid)
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(sArenaRobotConfig.getRobotName())
|
||||
.setScore(score)
|
||||
.setHead(0)
|
||||
.setRank(++start)
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.setHeadFrame(0)
|
||||
.build();
|
||||
arenaRankMemberInfo.add(CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build());
|
||||
continue;
|
||||
}
|
||||
|
||||
User user = UserManager.getUser(uid,true);
|
||||
if (null == user) {
|
||||
continue;
|
||||
}
|
||||
int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, GlobalsDef.TEAM_ARENA_DEFENSE, false);
|
||||
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.TEAM_ARENA_DEFENSE);
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
List<Integer> heroTids = new ArrayList<>(teamPosHeroInfoList.size());
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) {
|
||||
heroTids.add(heroMap.get(teamPosHeroInfo.getHeroId()).getTemplateId());
|
||||
}
|
||||
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(heroTids).build();
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(uid)
|
||||
.setLevel(playerInfoManager.getLevel())
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setScore(score)
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setRank(++start)
|
||||
.setTotalForce(totalForce)
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame())
|
||||
.build();
|
||||
arenaRankMemberInfo.add(CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setTeam(teamBuild)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
int uid = session.getUid();
|
||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.CHAMPION_BET_RANK,Integer.toString(1), Integer.toString(uid)).intValue();
|
||||
int myRank =-1;
|
||||
if(score == -1){
|
||||
score =0;
|
||||
}else{
|
||||
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.CHAMPION_BET_RANK,Integer.toString(1),Integer.toString(uid)).intValue();
|
||||
}
|
||||
|
||||
ArenaInfoProto.GetArenaRankInfoResponse buildResponse = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder()
|
||||
.addAllRankInfos(arenaRankMemberInfo)
|
||||
.setMyRank(myRank)
|
||||
.setMyscore(score)
|
||||
.build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE,buildResponse,true);
|
||||
|
||||
}
|
||||
|
||||
public static void minuteCheck() throws Exception {
|
||||
/* TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoId(1);
|
||||
if( null == timeControllerOfFunction){
|
||||
progress = -1;
|
||||
return;
|
||||
}
|
||||
long now = TimeUtils.now();
|
||||
long startTime = timeControllerOfFunction.getStartTime();
|
||||
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
||||
int duration = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime()*60*1000;
|
||||
int progressTmp=(int)((now - startTime)%duration +1);
|
||||
long round = (now - startTime) / duration + 1;
|
||||
roundTimes = (int) round;
|
||||
long diff = round - sChampionshipSetting.getTrialsGroup() * (sChampionshipSetting.getTrialsGroup() - 1) / 2;
|
||||
if(diff<0){ //选拔赛
|
||||
progress =10 + progressTmp;
|
||||
}else {//决赛
|
||||
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
|
||||
int roundTimes = (int) (totalWiner / (diff + 1));
|
||||
progress =roundTimes*100 + progressTmp;
|
||||
}
|
||||
|
||||
if(progress%3==2){ //竞猜阶段
|
||||
switchBet();
|
||||
}else if(progress%3==0){ //比赛阶段
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@ public class ArenaManager extends MongoBase {
|
|||
|
||||
private int season;
|
||||
|
||||
private List<ArenaEnemy> arenaEnemies;
|
||||
|
||||
private List<ArenaEnemy> arenaEnemies;
|
||||
|
||||
|
||||
public void updateChallenge(int fightResult){
|
||||
|
|
@ -78,6 +78,7 @@ public class ArenaManager extends MongoBase {
|
|||
return season;
|
||||
}
|
||||
|
||||
|
||||
public void resetSeason(int curSeason) {
|
||||
this.season = curSeason;
|
||||
this.failNums =0;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ public class ArenaRecord {
|
|||
|
||||
private String id;
|
||||
|
||||
private int type; // 1 : 人机对战 2 : 真人对战 3:机机对战
|
||||
|
||||
private int attackId; //进攻者
|
||||
|
||||
private int defScore; //防守获得分数 正:代表胜利 负:代表失败
|
||||
|
|
@ -16,7 +18,9 @@ public class ArenaRecord {
|
|||
|
||||
private int createTime;
|
||||
|
||||
private int fightResult;
|
||||
private int fightResult = -1; //表示进行中
|
||||
|
||||
private int defUid;
|
||||
|
||||
public ArenaRecord(){}
|
||||
|
||||
|
|
@ -75,4 +79,20 @@ public class ArenaRecord {
|
|||
public void setFightResult(int fightResult) {
|
||||
this.fightResult = fightResult;
|
||||
}
|
||||
|
||||
public int getDefUid() {
|
||||
return defUid;
|
||||
}
|
||||
|
||||
public void setDefUid(int defUid) {
|
||||
this.defUid = defUid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.ArenaRecord;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
public class AreFightPro implements EndFightProcessor {
|
||||
ArenaRecord arenaRecord;
|
||||
@Override
|
||||
public void endfightProcess(FightResult fightResult) {
|
||||
arenaRecord.setFightResult(fightResult.getCheckResult()[0]);
|
||||
}
|
||||
|
||||
public ArenaRecord getArenaRecord() {
|
||||
return arenaRecord;
|
||||
}
|
||||
|
||||
public void setArenaRecord(ArenaRecord arenaRecord) {
|
||||
this.arenaRecord = arenaRecord;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CallBackTask<T,R> {
|
||||
void calllBack();
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
public interface EndFightProcessor {
|
||||
|
||||
void endfightProcess(FightResult fightResult);
|
||||
}
|
||||
|
|
@ -1,11 +1,52 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.thread.ThreadManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
public class FightDispatcher {
|
||||
|
||||
|
||||
public static FightResult dispatcher(FightEvent fightEvent) throws Exception {
|
||||
GameFightType fightType = fightEvent.getFightType();
|
||||
return fightType.getFightEventProcesor().process(fightEvent);
|
||||
}
|
||||
|
||||
//gs-fight
|
||||
public static long dispatcherAsync(FightEvent fightEvent) throws Exception {
|
||||
long fightId = 0;
|
||||
ThreadManager.getScheduledExecutor().submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
GameFightType fightType = fightEvent.getFightType();
|
||||
FightResult fightResult = fightType.getFightEventProcesor().process(fightEvent);
|
||||
FightDispatcher.dispatcherAsyncToGs(fightResult);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
return fightId;
|
||||
|
||||
}
|
||||
|
||||
private static Map<Long,EndFightProcessor> map = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
//fight - gs
|
||||
public static void dispatcherAsyncToGs(FightResult fightResult) throws Exception {
|
||||
map.get(fightResult.getId()).endfightProcess(fightResult);
|
||||
}
|
||||
|
||||
public static Map<Long, EndFightProcessor> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void setMap(Map<Long, EndFightProcessor> map) {
|
||||
FightDispatcher.map = map;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.fight;
|
|||
import java.util.Map;
|
||||
|
||||
public class FightEvent {
|
||||
private String id;
|
||||
private int attackUid;
|
||||
private int teamId;
|
||||
private int mostTime;
|
||||
|
|
@ -45,4 +46,8 @@ public class FightEvent {
|
|||
public String getFrames() {
|
||||
return frames;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ public class FightUtil {
|
|||
|
||||
public static FightResult getFightForPVP(FightEvent fightEvent){
|
||||
PVPFightEvent pvpFightEvent = (PVPFightEvent)fightEvent;
|
||||
User userInMem = UserManager.getUserInMem(pvpFightEvent.getAttackUid());
|
||||
CommonProto.FightTeamInfo fightTeamInfo = makePersonFightData(userInMem, pvpFightEvent.getTeamId(),pvpFightEvent.getAttackBloodMap());
|
||||
|
||||
int fightSeed =getFightSeed();
|
||||
CommonProto.FightTeamInfo fightTeamInfo = null;
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = null;
|
||||
if(pvpFightEvent.getDefFightSnapData()!=null){
|
||||
deffightTeamInfo = makeFightWithSnapData(pvpFightEvent.getDefFightSnapData());
|
||||
|
|
@ -99,6 +99,13 @@ public class FightUtil {
|
|||
}
|
||||
|
||||
}
|
||||
if(fightEvent.getFightType()!=GameFightType.Arena2RobotFight){
|
||||
User userInMem = UserManager.getUserInMem(pvpFightEvent.getAttackUid());
|
||||
fightTeamInfo = makePersonFightData(userInMem, pvpFightEvent.getTeamId(),pvpFightEvent.getAttackBloodMap());
|
||||
}else{
|
||||
fightTeamInfo = makeRobotFightData(pvpFightEvent.getDefUid());
|
||||
}
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(fightEvent.getFrames());
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(fightSeed, fightEvent.getMostTime(), getFightData, getOptionData, fightEvent.getFightType().getFightType());
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public enum GameFightType {
|
|||
|
||||
ArenaPersonFight(FightType.ArenaFight,new PVPFightHandler(),null),
|
||||
ArenaRobotFight(FightType.ArenaFight,new PVPFightHandler(),null),
|
||||
Arena2RobotFight(FightType.ArenaFight,new PVPFightHandler(),null),
|
||||
|
||||
MonterFight(FightType.MonterFight,new DefaultWithoutHandFightHandler(),null),
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ public class PVPFightEvent extends FightEvent {
|
|||
private int defUid;
|
||||
private int defTeamId;
|
||||
|
||||
|
||||
|
||||
//对手快照
|
||||
private DefFightSnapData defFightSnapData;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import java.util.List;
|
||||
|
||||
public class FightResult {
|
||||
private long id;
|
||||
private int[] checkResult;
|
||||
private int seed;
|
||||
private CommonProto.FightTeamInfo fightTeamInfo;
|
||||
|
|
@ -123,4 +124,12 @@ public class FightResult {
|
|||
public void setDefFightTeamInfo(CommonProto.FightTeamInfo defFightTeamInfo) {
|
||||
this.defFightTeamInfo = defFightTeamInfo;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ChampionshipReward")
|
||||
public class SChampionshipReward implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int minRank;
|
||||
|
||||
private int maxRank;
|
||||
|
||||
private int[][] seasonReward;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getMinRank() {
|
||||
return minRank;
|
||||
}
|
||||
|
||||
public int getMaxRank() {
|
||||
return maxRank;
|
||||
}
|
||||
|
||||
public int[][] getSeasonReward() {
|
||||
return seasonReward;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ChampionshipSetting")
|
||||
public class SChampionshipSetting implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int championshipPlayer;
|
||||
|
||||
private int trialsGroup;
|
||||
|
||||
private int trialsGroupWinner;
|
||||
|
||||
private int[] championshipStartTime;
|
||||
|
||||
private int prepareTime;
|
||||
|
||||
private int guessTime;
|
||||
|
||||
private int battleTime;
|
||||
|
||||
private int warTime;
|
||||
|
||||
private int arenaPercent;
|
||||
|
||||
private int[][] itemNum;
|
||||
|
||||
private int exchangeItem;
|
||||
|
||||
private int[] arenaItem;
|
||||
|
||||
private int guessNum;
|
||||
|
||||
private int knockoutGroup;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getChampionshipPlayer() {
|
||||
return championshipPlayer;
|
||||
}
|
||||
|
||||
public int getTrialsGroup() {
|
||||
return trialsGroup;
|
||||
}
|
||||
|
||||
public int getTrialsGroupWinner() {
|
||||
return trialsGroupWinner;
|
||||
}
|
||||
|
||||
public int[] getChampionshipStartTime() {
|
||||
return championshipStartTime;
|
||||
}
|
||||
|
||||
public int getPrepareTime() {
|
||||
return prepareTime;
|
||||
}
|
||||
|
||||
public int getGuessTime() {
|
||||
return guessTime;
|
||||
}
|
||||
|
||||
public int getBattleTime() {
|
||||
return battleTime;
|
||||
}
|
||||
|
||||
public int getWarTime() {
|
||||
return warTime;
|
||||
}
|
||||
|
||||
public int getArenaPercent() {
|
||||
return arenaPercent;
|
||||
}
|
||||
|
||||
public int[][] getItemNum() {
|
||||
return itemNum;
|
||||
}
|
||||
|
||||
public int getExchangeItem() {
|
||||
return exchangeItem;
|
||||
}
|
||||
|
||||
public int[] getArenaItem() {
|
||||
return arenaItem;
|
||||
}
|
||||
|
||||
public int getGuessNum() {
|
||||
return guessNum;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue