|
@@ -57,8 +57,8 @@ public class ZDRoom extends Room {
|
|
|
this.data.isTribute = false;
|
|
|
// 初始化牌库
|
|
|
this.initCardList();
|
|
|
- //初始化比赛
|
|
|
- this.data.contestId= jsonData.getLong("contestId");
|
|
|
+ // 初始化比赛
|
|
|
+ this.data.contestId = this.data.type == 1? jsonData.getLong("contestId") : 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -328,6 +328,7 @@ public class ZDRoom extends Room {
|
|
|
*/
|
|
|
@Override
|
|
|
public synchronized void doSendCard() {
|
|
|
+ List<String> teammate = new ArrayList<>();
|
|
|
for (Player player : this.actors.values()) {
|
|
|
if (player != null) {
|
|
|
// 设置用户状态
|
|
@@ -350,6 +351,12 @@ public class ZDRoom extends Room {
|
|
|
player.data.remainCards = CardUtils.add(player.data.remainCards, card);
|
|
|
this.data.cardList.remove(0);
|
|
|
}
|
|
|
+ // 设置翻牌队友
|
|
|
+ if (CardUtils.contains(player.data.remainCards, this.data.showCard) && teammate.size() < 2) {
|
|
|
+ if (!teammate.contains(player.getId())) {
|
|
|
+ teammate.add(player.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
// todo 测试代码
|
|
|
// if (this.data.wildCard != 0) {
|
|
|
// player.data.remainCards = CardUtils.add(player.data.remainCards, this.data.wildCard);
|
|
@@ -358,6 +365,60 @@ public class ZDRoom extends Room {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 随机搭档
|
|
|
+ if (this.jsonData.getInteger("team") == 1) {
|
|
|
+ if (teammate.size() == 2) {
|
|
|
+ List<String> other = new ArrayList<>();
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null && !teammate.contains(tmPlayer.getId())) {
|
|
|
+ other.add(tmPlayer.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (other.size() == 2) {
|
|
|
+ Player p1 = this.actors.getOrDefault(teammate.get(0), null);
|
|
|
+ Player p2 = this.actors.getOrDefault(teammate.get(1), null);
|
|
|
+ if (p1 != null && p2 != null) {
|
|
|
+ p1.data.pos = 0;
|
|
|
+ p2.data.pos = 2;
|
|
|
+ p1.data.teammateId = p2.getId();
|
|
|
+ p2.data.teammateId = p1.getId();
|
|
|
+ // 设置座位
|
|
|
+ this.data.playerMap[0] = p1;
|
|
|
+ this.data.playerMap[2] = p2;
|
|
|
+ }
|
|
|
+ Player p3 = this.actors.getOrDefault(other.get(0), null);
|
|
|
+ Player p4 = this.actors.getOrDefault(other.get(1), null);
|
|
|
+ if (p3 != null && p4 != null) {
|
|
|
+ p3.data.pos = 1;
|
|
|
+ p4.data.pos = 3;
|
|
|
+ p3.data.teammateId = p4.getId();
|
|
|
+ p4.data.teammateId = p3.getId();
|
|
|
+ // 设置座位
|
|
|
+ this.data.playerMap[1] = p3;
|
|
|
+ this.data.playerMap[3] = p4;
|
|
|
+ }
|
|
|
+ this.data.zhuangPos = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 均匀分配
|
|
|
+ if (this.jsonData.getInteger("team") == 2) {
|
|
|
+ // 按局数 并且 局数必须是3的倍数
|
|
|
+ if (this.data.mode != 2 || this.data.maxRound % 3 != 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 保存最后一个玩家
|
|
|
+ Player lastPlayer = this.data.playerMap[this.data.playerMap.length - 1];
|
|
|
+ // 从后向前移动位置
|
|
|
+ for (int i = this.data.playerMap.length - 1; i > 0; i--) {
|
|
|
+ this.data.playerMap[i] = this.data.playerMap[i - 1];
|
|
|
+ }
|
|
|
+ // 将最后一个玩家移动到第一个位置
|
|
|
+ this.data.playerMap[0] = lastPlayer;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -372,13 +433,19 @@ public class ZDRoom extends Room {
|
|
|
this.data.zhuangPos = RandomUtil.getIndex(this.data.maxNum);
|
|
|
// 随机打几
|
|
|
if (this.jsonData.getInteger("tc") == 0) {
|
|
|
- this.data.curLevelIndex = RandomUtil.getIndex(GDUtils.levelPoint.length);
|
|
|
+ this.data.curLevelIndex = RandomUtil.getIndex(GDUtils.randomTeam.length);
|
|
|
+ // 随机队友-系统翻牌
|
|
|
+ this.data.showCard = GDUtils.randomTeam[this.data.curLevelIndex];
|
|
|
}
|
|
|
// 固定打2
|
|
|
if (this.jsonData.getInteger("tc") == 1) {
|
|
|
- this.data.curLevelIndex = 0;
|
|
|
+ this.data.curLevelIndex = 12;
|
|
|
+ // 随机队友-系统翻牌
|
|
|
+ this.data.showCard = GDUtils.randomTeam[this.data.curLevelIndex];
|
|
|
}
|
|
|
- this.data.curLevelPoint = GDUtils.levelPoint[this.data.curLevelIndex];
|
|
|
+ // 级牌下标
|
|
|
+ int index = (this.data.curLevelIndex + 1) % GDUtils.randomTeam.length;
|
|
|
+ this.data.curLevelPoint = (GDUtils.randomTeam[index] & 0xF);
|
|
|
// 发牌
|
|
|
this.doSendCard();
|
|
|
// 进还贡数据
|
|
@@ -1310,7 +1377,7 @@ public class ZDRoom extends Room {
|
|
|
for (Player tmPlayer : this.actors.values()) {
|
|
|
if (tmPlayer != null) {
|
|
|
// 结算信息
|
|
|
- Map<String, Object> data = this.roomToMessage(tmPlayer, this.data.currentPlayer);
|
|
|
+ Map<String, Object> data = this.roomToMessage(tmPlayer, null);
|
|
|
data.put("state", 3);
|
|
|
tmPlayer.receive(CommonProto.Cmd.GameStateChange_VALUE, data);
|
|
|
}
|
|
@@ -1322,47 +1389,6 @@ public class ZDRoom extends Room {
|
|
|
Log.debug("牌局结束...roomId : {}", this.data.roomId);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 变更队友 0固定队友 1随机搭档 2均匀分配
|
|
|
- */
|
|
|
- private synchronized void changeTeam() {
|
|
|
- // 随机搭档
|
|
|
- if (this.jsonData.getInteger("team") == 1) {
|
|
|
- boolean isTransPosition = ((int)(10 * Math.random())) % 2 == 1;
|
|
|
- if (isTransPosition) {
|
|
|
- List<String> keyList = new ArrayList<>(this.actors.keySet());
|
|
|
- Collections.shuffle(keyList);
|
|
|
- int pos = 0;
|
|
|
- for (String id : keyList) {
|
|
|
- if (!StringUtils.isEmpty(id)) {
|
|
|
- Player tmPlayer = this.actors.getOrDefault(id, null);
|
|
|
- if (tmPlayer != null) {
|
|
|
- tmPlayer.data.pos = pos;
|
|
|
- this.data.playerMap[pos] = tmPlayer;
|
|
|
- pos += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 均匀分配
|
|
|
- if (this.jsonData.getInteger("team") == 2) {
|
|
|
- // 按局数 并且 局数必须是3的倍数
|
|
|
- if (this.data.mode != 2 || this.data.maxRound % 3 != 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 保存最后一个玩家
|
|
|
- Player lastPlayer = this.data.playerMap[this.data.playerMap.length - 1];
|
|
|
- // 从后向前移动位置
|
|
|
- for (int i = this.data.playerMap.length - 1; i > 0; i--) {
|
|
|
- this.data.playerMap[i] = this.data.playerMap[i - 1];
|
|
|
- }
|
|
|
- // 将最后一个玩家移动到第一个位置
|
|
|
- this.data.playerMap[0] = lastPlayer;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 下一局重置房间数据
|
|
|
*/
|
|
@@ -1402,8 +1428,6 @@ public class ZDRoom extends Room {
|
|
|
|
|
|
// 初始化牌桌
|
|
|
this.initCardList();
|
|
|
- // 变更队友
|
|
|
- this.changeTeam();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1440,6 +1464,7 @@ public class ZDRoom extends Room {
|
|
|
data.put("curRound", this.data.curRound);
|
|
|
data.put("curTime", this.data.curTime);
|
|
|
data.put("zhuangPos", this.data.zhuangPos);
|
|
|
+ data.put("showCard", this.data.showCard);
|
|
|
// 当前级牌点数
|
|
|
data.put("curLevelPoint", this.data.curLevelPoint);
|
|
|
// 是否有进还贡
|
|
@@ -1492,6 +1517,7 @@ public class ZDRoom extends Room {
|
|
|
data.put("maxRound", this.data.maxRound);
|
|
|
data.put("curRound", this.data.curRound);
|
|
|
data.put("zhuangPos", this.data.zhuangPos);
|
|
|
+ data.put("showCard", this.data.showCard);
|
|
|
// 当前级牌点数
|
|
|
data.put("curLevelPoint", this.data.curLevelPoint);
|
|
|
// 是否有进还贡
|