|
@@ -147,11 +147,15 @@ public class ZDRoom extends Room {
|
|
|
}
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
- // 房间没人直接解散
|
|
|
- if (this.actors.isEmpty()) {
|
|
|
- this.destroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 广播
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
}
|
|
|
}
|
|
|
+ this.destroy();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -266,11 +270,11 @@ public class ZDRoom extends Room {
|
|
|
this.time = 0;
|
|
|
} else {
|
|
|
// 广播
|
|
|
-// for (Player tmPlayer : this.actors.values()) {
|
|
|
-// if (tmPlayer != null) {
|
|
|
-// tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
-// }
|
|
|
-// }
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
this.destroy();
|
|
|
}
|
|
|
break;
|
|
@@ -284,11 +288,11 @@ public class ZDRoom extends Room {
|
|
|
this.time = 0;
|
|
|
} else {
|
|
|
// 广播
|
|
|
-// for (Player tmPlayer : this.actors.values()) {
|
|
|
-// if (tmPlayer != null) {
|
|
|
-// tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
-// }
|
|
|
-// }
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
this.destroy();
|
|
|
}
|
|
|
break;
|
|
@@ -474,6 +478,20 @@ public class ZDRoom extends Room {
|
|
|
tmPlayer.data.pos = i;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 设置队友
|
|
|
+ Player p0 = this.data.playerMap[0];
|
|
|
+ Player p2 = this.data.playerMap[2];
|
|
|
+ if (p0 != null && p2 != null) {
|
|
|
+ p0.data.teammateId = p2.getId();
|
|
|
+ p2.data.teammateId = p0.getId();
|
|
|
+ }
|
|
|
+ Player p1 = this.data.playerMap[1];
|
|
|
+ Player p3 = this.data.playerMap[3];
|
|
|
+ if (p1 != null && p3 != null) {
|
|
|
+ p1.data.teammateId = p3.getId();
|
|
|
+ p3.data.teammateId = p1.getId();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1502,9 +1520,10 @@ public class ZDRoom extends Room {
|
|
|
if (!this.actors.isEmpty()) {
|
|
|
for (Player player : this.actors.values()) {
|
|
|
if (player != null) {
|
|
|
- this.leaveRoom(player);
|
|
|
+ player.resetRoom();
|
|
|
}
|
|
|
}
|
|
|
+ this.actors.clear();
|
|
|
}
|
|
|
|
|
|
Log.debug("清理房间数据...");
|
|
@@ -1556,11 +1575,11 @@ public class ZDRoom extends Room {
|
|
|
data.put("curDiscardSex", this.data.disCardPlayer != null ? this.data.disCardPlayer.data.sex : 0);
|
|
|
data.put("curPassList", this.data.passList);
|
|
|
data.put("roomIp",this.data.roomIp);
|
|
|
- data.put("myInfo", player.playerRoomToMessage(true));
|
|
|
+ data.put("myInfo", this.playerRoomToMessage(player, true));
|
|
|
List<Map<String, Object>> otherInfo = new ArrayList<>();
|
|
|
for (Player tmPlayer : this.actors.values()) {
|
|
|
if (tmPlayer != null && !Objects.equals(tmPlayer.getId(), player.getId())) {
|
|
|
- otherInfo.add(tmPlayer.playerRoomToMessage(false));
|
|
|
+ otherInfo.add(this.playerRoomToMessage(tmPlayer, false));
|
|
|
}
|
|
|
}
|
|
|
data.put("otherInfo", otherInfo);
|
|
@@ -1580,6 +1599,37 @@ public class ZDRoom extends Room {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 玩家信息转消息
|
|
|
+ *
|
|
|
+ * @param flag 是否显示手牌
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> playerRoomToMessage(Player player, boolean flag) {
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("id", player.getId());
|
|
|
+ data.put("name", player.data.name);
|
|
|
+ data.put("avatar", "https://img95.699pic.com/element/40109/0194.png_300.png");
|
|
|
+ data.put("sex", player.data.sex);
|
|
|
+ data.put("pos", player.data.pos);
|
|
|
+ data.put("state", player.data.state);
|
|
|
+ data.put("isAuto", player.data.isAuto);
|
|
|
+ // 转蛋积分-累计
|
|
|
+ data.put("accumulatedPoints", player.data.accumulatedPoints);
|
|
|
+ // 队友Id
|
|
|
+ data.put("teammateId", player.data.teammateId);
|
|
|
+
|
|
|
+ // 玩家牌数据
|
|
|
+ Map<String, Object> cardInfo = new HashMap<>();
|
|
|
+ cardInfo.put("remainCards", flag? player.data.remainCards : "");
|
|
|
+ cardInfo.put("remainCardsNum", player.data.remainCards.length);
|
|
|
+ cardInfo.put("discardList", player.data.discardList);
|
|
|
+ cardInfo.put("disCardType", player.data.disCardType);
|
|
|
+ cardInfo.put("tributeGetCard", player.data.tributeGetCard);
|
|
|
+ data.put("cardInfo", cardInfo);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 房间信息转游戏回放
|
|
|
*
|