Merge branch 'master_xiyou' into master_luofu

# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java
#	serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java
#	serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ArenaManager.java
master_dev
grimm 2024-04-25 20:19:58 +08:00
commit 415df3b213
13 changed files with 315 additions and 418 deletions

View File

@ -25,81 +25,10 @@ public class SArenaRobotStaticConfig extends AbstractClassStaticConfig {
Map<Integer, SArenaRobotConfig> integerSArenaRobotConfigMap = SArenaRobotConfig.getsArenaRobotConfigMap();
for(SArenaRobotConfig sArenaRobotConfig : integerSArenaRobotConfigMap.values()){
List<Integer> heroList = sArenaRobotConfig.getHeroList();
List<Integer> heroList2 = sArenaRobotConfig.getHeroList2();
List<Integer> heroList3= sArenaRobotConfig.getHeroList3();
int heroLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, CommonProto.Hero> heroMap = new HashMap<>();
for(Integer heroTid :heroList){
SCHero scHero = SCHero.getsCHero().get(heroTid);
if(null ==scHero){
throw new IllegalArgumentException("sArenaRobotConfig id "+sArenaRobotConfig.getId()+"机器人英雄模板id找不到 heroTid:"+heroTid);
}
CommonProto.Hero.Builder heroBuilder = CommonProto.Hero.newBuilder();
int star = HeroLogic.getInstance().calRobotStarByLevel(heroTid,heroLevel);
int heroStarBreakId = HeroLogic.getInstance().calRobotStarBreakByLevel(heroTid,heroLevel);
int heroBreakId = HeroLogic.getInstance().calRobotBreakByLevel(heroTid,heroLevel);
heroBuilder.setId(String.valueOf(scHero.getId()));
heroBuilder.setHeroId(scHero.getId());
heroBuilder.setLevel(heroLevel);
heroBuilder.setStar(star);
heroBuilder.setStarBreakId(heroStarBreakId);
heroBuilder.setBreakId(heroBreakId);
heroBuilder.setPropertyId(scHero.getPropertyName());
heroMap.put(heroTid,heroBuilder.build());
}
sArenaRobotConfig.setHeroMapList(heroMap);
Map<Integer, CommonProto.Hero> heroMap2 = new HashMap<>();
for(Integer heroTid :heroList2){
SCHero scHero = SCHero.getsCHero().get(heroTid);
if(null ==scHero){
throw new IllegalArgumentException("sArenaRobotConfig id "+sArenaRobotConfig.getId()+"机器人英雄模板id找不到 heroTid:"+heroTid);
}
CommonProto.Hero.Builder heroBuilder = CommonProto.Hero.newBuilder();
int star = HeroLogic.getInstance().calRobotStarByLevel(heroTid,heroLevel);
int heroStarBreakId = HeroLogic.getInstance().calRobotStarBreakByLevel(heroTid,heroLevel);
int heroBreakId = HeroLogic.getInstance().calRobotBreakByLevel(heroTid,heroLevel);
heroBuilder.setId(String.valueOf(scHero.getId()));
heroBuilder.setHeroId(scHero.getId());
heroBuilder.setLevel(heroLevel);
heroBuilder.setStar(star);
heroBuilder.setStarBreakId(heroStarBreakId);
heroBuilder.setBreakId(heroBreakId);
heroBuilder.setPropertyId(scHero.getPropertyName());
heroMap2.put(heroTid,heroBuilder.build());
}
sArenaRobotConfig.setHeroMapList2(heroMap2);
Map<Integer, CommonProto.Hero> heroMap3 = new HashMap<>();
for(Integer heroTid :heroList3){
SCHero scHero = SCHero.getsCHero().get(heroTid);
if(null ==scHero){
throw new IllegalArgumentException("sArenaRobotConfig id "+sArenaRobotConfig.getId()+"机器人英雄模板id找不到 heroTid:"+heroTid);
}
CommonProto.Hero.Builder heroBuilder = CommonProto.Hero.newBuilder();
int star = HeroLogic.getInstance().calRobotStarByLevel(heroTid,heroLevel);
int heroStarBreakId = HeroLogic.getInstance().calRobotStarBreakByLevel(heroTid,heroLevel);
int heroBreakId = HeroLogic.getInstance().calRobotBreakByLevel(heroTid,heroLevel);
heroBuilder.setId(String.valueOf(scHero.getId()));
heroBuilder.setHeroId(scHero.getId());
heroBuilder.setLevel(heroLevel);
heroBuilder.setStar(star);
heroBuilder.setStarBreakId(heroStarBreakId);
heroBuilder.setBreakId(heroBreakId);
heroBuilder.setPropertyId(scHero.getPropertyName());
heroMap3.put(heroTid,heroBuilder.build());
}
sArenaRobotConfig.setHeroMapList3(heroMap3);
sArenaRobotConfig.setHeroMapList(buildHeroProtoMap(sArenaRobotConfig, sArenaRobotConfig.getHeroList(), heroLevel));
sArenaRobotConfig.setHeroMapList2(buildHeroProtoMap(sArenaRobotConfig, sArenaRobotConfig.getHeroList2(), heroLevel));
sArenaRobotConfig.setHeroMapList3(buildHeroProtoMap(sArenaRobotConfig, sArenaRobotConfig.getHeroList3(), heroLevel));
int totleForce = HeroLogic.getInstance().calRobotTotalForce(sArenaRobotConfig);
sArenaRobotConfig.setTotalForce(totleForce);
int totleYxldForce = HeroLogic.getInstance().calRobotYxldTotalForce(sArenaRobotConfig);
@ -121,6 +50,32 @@ public class SArenaRobotStaticConfig extends AbstractClassStaticConfig {
}
}
public Map<Integer, CommonProto.Hero> buildHeroProtoMap(SArenaRobotConfig sArenaRobotConfig, List<Integer> heroList3, int heroLevel) {
Map<Integer, CommonProto.Hero> heroMap = new HashMap<>();
for(Integer heroTid : heroList3){
SCHero scHero = SCHero.getsCHero().get(heroTid);
if(null ==scHero){
throw new IllegalArgumentException("sArenaRobotConfig id "+sArenaRobotConfig.getId()+"机器人英雄模板id找不到 heroTid:"+heroTid);
}
CommonProto.Hero.Builder heroBuilder = CommonProto.Hero.newBuilder();
int star = HeroLogic.getInstance().calRobotStarByLevel(heroTid,heroLevel);
int heroStarBreakId = HeroLogic.getInstance().calRobotStarBreakByLevel(heroTid,heroLevel);
int heroBreakId = HeroLogic.getInstance().calRobotBreakByLevel(heroTid,heroLevel);
heroBuilder.setId(String.valueOf(scHero.getId()));
heroBuilder.setHeroId(scHero.getId());
heroBuilder.setLevel(heroLevel);
heroBuilder.setStar(star);
heroBuilder.setStarBreakId(heroStarBreakId);
heroBuilder.setBreakId(heroBreakId);
heroBuilder.setPropertyId(scHero.getPropertyName());
heroMap.put(heroTid,heroBuilder.build());
}
return heroMap;
}
public static Integer getFloorForce2robotId(int force) {
Map.Entry<Integer,LinkedList<Integer>> entry = force2robotId.ceilingEntry(force);
LinkedList<Integer> value;

View File

@ -378,6 +378,9 @@ public class RedisKey {
public static final String NEW_ARENA_RANK = "NEW_ARENA_RANK"; //新竞技场排行榜
public static final String NEW_ARENA_PLAYER = "NEW_ARENA_PLAYER";//新竞技场玩家信息
public static final String NEW_ARENA_RESET = "NEW_ARENA_RESET";//新竞技场重置标记
public static final String NEW_ARENA_REFRESH_FIRST_MARK = "NEW_ARENA_REFRESH_FIRST_MARK";//新竞技场第一次匹配标记
// public static final String NEW_ARENA_FIRST_PUSH = "NEW_ARENA_FIRST_PUSH";//竞技场第一名推送标记
//进程排行 合区统一
public static Set<String> newAreaCacChe = new HashSet<>();

View File

@ -27,27 +27,27 @@ public class ArenaRandomHandler extends BaseHandler {
@Override
public void process(ISession session, PacketNetData netData) throws Exception {
int curSeason =ArenaLogic.getInstance().getCurSeason();
if(curSeason == 0){
throw new ErrorCodeException(ErrorCode.newDefineCode("season_close"));
}
int uid = session.getUid();
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
if(sArenaSetting == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
User user = UserManager.getUser(uid);
ArenaManager arenaManager = user.getArenaManager();
int flushEnenyTime = arenaManager.getFlushTime();
int coldTime = sArenaSetting.getColdTime();
int now = (int)(TimeUtils.now()/1000);
if( now - flushEnenyTime < coldTime-1 ){
throw new ErrorCodeException(ErrorCode.ARENA_RANDOM_ENEMY_CODE_TIME);
}
//刷新选手
ArenaLogic.getInstance().setMyArenaEnemys(uid,user);
arenaManager.setFlushTime(now);
ArenaInfoProto.ArenaRandomResponse build = ArenaInfoProto.ArenaRandomResponse.newBuilder().addAllArenaEnemys(ArenaLogic.getInstance().getArenaEnemyList(arenaManager.getArenaEnemies())).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,build,true);
// int curSeason =ArenaLogic.getInstance().getCurSeason();
// if(curSeason == 0){
// throw new ErrorCodeException(ErrorCode.newDefineCode("season_close"));
// }
// int uid = session.getUid();
// SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
// if(sArenaSetting == null){
// throw new ErrorCodeException(ErrorCode.CFG_NULL);
// }
// User user = UserManager.getUser(uid);
// ArenaManager arenaManager = user.getArenaManager();
// int flushEnenyTime = arenaManager.getFlushTime();
// int coldTime = sArenaSetting.getColdTime();
// int now = TimeUtils.nowInt();
// if(now - flushEnenyTime < coldTime - 1){
// throw new ErrorCodeException(ErrorCode.ARENA_RANDOM_ENEMY_CODE_TIME);
// }
// //刷新选手
// ArenaLogic.getInstance().setMyArenaEnemys(uid,user);
// arenaManager.setFlushTime(now);
// ArenaInfoProto.ArenaRandomResponse build = ArenaInfoProto.ArenaRandomResponse.newBuilder().addAllArenaEnemys(ArenaLogic.getInstance().getArenaEnemyList(arenaManager.getArenaEnemies())).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,null,true);
}
}

View File

@ -95,7 +95,7 @@ public enum ActivityTypeEnum {
CONTINUOUS_GIFT(ActivityType.CONTINUOUS_GIFT,SuperBoxActivity::new),//连续礼包
TRANSFORMATION_DRAW_CARD(ActivityType.TRANSFORMATION_DRAW_CARD,DefaultEmptyActivity::new),//方寸寻宝
CONTINUOUS_GIFT_NEW(ActivityType.CONTINUOUS_GIFT_NEW,ContinuousGiftActivity::new),//新连续礼包
ARENA_RANK_EXPERIMENT(ActivityType.ARENA_RANK_EXPERIMENT,ArenaRankActivity::new),//竞技试炼
// ARENA_RANK_EXPERIMENT(ActivityType.ARENA_RANK_EXPERIMENT,ArenaRankActivity::new),//竞技试炼
NEW_RECHARGE_SUM_DAY_6(ActivityType.NEW_RECHARGE_SUM_DAY_6,NewRechargeSumDayActivity::new),//超值返利6
NEW_RECHARGE_SUM_DAY_12(ActivityType.NEW_RECHARGE_SUM_DAY_12,NewRechargeSumDayActivity::new),//超值返利12

View File

@ -55,44 +55,44 @@ public class ArenaRankActivity extends AbstractActivity {
@Override
public void onActivityEnd() throws Exception {
LOGGER.info("竞技试炼发奖励 onActivityEnd...{}", id);
ThreadManager.scheduleOne(this::sendReward,0, TimeUnit.NANOSECONDS);
// LOGGER.info("竞技试炼发奖励 onActivityEnd...{}", id);
// ThreadManager.scheduleOne(this::sendReward,0, TimeUnit.NANOSECONDS);
}
private void sendReward(){
Thread.currentThread().setName("sendReward-Activity-"+id);
List<SActivityRankingReward> sActivityRankingRewards = SActivityRankingReward.getsActivityRankingRewardMapByActivityId(id);
if (sActivityRankingRewards == null || sActivityRankingRewards.isEmpty()) {
LOGGER.info("竞技试炼未配置奖励 onActivityEnd...{}", id);
return;
}
int curSeason = ArenaLogic.getInstance().getCurSeason();
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, -1);
int rank = 1;
int nowTime = (int) (TimeUtils.now() / 1000);
String title = SErrorCodeEerverConfig.getI18NMessage("arena_activity_mail_title");
for (ZSetOperations.TypedTuple<String> item : arenaRankInfo) {
String value = item.getValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUserNotCache(uid);
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("arena_activity_mail_txt", new Object[]{rank}, new int[0], "#");
int[][] rewardByRank = null;
for (SActivityRankingReward sActivityRankingReward : sActivityRankingRewards) {
if (sActivityRankingReward.getMinRank() >= rank && rank <= sActivityRankingReward.getMaxRank()) {
rewardByRank = sActivityRankingReward.getRankingReward();
break;
}
}
if (rewardByRank == null) {
break;
}
MailLogic.getInstance().sendMail(user.getId(), title, content, StringUtil.parseArrayToString(rewardByRank), nowTime, Global.MAIL_EFFECTIVE_TIME);
rank++;
}
try {
MongoUtil.getInstence().lastUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
// private void sendReward(){
// Thread.currentThread().setName("sendReward-Activity-"+id);
// List<SActivityRankingReward> sActivityRankingRewards = SActivityRankingReward.getsActivityRankingRewardMapByActivityId(id);
// if (sActivityRankingRewards == null || sActivityRankingRewards.isEmpty()) {
// LOGGER.info("竞技试炼未配置奖励 onActivityEnd...{}", id);
// return;
// }
// int curSeason = ArenaLogic.getInstance().getCurSeason();
// Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, -1);
// int rank = 1;
// int nowTime = (int) (TimeUtils.now() / 1000);
// String title = SErrorCodeEerverConfig.getI18NMessage("arena_activity_mail_title");
// for (ZSetOperations.TypedTuple<String> item : arenaRankInfo) {
// String value = item.getValue();
// int uid = Integer.parseInt(value);
// User user = UserManager.getUserNotCache(uid);
// String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("arena_activity_mail_txt", new Object[]{rank}, new int[0], "#");
// int[][] rewardByRank = null;
// for (SActivityRankingReward sActivityRankingReward : sActivityRankingRewards) {
// if (sActivityRankingReward.getMinRank() >= rank && rank <= sActivityRankingReward.getMaxRank()) {
// rewardByRank = sActivityRankingReward.getRankingReward();
// break;
// }
// }
// if (rewardByRank == null) {
// break;
// }
// MailLogic.getInstance().sendMail(user.getId(), title, content, StringUtil.parseArrayToString(rewardByRank), nowTime, Global.MAIL_EFFECTIVE_TIME);
// rank++;
// }
// try {
// MongoUtil.getInstence().lastUpdate();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}

View File

@ -250,7 +250,7 @@ public class OpenServerCompeteRankActivity extends AbstractActivity {
backRankType = chongRankInfo.getBackRankType();
AbstractRank backRank = RankContext.getRankEnum(backRankType);
Set<ZSetOperations.TypedTuple<String>> backRankInfo = backRank.getRankByKey("", 0, -1);
if (backRankInfo != null && backRankInfo.size() > 0){
if (backRankInfo != null && !backRankInfo.isEmpty()){
LOGGER.info("冲榜备份结束备份数据已存在活动id{},排行榜类型:{},排行榜数量:{}",id,backRankType,backRankInfo.size());
return null;
}

View File

@ -4,6 +4,8 @@ import com.ljsd.GameApplication;
import com.ljsd.fight.ArenaRecord;
import com.ljsd.fight.FightType;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.config.clazzStaticCfg.SArenaRobotStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -76,19 +78,19 @@ public class ArenaLogic {
return viewSeason;
}
public List<CommonProto.ArenaEnemy> getArenaEnemyList(List<ArenaEnemy> arenaEnemies) {
List<CommonProto.ArenaEnemy> arenaEnemyList = new ArrayList<>(arenaEnemies.size());
for (ArenaEnemy arenaEnemy : arenaEnemies) {
int enemyId = arenaEnemy.getEnemyId();
int enemyType = arenaEnemy.getEnemyType();
try {
arenaEnemyList.add(getArenaEnemy(enemyId, enemyType));
} catch (Exception e) {
LOGGER.error("竞技场报错:{}",e.getMessage());
}
}
return arenaEnemyList;
}
// public List<CommonProto.ArenaEnemy> getArenaEnemyList(List<ArenaEnemy> arenaEnemies) {
// List<CommonProto.ArenaEnemy> arenaEnemyList = new ArrayList<>(arenaEnemies.size());
// for (ArenaEnemy arenaEnemy : arenaEnemies) {
// int enemyId = arenaEnemy.getEnemyId();
// int enemyType = arenaEnemy.getEnemyType();
// try {
// arenaEnemyList.add(getArenaEnemy(enemyId, enemyType));
// } catch (Exception e) {
// LOGGER.error("竞技场报错:{}",e.getMessage());
// }
// }
// return arenaEnemyList;
// }
public CommonProto.ArenaEnemy getArenaEnemy(int enemyId, int enemyType) throws Exception {
if (enemyType == 0) { //机器人
@ -109,12 +111,7 @@ public class ArenaLogic {
User user = UserManager.getUser(enemyId);
long totalForce = HeroLogic.getInstance().calTeamTotalForce(user, TeamEnum.TEAM_ARENA_DEFENSE.getTeamId());
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(TeamEnum.TEAM_ARENA_DEFENSE.getTeamId());
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();
CommonProto.Team teamBuild = buildTeam(user, teamPosHeroInfoList);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
long score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(curSeason), Integer.toString(enemyId)).longValue();
if (score == -1) {
@ -136,36 +133,45 @@ 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();
public static CommonProto.Team buildTeam(User user, List<TeamPosHeroInfo> teamPosHeroInfoList) {
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());
}
ArenaManager arenaManager = user.getArenaManager();
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
if (curSeason == 1 && arenaManager.getFlushNums() < SArenaSetting.getSArenaSetting().getPveNum()) {
Set<Integer> robotIds = randomRobot(score, 5);
toArenaEnemy(uid, robotIds, arenaEnemies, GlobalsDef.ARENA_ROBOT_TYPE);
} else {
Set<Integer> robotIds = randomPerson(uid, score, true);
int type = GlobalsDef.ARENA_PLAYER_TYPE;
toArenaEnemy(uid, robotIds, arenaEnemies, type);
if (robotIds.isEmpty()) {
if (curSeason > 1) {
robotIds = randomPerson(uid, score, false);
}
toArenaEnemy(uid, robotIds, arenaEnemies, type);
}
int size = robotIds.size();
if (size < 5) {
robotIds = randomRobot(score, 5 - size);
type = GlobalsDef.ARENA_ROBOT_TYPE;
toArenaEnemy(uid, robotIds, arenaEnemies, type);
}
}
arenaManager.setArenaEnemies(arenaEnemies);
return CommonProto.Team.newBuilder().addAllHeroTid(heroTids).build();
}
// 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 (curSeason == 1 && arenaManager.getFlushNums() < SArenaSetting.getSArenaSetting().getPveNum()) {
// Set<Integer> robotIds = randomRobot(score, 5);
// toArenaEnemy(uid, robotIds, arenaEnemies, GlobalsDef.ARENA_ROBOT_TYPE);
// } else {
// Set<Integer> robotIds = randomPerson(uid, score, true);
// int type = GlobalsDef.ARENA_PLAYER_TYPE;
// toArenaEnemy(uid, robotIds, arenaEnemies, type);
// if (robotIds.isEmpty()) {
// if (curSeason > 1) {
// robotIds = randomPerson(uid, score, false);
// }
// toArenaEnemy(uid, robotIds, arenaEnemies, type);
// }
// int size = robotIds.size();
// if (size < 5) {
// robotIds = randomRobot(score, 5 - size);
// type = GlobalsDef.ARENA_ROBOT_TYPE;
// toArenaEnemy(uid, robotIds, arenaEnemies, type);
// }
// }
// arenaManager.setArenaEnemies(arenaEnemies);
// }
/**
*
@ -238,51 +244,51 @@ public class ArenaLogic {
/**
*
*/
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(matchSeason), myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1);
LOGGER.info("curSeason={},matchSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},", curSeason, matchSeason, uid, myScore, low, high, myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1);
if (arenaRank != null && !arenaRank.isEmpty()) {
arenaRank.remove(Integer.toString(uid));
String s = randomSet(arenaRank);
if (!StringUtil.isEmpty(s)) {
result.add(Integer.parseInt(s));
}
}
}
return result;
}
// 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(matchSeason), myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1);
// LOGGER.info("curSeason={},matchSeason={},the uid={},the myscore={},the low={},the high={},mylow={},myhigh={},", curSeason, matchSeason, uid, myScore, low, high, myScore * low / 10000.0f - 1, myScore * high / 10000.0f + 1);
// if (arenaRank != null && !arenaRank.isEmpty()) {
// arenaRank.remove(Integer.toString(uid));
// String s = randomSet(arenaRank);
// if (!StringUtil.isEmpty(s)) {
// result.add(Integer.parseInt(s));
// }
// }
// }
// return result;
// }
private String randomSet(Set<String> infos) {
if (infos == null || infos.isEmpty()) {
return null;
}
int num = MathUtils.randomInt(infos.size());
for (String id : infos) {
if (num-- == 0) {
return id;
}
}
return null;
}
public void toArenaEnemy(int uid, Set<Integer> enemyList, List<ArenaEnemy> arenaEnemies, int type) {
for (Integer enemyId : enemyList) {
if (1 == type && enemyId == uid) {
continue;
}
arenaEnemies.add(new ArenaEnemy(enemyId, type, type));
}
}
// private String randomSet(Set<String> infos) {
// if (infos == null || infos.isEmpty()) {
// return null;
// }
// int num = MathUtils.randomInt(infos.size());
// for (String id : infos) {
// if (num-- == 0) {
// return id;
// }
// }
// return null;
//
// }
//
// public void toArenaEnemy(int uid, Set<Integer> enemyList, List<ArenaEnemy> arenaEnemies, int type) {
// for (Integer enemyId : enemyList) {
// if (1 == type && enemyId == uid) {
// continue;
// }
// arenaEnemies.add(new ArenaEnemy(enemyId, type, type));
// }
// }
// public void getWorldRankByPage(ISession session, int page) {
@ -672,68 +678,35 @@ public class ArenaLogic {
int size = 4;
Map<Integer, CommonProto.ArenaPersonInfo> result = new LimitedSizeMap<>(size);
// 每個人第一次初始化機器人
String markKey = RedisKey.NEW_ARENA_REFRESH_FIRST_MARK + ":" + user.getId();
String firstMark = redisUtil.getObject(markKey, String.class);
if (firstMark == null){
refreshRobotList(score, size, result);
redisUtil.set(markKey, "1");
}
SArenaSetting arenaSetting = SArenaSetting.getSArenaSetting();
int[][] interval = arenaSetting.getInterval();
// 读取配置走正常区间分配
for (int[] limit : interval) {
// 获取匹配积分区间的最大值和最小值
double low = score * limit[0] / 10000.0f - 1;
double high = score * limit[1] / 10000.0f + 1;
Set<String> range = redisUtil.getZsetRangeOrigin(key, low, high);
if (range == null || range.isEmpty()){
continue;
}
List<String> list = new ArrayList<>(range);
Collections.shuffle(list);
for (String id : list) {
int uid = Integer.parseInt(id);
if (uid == user.getId() || result.containsKey(uid)){
continue;
}
CommonProto.ArenaPersonInfo personInfo = CBean2Proto.getNewArenaPlayerProto(uid, roomId);
if (personInfo == null){
continue;
}
result.put(uid, personInfo);
if (result.size() == size){
break;
}
if (result.size() < size){
for (int[] limit : interval) {
// 获取匹配积分区间的最大值和最小值
double low = score * limit[0] / 10000.0f - 1;
double high = score * limit[1] / 10000.0f + 1;
Set<String> range = redisUtil.getZsetRangeOrigin(key, low, high);
refreshPersonList(user.getId(), size, roomId, range, result);
}
}
// 长度不足,走顺位排名
if (result.size() < size){
int end = ranking + size;
Set<String> zset = redisUtil.getReverseZset(key, ranking, end);
if (zset != null && !zset.isEmpty()){
for (String id : zset) {
int uid = Integer.parseInt(id);
if (uid == user.getId() || result.containsKey(uid)){
continue;
}
CommonProto.ArenaPersonInfo personInfo = CBean2Proto.getNewArenaPlayerProto(uid, roomId);
if (personInfo == null){
continue;
}
result.put(uid, personInfo);
if (result.size() == size){
break;
}
}
}
refreshPersonList(user.getId(), size, roomId, zset, result);
}
// 长度不足,走机器人表
if (result.size() < size){
Set<Integer> robotIds = randomRobot(score, size);
for (Integer robotId : robotIds) {
CommonProto.ArenaPersonInfo personInfo = CBean2Proto.getNewArenaRobotProto(robotId);
if (personInfo == null){
continue;
}
result.put(robotId, personInfo);
if (result.size() == size){
break;
}
}
refreshRobotList(score, size, result);
}
ArrayList<CommonProto.ArenaPersonInfo> personInfos = new ArrayList<>(result.values());
@ -742,6 +715,42 @@ public class ArenaLogic {
return personInfos;
}
public void refreshRobotList(long score, int size, Map<Integer, CommonProto.ArenaPersonInfo> result) {
Set<Integer> robotIds = randomRobot(score, size);
for (Integer robotId : robotIds) {
CommonProto.ArenaPersonInfo personInfo = CBean2Proto.getNewArenaRobotProto(robotId);
if (personInfo == null){
continue;
}
result.put(robotId, personInfo);
if (result.size() == size){
break;
}
}
}
public void refreshPersonList(int userId, int size, int roomId, Set<String> set, Map<Integer, CommonProto.ArenaPersonInfo> result){
if (set == null || set.isEmpty()){
return;
}
ArrayList<String> list = new ArrayList<>(set);
Collections.shuffle(list);
for (String id : list) {
int uid = Integer.parseInt(id);
if (uid == userId || result.containsKey(uid)){
continue;
}
CommonProto.ArenaPersonInfo personInfo = CBean2Proto.getNewArenaPlayerProto(uid, roomId);
if (personInfo == null){
continue;
}
result.put(uid, personInfo);
if (result.size() == size){
break;
}
}
}
/**
*
* @param session session
@ -1124,11 +1133,11 @@ public class ArenaLogic {
NewArenaRank rank = (NewArenaRank) RankEnum.toRank(RankEnum.NEW_ARENA_RANK.getType());
String title = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title");
// 最高场房间id
int maxHighRoomId = SArenaRoom.getMaxHighRoomId();
// int maxHighRoomId = SArenaRoom.getMaxHighRoomId();
for (Integer roomId : crossRooms) {
String roomName = SArenaRoom.getRoomName(roomId);
int ranking = 1;
int firstUid = 0;
// int firstUid = 0;
Set<ZSetOperations.TypedTuple<String>> allRank = rank.getAllRank(roomId);
if (allRank == null){
LOGGER.error("高级竞技场赛季发奖退出,找不到房间排行榜roomId{}",roomId);
@ -1150,9 +1159,9 @@ public class ArenaLogic {
// 重置标记,发送段位分
setNewArenaResetMark(uid, roomId, ranking);
// 获取第一名的uid
if (ranking == 1){
firstUid = uid;
}
// if (ranking == 1){
// firstUid = uid;
// }
}catch (Exception e){
LOGGER.error("高级竞技场赛季发奖报错,已跳过玩家:{},排名:{},错误:{}",value,ranking,e.getMessage());
e.printStackTrace();

View File

@ -139,48 +139,47 @@ public class CrossYuxulundaoLogic {
/**
*
*/
public void resetSeason(User user) {
PlayerManager player = user.getPlayerInfoManager();
}
public void setMatchRivals(User user) {
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if (crossGroup == -1) {
return;
}
Set<Integer> robotIds = new HashSet<>(5);
PlayerManager player = user.getPlayerInfoManager();
ArenaManager arenaManager = user.getArenaManager();
int curLevel = arenaManager.getCrossYuxulundaoNewLevelId();//当前段位
List<ArenaEnemy> arenaEnemies = new ArrayList<>(); //得存储
Map<Integer, SMServerRankConfig> robotConfigMap = STableManager.getConfig(SMServerRankConfig.class);
if (!robotConfigMap.containsKey(curLevel)) {
return;
}
int[] timePool = robotConfigMap.get(curLevel).getFitRobotPool();
if (arenaManager.getCrossMatchTimes() < timePool[0]) {
//匹配机器人
List<SArenaRobotConfig> robotConfig = STableManager.getConfig(SArenaRobotConfig.class).values().stream().filter(n -> n.getPoolId() == timePool[1]).collect(Collectors.toList());
Collections.shuffle(robotConfig);
robotConfig.subList(0, robotIds.size()).forEach(n -> robotIds.add(n.getId()));
for (int robot : robotIds) {
arenaEnemies.add(new ArenaEnemy(robot, 1, 0));
}
arenaManager.setCrossMatchTimes(arenaManager.getCrossMatchTimes() + 1);
arenaManager.setArenaEnemies(arenaEnemies);
} else {
//TODO 次数超过后怎么匹配真人 真人不足怎么办 匹配真人的规则
}
}
// public void resetSeason(User user) {
// PlayerManager player = user.getPlayerInfoManager();
//
// }
//
// public void setMatchRivals(User user) {
// int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
// if (crossGroup == -1) {
// return;
// }
// Set<Integer> robotIds = new HashSet<>(5);
// ArenaManager arenaManager = user.getArenaManager();
// int curLevel = arenaManager.getCrossYuxulundaoNewLevelId();//当前段位
// List<ArenaEnemy> arenaEnemies = new ArrayList<>(); //得存储
//
//
// Map<Integer, SMServerRankConfig> robotConfigMap = STableManager.getConfig(SMServerRankConfig.class);
// if (!robotConfigMap.containsKey(curLevel)) {
// return;
// }
// int[] timePool = robotConfigMap.get(curLevel).getFitRobotPool();
// if (arenaManager.getCrossMatchTimes() < timePool[0]) {
// //匹配机器人
// List<SArenaRobotConfig> robotConfig = STableManager.getConfig(SArenaRobotConfig.class).values().stream().filter(n -> n.getPoolId() == timePool[1]).collect(Collectors.toList());
// Collections.shuffle(robotConfig);
// robotConfig.subList(0, robotIds.size()).forEach(n -> robotIds.add(n.getId()));
// for (int robot : robotIds) {
// arenaEnemies.add(new ArenaEnemy(robot, 1, 0));
// }
// arenaManager.setCrossMatchTimes(arenaManager.getCrossMatchTimes() + 1);
// arenaManager.setArenaEnemies(arenaEnemies);
// } else {
// //TODO 次数超过后怎么匹配真人 真人不足怎么办 匹配真人的规则
// }
//
// }
/**
*
*/
public void matchRivals(User user) throws Exception {
public void matchRivals(User user) {
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if (crossGroup == -1) {
return;

View File

@ -1166,12 +1166,7 @@ public class ChampionshipLogic {
long totalForce = HeroLogic.getInstance().calTeamTotalForce(user, TeamEnum.CHAMPION_TEAM.getTeamId());
if (type == 0) {
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(TeamEnum.CHAMPION_TEAM.getTeamId());
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();
CommonProto.Team teamBuild = ArenaLogic.buildTeam(user, teamPosHeroInfoList);
builder.setTeam(teamBuild);
}

View File

@ -6,14 +6,8 @@ import java.util.*;
public class ArenaManager extends MongoBase {
private int failNums; //失败次数
private int successNums; //胜利次数
private int count; //进攻次数
private int flushTime; //刷新时间
private int topMaxRank=0; // 我的历史最高排名
public int worldFreeChallengeTime=0;
private List<ArenaEnemy> arenaEnemies;
public int costDallyTime=0;
private List<ArenaEnemy> crossYuxulundaoEnemies;
//跨服 玉虚论道
@ -60,71 +54,6 @@ public class ArenaManager extends MongoBase {
return newArenaLvScore;
}
public void updateChallenge(int fightResult){
if(fightResult == 1){
successNums ++;
updateString("successNums",successNums);
}else{
failNums++;
updateString("failNums",failNums);
}
count++;
updateString("count",count);
}
public int getFailNums() {
return failNums;
}
public int getSuccessNums() {
return successNums;
}
public int getCount() {
return count;
}
public int getFlushTime() {
return flushTime;
}
public List<ArenaEnemy> getArenaEnemies() {
return arenaEnemies;
}
public void setArenaEnemies(List<ArenaEnemy> arenaEnemies) {
Collections.shuffle(arenaEnemies);
updateString("arenaEnemies",arenaEnemies);
this.arenaEnemies = arenaEnemies;
}
public void setFlushTime(int flushTime) {
this.flushTime = flushTime;
updateString("flushTime",flushTime);
}
public int getFlushNums() {
return 0;
}
public int getSeason() {
return 0;
}
public void resetSeason(int curSeason) {
this.failNums =0;
this.successNums=0;
this.count=0;
this.flushTime=0;
updateString("failNums",failNums);
updateString("successNums",successNums);
updateString("count",count);
updateString("flushTime",flushTime);
}
public int getTopMaxRank() {
return topMaxRank;
}
@ -134,17 +63,13 @@ public class ArenaManager extends MongoBase {
updateString("topMaxRank",topMaxRank);
}
public List<Integer> getHadTakeReward() {
return new LinkedList<>();
public int getCostDallyTime() {
return costDallyTime;
}
public int getWorldFreeChallengeTime() {
return worldFreeChallengeTime;
}
public void setWorldFreeChallengeTime(int worldFreeChallengeTime) {
updateString("worldFreeChallengeTime",worldFreeChallengeTime);
this.worldFreeChallengeTime = worldFreeChallengeTime;
public void setCostDallyTime(int costDallyTime) {
updateString("costDallyTime",costDallyTime);
this.costDallyTime = costDallyTime;
}
public List<ArenaEnemy> getCrossYuxulundaoEnemies() {

View File

@ -2529,7 +2529,7 @@ public class HeroLogic {
}
SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(templatePropetyId);
if (sPropertyConfig.getIfFormula() == 1) {
sb.append(propertyValue * 0.1 / (sArenaRobotConfig.getRoleLv() + 10) / 100).append(DIVISION);
sb.append(propertyValue * 0.1 / (robotLevel + 10) / 100).append(DIVISION);
} else {
if (sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE) {
sb.append(propertyValue / 10000f).append(DIVISION);

View File

@ -782,25 +782,19 @@ public class PlayerLogic {
CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
if(id ==TeamEnum.CROSS_YU_XU_LUN_DAO_ONE.getTeamId()){
for(Map.Entry<Integer,CommonProto.Hero> item : sArenaRobotConfig.getHeroMapList().entrySet()){
Integer heroTid = item.getKey();
int heroStar = item.getValue().getStar();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder().setPropertyId(item.getValue().getPropertyId()).setHeroid(String.valueOf(heroTid)).setHeroTid(heroTid).setLevel(sArenaRobotConfig.getRoleLv()).setStar(heroStar).setPosition(position++).setGodSoulLv(item.getValue().getGodSoulLv()).build());
position = getPosition(sArenaRobotConfig, position, teamInfo, item);
}
teamInfo.setTotalForce(sArenaRobotConfig.getYxldTotalForce1());
}else if(id ==TeamEnum.CROSS_YU_XU_LUN_DAO_TWO.getTeamId()){
for(Map.Entry<Integer,CommonProto.Hero> item : sArenaRobotConfig.getHeroMapList2().entrySet()){
Integer heroTid = item.getKey();
int heroStar = item.getValue().getStar();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder().setPropertyId(item.getValue().getPropertyId()).setHeroid(String.valueOf(heroTid)).setHeroTid(heroTid).setLevel(sArenaRobotConfig.getRoleLv()).setStar(heroStar).setPosition(position++).setGodSoulLv(item.getValue().getGodSoulLv()).build());
position = getPosition(sArenaRobotConfig, position, teamInfo, item);
}
teamInfo.setTotalForce(sArenaRobotConfig.getYxldTotalForce2());
}else if(id ==TeamEnum.CROSS_YU_XU_LUN_DAO_THREE.getTeamId()){
for(Map.Entry<Integer,CommonProto.Hero> item : sArenaRobotConfig.getHeroMapList3().entrySet()){
Integer heroTid = item.getKey();
int heroStar = item.getValue().getStar();
teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder().setPropertyId(item.getValue().getPropertyId()).setHeroid(String.valueOf(heroTid)).setHeroTid(heroTid).setLevel(sArenaRobotConfig.getRoleLv()).setStar(heroStar).setPosition(position++).setGodSoulLv(item.getValue().getGodSoulLv()).build());
position = getPosition(sArenaRobotConfig, position, teamInfo, item);
}
teamInfo.setTotalForce(sArenaRobotConfig.getYxldTotalForce3());
}
@ -809,6 +803,22 @@ public class PlayerLogic {
return oneInfo;
}
public int getPosition(SArenaRobotConfig sArenaRobotConfig, int position, CommonProto.TeamOneTeamInfo.Builder teamInfo, Map.Entry<Integer, CommonProto.Hero> item) {
Integer heroTid = item.getKey();
CommonProto.Hero hero = item.getValue();
CommonProto.TeamSimpleInfo build = CommonProto.TeamSimpleInfo.newBuilder()
.setPropertyId(hero.getPropertyId())
.setHeroid(String.valueOf(heroTid))
.setHeroTid(heroTid)
.setLevel(sArenaRobotConfig.getRoleLv())
.setStar(hero.getStar())
.setPosition(position++)
.setGodSoulLv(hero.getGodSoulLv())
.build();
teamInfo.addTeam(build);
return position;
}
//获取跨服玩家信息
public CommonProto.TeamOneInfo getCrossYxldMyTeamInfo(User user,List<Integer> team) throws Exception{
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(user.getId());
@ -989,7 +999,8 @@ public class PlayerLogic {
builder.setForce(HeroLogic.getInstance().calForce(robotHeroAttribute));
if(teamId==TeamEnum.CROSS_YU_XU_LUN_DAO_ONE.getTeamId()){
builder.setHero(sArenaRobotConfig.getHeroMapList().get(scHero.getId()));
}else if(teamId==TeamEnum.CROSS_YU_XU_LUN_DAO_TWO.getTeamId()){
}
else if(teamId==TeamEnum.CROSS_YU_XU_LUN_DAO_TWO.getTeamId()){
builder.setHero(sArenaRobotConfig.getHeroMapList2().get(scHero.getId()));
}
else if(teamId==TeamEnum.CROSS_YU_XU_LUN_DAO_THREE.getTeamId()){

View File

@ -26,7 +26,7 @@ public enum RankEnum {
EXPERT_RANK(21,RedisKey.EXPERT_RANK,GoldRank::new,false),// 达人排行榜 param1活动进度 param2无 param3:无
FORCE_CURR_RANK(22,RedisKey.FORCE_CURR_RANK,ForceCurrRank::new,false),//新战力排行榜 param1人物战力 param2无 param3:无
@Deprecated
ARENA_RANK(23,RedisKey.ARENA_RANK,ArenaRank::new,false),// 竞技场排行榜 param1竞技场积分 param2无 param3:无
// ARENA_RANK(23,RedisKey.ARENA_RANK,ArenaRank::new,false),// 竞技场排行榜 param1竞技场积分 param2无 param3:无
SITUATION_RANK(24,RedisKey.SITUATION_RANK,SituationRank::new,false),//param1通关次数 param2无 param3:无
GUILD_CHALLENGE_RANK(26,RedisKey.GUILD_CHALLENGE_RANK,GuildChallengeRank::new,false),//param1伤害 param2无 param3:无
GUILD_SHEJI_SCORE_RANK(27,RedisKey.GUILD_SHEJI_SCORE_RANK,GuildSheJiScoreRank::new,false),//param1公会社稷贡献 param2无 param3:无