match
parent
f40ed6ea41
commit
2cb68aebbb
|
@ -16,6 +16,7 @@ public class SArenaRobotConfig implements BaseConfig {
|
|||
|
||||
private String robotName;
|
||||
|
||||
private int robotScore;
|
||||
private int robotLevel;
|
||||
|
||||
private int[] roleId;
|
||||
|
@ -83,11 +84,11 @@ public class SArenaRobotConfig implements BaseConfig {
|
|||
return robotName;
|
||||
}
|
||||
|
||||
public int getRobotLevel() {
|
||||
return robotLevel;
|
||||
public int getRobotScore() {
|
||||
return robotScore;
|
||||
}
|
||||
|
||||
private int[] getRoleId() {
|
||||
private int[] getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
|
@ -138,4 +139,8 @@ public class SArenaRobotConfig implements BaseConfig {
|
|||
public void setStarOfHeroMap(Map<Integer, Integer> starOfHeroMap) {
|
||||
this.starOfHeroMap = starOfHeroMap;
|
||||
}
|
||||
|
||||
public int getRobotLevel() {
|
||||
return robotLevel;
|
||||
}
|
||||
}
|
|
@ -10,9 +10,9 @@ public class SArenaRobotSetting implements BaseConfig {
|
|||
|
||||
private int id;
|
||||
|
||||
private int playerLevelMax;
|
||||
private int playerScoreMax;
|
||||
|
||||
private int playerLevelMin;
|
||||
private int playerScoreMin;
|
||||
|
||||
private int pool;
|
||||
|
||||
|
@ -32,15 +32,15 @@ public class SArenaRobotSetting implements BaseConfig {
|
|||
return id;
|
||||
}
|
||||
|
||||
public int getPlayerLevelMax() {
|
||||
return playerLevelMax;
|
||||
public int getPlayerScoreMax() {
|
||||
return playerScoreMax;
|
||||
}
|
||||
|
||||
public int getPlayerLevelMin() {
|
||||
return playerLevelMin;
|
||||
public int getPlayerScoreMin() {
|
||||
return playerScoreMin;
|
||||
}
|
||||
|
||||
public int getPool() {
|
||||
public int getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.ljsd.jieling.logic.arena;
|
|||
|
||||
|
||||
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
|
@ -29,7 +28,6 @@ import com.ljsd.jieling.util.*;
|
|||
import org.luaj.vm2.LuaValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.session.SessionProperties;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -57,22 +55,21 @@ public class ArenaLogic {
|
|||
public void getArenaInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int level = user.getPlayerInfoManager().getLevel();
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
if(arenaManager.getSeason()!=curSeason){
|
||||
arenaManager.resetSeason(curSeason);
|
||||
}
|
||||
if(arenaManager.getFlushNums() == 0){
|
||||
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
|
||||
Set<Integer> robotIds = randomRobot(level, 5);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies, GlobalsDef.ARENA_ROBOT_TYPE);
|
||||
arenaManager.setArenaEnemies(arenaEnemies);
|
||||
}
|
||||
|
||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||
if(score == -1){
|
||||
score = SArenaSetting.getSArenaSetting().getScore();
|
||||
}
|
||||
if(arenaManager.getFlushNums() == 0){
|
||||
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
|
||||
Set<Integer> robotIds = randomRobot(score, 5);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies, GlobalsDef.ARENA_ROBOT_TYPE);
|
||||
arenaManager.setArenaEnemies(arenaEnemies);
|
||||
}
|
||||
|
||||
CommonProto.ArenaInfo build = CommonProto.ArenaInfo.newBuilder()
|
||||
.setFailNums(arenaManager.getFailNums())
|
||||
.setSuccessNums(arenaManager.getSuccessNums())
|
||||
|
@ -87,7 +84,6 @@ public class ArenaLogic {
|
|||
|
||||
public List<CommonProto.ArenaEnemy> getArenaEnemyList(List<ArenaEnemy> arenaEnemies) throws Exception {
|
||||
List<CommonProto.ArenaEnemy> arenaEnemyList = new ArrayList<>(arenaEnemies.size());
|
||||
int defaultScore = SArenaSetting.getSArenaSetting().getScore();
|
||||
for(ArenaEnemy arenaEnemy : arenaEnemies){
|
||||
int enemyId = arenaEnemy.getEnemyId();
|
||||
int enemyType = arenaEnemy.getEnemyType();
|
||||
|
@ -98,7 +94,7 @@ public class ArenaLogic {
|
|||
.setUid(enemyId)
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(sArenaRobotConfig.getRobotName())
|
||||
.setScore(defaultScore)
|
||||
.setScore(sArenaRobotConfig.getRobotScore())
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.build();
|
||||
arenaEnemyList.add(CommonProto.ArenaEnemy.newBuilder()
|
||||
|
@ -207,18 +203,28 @@ public class ArenaLogic {
|
|||
}
|
||||
|
||||
public void setMyArenaEnemys(int uid,User user){
|
||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||
if(score == -1){
|
||||
score = SArenaSetting.getSArenaSetting().getScore();
|
||||
}
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
|
||||
if(arenaManager.getFlushNums()<SArenaSetting.getSArenaSetting().getPveNum()){
|
||||
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
|
||||
if(curSeason ==1 && arenaManager.getFlushNums()<SArenaSetting.getSArenaSetting().getPveNum()){
|
||||
Set<Integer> robotIds = randomRobot(score, 5);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE);
|
||||
}else{
|
||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||
if(score == -1){
|
||||
score = SArenaSetting.getSArenaSetting().getScore();
|
||||
Set<Integer> robotIds = randomPerson(uid,score,true);
|
||||
int type = GlobalsDef.ARENA_PLAYER_TYPE;
|
||||
if(robotIds.isEmpty()){
|
||||
if(curSeason>1){
|
||||
robotIds = randomPerson(uid,score,false);
|
||||
}
|
||||
if(robotIds.isEmpty()){
|
||||
robotIds = randomRobot(score, 5);
|
||||
type = GlobalsDef.ARENA_ROBOT_TYPE;
|
||||
}
|
||||
}
|
||||
Set<Integer> robotIds = randomPerson(uid,score);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_PLAYER_TYPE);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies,type);
|
||||
}
|
||||
arenaManager.setArenaEnemies(arenaEnemies);
|
||||
}
|
||||
|
@ -338,13 +344,13 @@ public class ArenaLogic {
|
|||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
public Set<Integer> randomRobot(int userLevel,int nums){
|
||||
public Set<Integer> randomRobot(int userSscore,int nums){
|
||||
Set<Integer> robotIds = new HashSet<>(5);
|
||||
Map<Integer, SArenaRobotSetting> config = SArenaRobotSetting.getConfig();
|
||||
for(SArenaRobotSetting sArenaRobotSetting : config.values()){
|
||||
int playerLevelMin = sArenaRobotSetting.getPlayerLevelMin();
|
||||
int playerLevelMax = sArenaRobotSetting.getPlayerLevelMax();
|
||||
if(userLevel>=playerLevelMin && userLevel<=playerLevelMax){
|
||||
int playerLevelMin = sArenaRobotSetting.getPlayerScoreMin();
|
||||
int playerLevelMax = sArenaRobotSetting.getPlayerScoreMax();
|
||||
if(userSscore>=playerLevelMin && userSscore<=playerLevelMax){
|
||||
int poolId = sArenaRobotSetting.getPool();
|
||||
List<SArenaRobotConfig> sArenaRobotConfigsByPool = SArenaRobotConfig.getSArenaRobotConfigsByPool(poolId);
|
||||
int size = sArenaRobotConfigsByPool.size();
|
||||
|
@ -356,14 +362,18 @@ public class ArenaLogic {
|
|||
return robotIds;
|
||||
}
|
||||
|
||||
public Set<Integer> randomPerson(int uid,int myScore){
|
||||
public Set<Integer> randomPerson(int uid,int myScore,boolean useCurSeason){
|
||||
Set<Integer> result = new HashSet<>(5);
|
||||
int[][] interval = SArenaSetting.getSArenaSetting().getInterval();
|
||||
int matchSeason = curSeason;
|
||||
if(!useCurSeason){
|
||||
matchSeason = curSeason - 1;
|
||||
}
|
||||
for(int[] item: interval){
|
||||
int low = item[0];
|
||||
int high = item[1];
|
||||
Set<String> arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK,Integer.toString(curSeason), myScore * low / 10000.0f-1, myScore * high / 10000.0f +1);
|
||||
LOGGER.info("curSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},",curSeason,uid,myScore,low,high,myScore * low / 10000.0f-1,myScore * high / 10000.0f +1);
|
||||
Set<String> arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK,Integer.toString(matchSeason), myScore * low / 10000.0f-1, myScore * high / 10000.0f +1);
|
||||
LOGGER.info("curSeason={},matchSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},",curSeason,matchSeason,uid,myScore,low,high,myScore * low / 10000.0f-1,myScore * high / 10000.0f +1);
|
||||
if(arenaRank!=null && !arenaRank.isEmpty()){
|
||||
LOGGER.info("arenRank-->{}",arenaRank);
|
||||
arenaRank.remove(Integer.toString(uid));
|
||||
|
|
Loading…
Reference in New Issue