|
@@ -38,43 +38,75 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
public class Contest {
|
|
|
|
|
|
- /** 比赛数据 **/
|
|
|
+ /**
|
|
|
+ * 比赛数据
|
|
|
+ **/
|
|
|
public ContestPO data;
|
|
|
- /** 比赛策划表配置 **/
|
|
|
+ /**
|
|
|
+ * 比赛策划表配置
|
|
|
+ **/
|
|
|
public ContestExt prop;
|
|
|
- /** 当前晋级配置 **/
|
|
|
+ /**
|
|
|
+ * 当前晋级配置
|
|
|
+ **/
|
|
|
public PromotionLvCO propPromotionLv;
|
|
|
|
|
|
- /** 激活标记 **/
|
|
|
+ /**
|
|
|
+ * 激活标记
|
|
|
+ **/
|
|
|
private boolean isActive;
|
|
|
- /** 检测标记 **/
|
|
|
+ /**
|
|
|
+ * 检测标记
|
|
|
+ **/
|
|
|
public boolean flag;
|
|
|
- /** 时间秒数 **/
|
|
|
+ /**
|
|
|
+ * 时间秒数
|
|
|
+ **/
|
|
|
public int time;
|
|
|
- /** 比赛状态(0等待/报名中 1比赛开始 2进行中 3已结束) **/
|
|
|
+ /**
|
|
|
+ * 比赛状态(0等待/报名中 1比赛开始 2进行中 3已结束)
|
|
|
+ **/
|
|
|
public int state;
|
|
|
|
|
|
- /**比赛当前状态0等待/报名中 1比赛开始 2进行中 3当局结束 */
|
|
|
+ /**
|
|
|
+ * 比赛当前状态0等待/报名中 1比赛开始 2进行中 3当局结束
|
|
|
+ */
|
|
|
public int contestState;
|
|
|
|
|
|
- /** 每个房间玩家容量 **/
|
|
|
+ /**
|
|
|
+ * 每个房间玩家容量
|
|
|
+ **/
|
|
|
private final int roomCapacity = 4;
|
|
|
|
|
|
- /** 比赛报名角色 [key:玩家id, value:玩家对象]**/
|
|
|
+ /**
|
|
|
+ * 比赛报名角色 [key:玩家id, value:玩家对象]
|
|
|
+ **/
|
|
|
public Map<String, Player> actors = new ConcurrentHashMap<>();
|
|
|
- /** 比赛房间列表 **/
|
|
|
+ /**
|
|
|
+ * 比赛房间列表
|
|
|
+ **/
|
|
|
public Map<Long, Room> rooms = new ConcurrentHashMap<>();
|
|
|
- /** 等待队列 **/
|
|
|
+ /**
|
|
|
+ * 等待队列
|
|
|
+ **/
|
|
|
private final ConcurrentLinkedQueue<String> waitingPlayers = new ConcurrentLinkedQueue<>();
|
|
|
- /**淘汰队列*/
|
|
|
+ /**
|
|
|
+ * 淘汰队列
|
|
|
+ */
|
|
|
private final ConcurrentLinkedQueue<String> DieOutPlayers = new ConcurrentLinkedQueue<>();
|
|
|
- /**替补队列*/
|
|
|
+ /**
|
|
|
+ * 替补队列
|
|
|
+ */
|
|
|
private final ConcurrentLinkedQueue<String> SubstitutePlayers = new ConcurrentLinkedQueue<>();
|
|
|
|
|
|
- /** 是否进行下一轮 **/
|
|
|
+ /**
|
|
|
+ * 是否进行下一轮
|
|
|
+ **/
|
|
|
public boolean isNext = true;
|
|
|
|
|
|
- /** 比赛任务主线程 **/
|
|
|
+ /**
|
|
|
+ * 比赛任务主线程
|
|
|
+ **/
|
|
|
private ScheduledExecutorService scheduler;
|
|
|
|
|
|
public Contest() {
|
|
@@ -102,21 +134,21 @@ public class Contest {
|
|
|
this.data = new ContestPO();
|
|
|
this.data.contestId = contestId;
|
|
|
// todo 测试
|
|
|
- this.data.startTime = LocalDateTime.parse(this.prop.openTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
|
|
|
- Log.info("比赛开始时间:{}",this.data.startTime);
|
|
|
+ this.data.startTime = LocalDateTime.parse(this.prop.openTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
|
|
|
+ Log.info("比赛开始时间:{}", this.data.startTime);
|
|
|
this.data.level = this.prop.level;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据当前人数刷新晋级配置
|
|
|
*
|
|
|
- * @param num 实际报名人数
|
|
|
+ * @param num 实际报名人数
|
|
|
*/
|
|
|
public void refreshPromotionLv(int num) {
|
|
|
// for (PromotionLvCO config : GameData.PromotionLvs.values()) {
|
|
|
- if (num >= this.propPromotionLv.min && num <= this.propPromotionLv.max) {
|
|
|
- this.propPromotionLv.num = num/2;
|
|
|
- }
|
|
|
+ if (num >= this.propPromotionLv.min && num <= this.propPromotionLv.max) {
|
|
|
+ this.propPromotionLv.num = num / 2;
|
|
|
+ }
|
|
|
// }
|
|
|
}
|
|
|
|
|
@@ -146,7 +178,7 @@ public class Contest {
|
|
|
//给其他人推送当前
|
|
|
this.actors.forEach((id, p) -> {
|
|
|
Map<String, Object> map = ProtoUtil.contestInfoToMessage(this);
|
|
|
- p.receive(CommonProto.Cmd.GetSignUpNum_VALUE,map);
|
|
|
+ p.receive(CommonProto.Cmd.GetSignUpNum_VALUE, map);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -168,7 +200,7 @@ public class Contest {
|
|
|
//给其他人推送当前
|
|
|
this.actors.forEach((id, p) -> {
|
|
|
Map<String, Object> map = ProtoUtil.contestInfoToMessage(this);
|
|
|
- p.receive(CommonProto.Cmd.GetSignUpNum_VALUE,map);
|
|
|
+ p.receive(CommonProto.Cmd.GetSignUpNum_VALUE, map);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -186,7 +218,7 @@ public class Contest {
|
|
|
* 开启官方比赛主线程
|
|
|
*/
|
|
|
public void startContestTask() {
|
|
|
- this.isActive = true;
|
|
|
+ this.isActive = this.prop.getRunStatus().equals("Y");
|
|
|
this.scheduler.scheduleAtFixedRate(() -> {
|
|
|
try {
|
|
|
if (this.isActive) {
|
|
@@ -241,14 +273,14 @@ public class Contest {
|
|
|
// 进行中
|
|
|
if (!this.flag) {
|
|
|
// 检测当轮是否结束
|
|
|
- if (this.checkRoomsAllOver()){
|
|
|
+ if (this.checkRoomsAllOver()) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
|
// 下一轮
|
|
|
- if (this.isNext&&this.time>=10) {
|
|
|
+ if (this.isNext && this.time >= 10) {
|
|
|
// this.state = 1;
|
|
|
this.contestState = 1;
|
|
|
this.flag = false;
|
|
@@ -293,8 +325,7 @@ public class Contest {
|
|
|
*/
|
|
|
public boolean isStart(Date date) {
|
|
|
// 时间是否到了
|
|
|
- boolean boon = date.getTime() >= this.data.startTime - (3 * 1000);
|
|
|
- return boon;
|
|
|
+ return date.getTime() >= this.data.startTime - (3 * 1000);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -329,9 +360,9 @@ public class Contest {
|
|
|
jsonData.put("playerNum", 4);
|
|
|
// 房间最大局数 分为预赛和决赛
|
|
|
// jsonData.put("maxRound", this.prop.maxRound);
|
|
|
- if (this.waitingPlayers.size() <=4){//决赛
|
|
|
+ if (this.waitingPlayers.size() <= 4) {//决赛
|
|
|
this.prop.maxRound = this.prop.finalNum;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.prop.maxRound = this.prop.readyNum;
|
|
|
}
|
|
|
|
|
@@ -404,11 +435,11 @@ public class Contest {
|
|
|
*/
|
|
|
public void doStart() {
|
|
|
cn.hutool.json.JSONObject object = new cn.hutool.json.JSONObject();
|
|
|
- object.put("type","updateCompete");
|
|
|
+ object.put("type", "updateCompete");
|
|
|
// 设置比赛数据
|
|
|
this.data.curRound += 1;
|
|
|
// 检测比赛人数是否满足最小人数配置
|
|
|
- if (this.data.curRound==1 && this.actors.size() < this.propPromotionLv.min) {
|
|
|
+ if (this.data.curRound == 1 && this.actors.size() < this.propPromotionLv.min) {
|
|
|
// 流局结束
|
|
|
for (Player tmPlayer : this.actors.values()) {
|
|
|
if (tmPlayer != null) {
|
|
@@ -423,8 +454,8 @@ public class Contest {
|
|
|
}
|
|
|
this.state = 3;
|
|
|
this.isActive = false;
|
|
|
- object.put("status","5");
|
|
|
- object.put("competeId",this.data.contestId);
|
|
|
+ object.put("status", "5");
|
|
|
+ object.put("competeId", this.data.contestId);
|
|
|
try {
|
|
|
RabbitMQUtil.sendMessage(object.toString());
|
|
|
} catch (Exception e) {
|
|
@@ -432,15 +463,15 @@ public class Contest {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- object.put("status","3");
|
|
|
- object.put("competeId",this.data.contestId);
|
|
|
+ object.put("status", "3");
|
|
|
+ object.put("competeId", this.data.contestId);
|
|
|
try {
|
|
|
RabbitMQUtil.sendMessage(object.toString());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
int i = this.waitingPlayers.size() % 4;
|
|
|
- if (i!=0){
|
|
|
+ if (i != 0) {
|
|
|
List<String> list = new ArrayList<>(this.waitingPlayers);
|
|
|
// 打乱列表顺序
|
|
|
Collections.shuffle(list);
|
|
@@ -474,9 +505,9 @@ public class Contest {
|
|
|
}
|
|
|
// switch (room.data.gameType) {
|
|
|
// case 1:
|
|
|
- if ( room.data.curRound >= this.prop.maxRound && room.state == 3) {
|
|
|
- cnt += 1;
|
|
|
- }
|
|
|
+ if (room.data.curRound >= this.prop.maxRound && room.state == 3) {
|
|
|
+ cnt += 1;
|
|
|
+ }
|
|
|
// break;
|
|
|
// }
|
|
|
}
|
|
@@ -485,8 +516,8 @@ public class Contest {
|
|
|
this.flag = true;
|
|
|
//统计分数 晋级
|
|
|
this.promotionLv();
|
|
|
- this.propPromotionLv.num = this.rooms.size()/2;
|
|
|
- if (this.rooms.size()>1){
|
|
|
+ this.propPromotionLv.num = this.rooms.size() / 2;
|
|
|
+ if (this.rooms.size() > 1) {
|
|
|
// 结束
|
|
|
this.gameOver();
|
|
|
//不结算 ,下一轮
|
|
@@ -494,16 +525,16 @@ public class Contest {
|
|
|
//清理所有房间数据
|
|
|
this.rooms.clear();
|
|
|
//加入替补玩家
|
|
|
- if (this.prop.substituteRule==1){
|
|
|
+ if (this.prop.substituteRule == 1) {
|
|
|
String playerId = this.DieOutPlayers.poll();
|
|
|
if (!StringUtils.isEmpty(playerId)) {
|
|
|
Player tmPlayer = (Player) PlayerUtil.getOnlinePlayer(playerId);
|
|
|
Map<String, Object> data = ProtoUtil.contestInfoToMessage(this);
|
|
|
- data.put("message", "当前比赛可替补,是否花费"+this.prop.substituteCost+"钻石替补");
|
|
|
+ data.put("message", "当前比赛可替补,是否花费" + this.prop.substituteCost + "钻石替补");
|
|
|
tmPlayer.receive(CommonProto.Cmd.CandidatePlayer_VALUE, data);
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.contestState = 3;
|
|
|
this.state = 3;
|
|
|
//结束比赛
|
|
@@ -519,7 +550,7 @@ public class Contest {
|
|
|
for (GPlayer player : onlinePlayers.values()) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
// 官方比赛信息列表
|
|
|
- map.put("contestInfo", GetContestListHandler.contestInfoList((Player)player));
|
|
|
+ map.put("contestInfo", GetContestListHandler.contestInfoList((Player) player));
|
|
|
player.receive(CommonProto.Cmd.GetContestListRes_VALUE, map);
|
|
|
}
|
|
|
}
|
|
@@ -529,7 +560,7 @@ public class Contest {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *统计分数 晋级
|
|
|
+ * 统计分数 晋级
|
|
|
*/
|
|
|
private void promotionLv() {
|
|
|
Map<Long, List<Struct.PromotionData>> roomMap = this.data.promotionMap.getOrDefault(this.data.curRound, new HashMap<>());
|
|
@@ -537,7 +568,7 @@ public class Contest {
|
|
|
int cnt;
|
|
|
|
|
|
// 首轮按配置表晋级,后面按头游二游晋级
|
|
|
- cnt = this.prop.model == 4? 2 : 1;
|
|
|
+ cnt = this.prop.model == 4 ? 2 : 1;
|
|
|
|
|
|
List<Player> objects = new ArrayList<>();
|
|
|
for (Room room : this.rooms.values()) {
|
|
@@ -545,47 +576,47 @@ public class Contest {
|
|
|
continue;
|
|
|
}
|
|
|
List<Struct.PromotionData> list = roomMap.getOrDefault(room.data.roomId, new ArrayList<>());
|
|
|
- if (room.data.result.size() >= room.data.maxNum) {
|
|
|
- //计算计分 头游
|
|
|
- Player Player1 = this.actors.getOrDefault(room.data.result.get(1).playerId,null);
|
|
|
- // 分
|
|
|
- int scores = 0;
|
|
|
-
|
|
|
- // 头游搭档数据
|
|
|
- Struct.TeammateData teammateData = ((ZDRoom)room).getTeammate(Player1.data.teammateId);
|
|
|
- switch (teammateData.getRank()) {
|
|
|
- case 2:
|
|
|
- // 搭档2游, +4
|
|
|
- scores = 4;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- // 搭档3游, +2
|
|
|
- scores = 2;
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- // 搭档4游, +1
|
|
|
- scores = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- list.add(new Struct.PromotionData(Player1.getId(), Player1.data.avatarUrl, Player1.data.name,scores, 1, this.rooms.size()==1));
|
|
|
- Player Player2 = teammateData.player;
|
|
|
- Player1.data.matchPoints = Player1.data.matchPoints + scores;
|
|
|
- Player2.data.matchPoints = Player2.data.matchPoints + scores;
|
|
|
- list.add(new Struct.PromotionData(Player2.getId(), Player2.data.avatarUrl, Player2.data.name,scores, teammateData.rank, this.rooms.size()==1));
|
|
|
- objects.add(Player1);
|
|
|
- objects.add(Player2);
|
|
|
- for (int i = 1; i <= room.data.result.size(); i++) {
|
|
|
- Player tmPlayer =this.actors.getOrDefault(room.data.result.getOrDefault(i, null).playerId,null);
|
|
|
- if (tmPlayer != null
|
|
|
- && !tmPlayer.getId().equals(Player1.getId())
|
|
|
- && !tmPlayer.getId().equals(teammateData.player.getId())) {
|
|
|
- tmPlayer.data.matchPoints = tmPlayer.data.matchPoints - scores;
|
|
|
- list.add(new Struct.PromotionData(tmPlayer.getId(), tmPlayer.data.avatarUrl, tmPlayer.data.name, -scores, i, this.rooms.size()==1));
|
|
|
- objects.add(tmPlayer);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (room.data.result.size() >= room.data.maxNum) {
|
|
|
+ //计算计分 头游
|
|
|
+ Player Player1 = this.actors.getOrDefault(room.data.result.get(1).playerId, null);
|
|
|
+ // 分
|
|
|
+ int scores = 0;
|
|
|
+
|
|
|
+ // 头游搭档数据
|
|
|
+ Struct.TeammateData teammateData = ((ZDRoom) room).getTeammate(Player1.data.teammateId);
|
|
|
+ switch (teammateData.getRank()) {
|
|
|
+ case 2:
|
|
|
+ // 搭档2游, +4
|
|
|
+ scores = 4;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ // 搭档3游, +2
|
|
|
+ scores = 2;
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ // 搭档4游, +1
|
|
|
+ scores = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ list.add(new Struct.PromotionData(Player1.getId(), Player1.data.avatarUrl, Player1.data.name, scores, 1, this.rooms.size() == 1));
|
|
|
+ Player Player2 = teammateData.player;
|
|
|
+ Player1.data.matchPoints = Player1.data.matchPoints + scores;
|
|
|
+ Player2.data.matchPoints = Player2.data.matchPoints + scores;
|
|
|
+ list.add(new Struct.PromotionData(Player2.getId(), Player2.data.avatarUrl, Player2.data.name, scores, teammateData.rank, this.rooms.size() == 1));
|
|
|
+ objects.add(Player1);
|
|
|
+ objects.add(Player2);
|
|
|
+ for (int i = 1; i <= room.data.result.size(); i++) {
|
|
|
+ Player tmPlayer = this.actors.getOrDefault(room.data.result.getOrDefault(i, null).playerId, null);
|
|
|
+ if (tmPlayer != null
|
|
|
+ && !tmPlayer.getId().equals(Player1.getId())
|
|
|
+ && !tmPlayer.getId().equals(teammateData.player.getId())) {
|
|
|
+ tmPlayer.data.matchPoints = tmPlayer.data.matchPoints - scores;
|
|
|
+ list.add(new Struct.PromotionData(tmPlayer.getId(), tmPlayer.data.avatarUrl, tmPlayer.data.name, -scores, i, this.rooms.size() == 1));
|
|
|
+ objects.add(tmPlayer);
|
|
|
+ }
|
|
|
+ }
|
|
|
// objects.addAll(list);
|
|
|
- //开始循环
|
|
|
+ //开始循环
|
|
|
// for (int i = 1; i <= ((GDRoom) room).data.result.size(); i++) {
|
|
|
// Player player = ((GDRoom) room).data.result.getOrDefault(i, null);
|
|
|
// if (player != null) {
|
|
@@ -652,13 +683,13 @@ public class Contest {
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
- }
|
|
|
+ }
|
|
|
roomMap.put(room.data.roomId, list);
|
|
|
}
|
|
|
//排序
|
|
|
objects.sort((o1, o2) -> Long.compare(o2.data.matchPoints, o1.data.matchPoints));
|
|
|
- for (int i = 1; i <=objects.size(); i++) {
|
|
|
- Player player = objects.get(i-1);
|
|
|
+ for (int i = 1; i <= objects.size(); i++) {
|
|
|
+ Player player = objects.get(i - 1);
|
|
|
player.data.roomId = 0;
|
|
|
Map<String, Object> messageMap = new HashMap<>();
|
|
|
String message;
|
|
@@ -672,13 +703,13 @@ public class Contest {
|
|
|
processRank(1, player, rewards, map);
|
|
|
break;
|
|
|
case 2:
|
|
|
- processRank(2,player, rewards, map);
|
|
|
+ processRank(2, player, rewards, map);
|
|
|
break;
|
|
|
case 3:
|
|
|
- processRank(3,player, rewards, map);
|
|
|
+ processRank(3, player, rewards, map);
|
|
|
break;
|
|
|
case 4:
|
|
|
- processRank(4,player, rewards, map);
|
|
|
+ processRank(4, player, rewards, map);
|
|
|
break;
|
|
|
}
|
|
|
cmd = CommonProto.Cmd.FirstPlayer_VALUE;
|
|
@@ -689,22 +720,22 @@ public class Contest {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
// 格式化Date对象为字符串
|
|
|
String formattedDateTime = formatter.format(now);
|
|
|
- map.put("date",formattedDateTime);
|
|
|
+ map.put("date", formattedDateTime);
|
|
|
map.put("contestName", this.prop.desc);
|
|
|
messageMap.put("message", map);
|
|
|
player.receive(cmd, messageMap);
|
|
|
|
|
|
cn.hutool.json.JSONObject object = new cn.hutool.json.JSONObject();
|
|
|
- object.put("type","GetCompeteReward");
|
|
|
- object.put("userId",player.data.playerId);
|
|
|
- object.put("competeId",this.data.contestId);
|
|
|
- object.put("rank",i);
|
|
|
+ object.put("type", "GetCompeteReward");
|
|
|
+ object.put("userId", player.data.playerId);
|
|
|
+ object.put("competeId", this.data.contestId);
|
|
|
+ object.put("rank", i);
|
|
|
try {
|
|
|
RabbitMQUtil.sendMessage(object.toString());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
if (i <= this.propPromotionLv.num) {
|
|
|
roomMap.forEach((key, value) -> {
|
|
|
Optional<Struct.PromotionData> first = value.stream()
|
|
@@ -720,7 +751,7 @@ public class Contest {
|
|
|
cmd = CommonProto.Cmd.PromotePlayer_VALUE;
|
|
|
messageMap.put("message", message);
|
|
|
player.receive(cmd, messageMap);
|
|
|
- } else{
|
|
|
+ } else {
|
|
|
roomMap.forEach((key, value) -> {
|
|
|
Optional<Struct.PromotionData> first = value.stream()
|
|
|
.filter(promotionData -> promotionData.getPlayerId().equals(player.getId()))
|
|
@@ -750,15 +781,15 @@ public class Contest {
|
|
|
cn.hutool.json.JSONObject reward = (cn.hutool.json.JSONObject) o;
|
|
|
String rank1 = (String) reward.get("rank");
|
|
|
String[] split = rank1.split("-");
|
|
|
- if (split.length>1){
|
|
|
- int min = Integer.parseInt(split[0]);
|
|
|
- int max = Integer.parseInt(split[1]);
|
|
|
- if (rank>=min&&rank<=max){
|
|
|
- getReward(reward,msg);//领奖品处理
|
|
|
+ if (split.length > 1) {
|
|
|
+ int min = Integer.parseInt(split[0]);
|
|
|
+ int max = Integer.parseInt(split[1]);
|
|
|
+ if (rank >= min && rank <= max) {
|
|
|
+ getReward(reward, msg);//领奖品处理
|
|
|
}
|
|
|
- }else {
|
|
|
- if (Integer.parseInt(split[0])==rank) {
|
|
|
- getReward(reward,msg);//领奖品处理
|
|
|
+ } else {
|
|
|
+ if (Integer.parseInt(split[0]) == rank) {
|
|
|
+ getReward(reward, msg);//领奖品处理
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -768,7 +799,7 @@ public class Contest {
|
|
|
map.put("name", player.data.name);
|
|
|
}
|
|
|
|
|
|
- private static void getReward(cn.hutool.json.JSONObject reward,StringBuilder msg){
|
|
|
+ private static void getReward(cn.hutool.json.JSONObject reward, StringBuilder msg) {
|
|
|
JSONArray objects = new JSONArray(reward.get("reward"));
|
|
|
for (Object object : objects) {
|
|
|
cn.hutool.json.JSONObject obj = (cn.hutool.json.JSONObject) object;
|
|
@@ -776,39 +807,6 @@ public class Contest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 比赛结算
|
|
|
- */
|
|
|
- private void settlement() {
|
|
|
- this.isActive = false;
|
|
|
- Log.info("开始结算");
|
|
|
- //推送第一名
|
|
|
- Map<Long, List<Struct.PromotionData>> longListMap = this.data.promotionMap.get(this.data.curRound);
|
|
|
- longListMap.forEach((key, value) -> {
|
|
|
-// if (key == this.data.curRound){
|
|
|
- value.forEach(promotionData -> {
|
|
|
- // 推送第一名奖状
|
|
|
- if(promotionData.rank==1){
|
|
|
- String playerId = promotionData.playerId;
|
|
|
- Player player = (Player)PlayerUtil.getOnlinePlayer(playerId);
|
|
|
- if (player != null) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("message", "恭喜你获得第一名");
|
|
|
- player.receive(CommonProto.Cmd.FirstPlayer_VALUE, map);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-// }
|
|
|
- });
|
|
|
- Log.info("比赛结算完成");
|
|
|
-
|
|
|
- // 计算排行榜
|
|
|
-
|
|
|
- // 解散房间
|
|
|
-
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 比赛结束
|
|
|
*/
|