|
@@ -32,9 +32,30 @@ public class ZDRoom extends Room {
|
|
|
this.data.type = jsonData.getInteger("type");
|
|
|
this.data.gameType = jsonData.getInteger("gameType");
|
|
|
this.data.ownerId = player != null? player.getId() : "";
|
|
|
- this.data.maxNum = jsonData.getInteger("playerNum");
|
|
|
- this.data.maxRound = jsonData.getInteger("maxRound");
|
|
|
- this.data.playerMap = new Player[4];
|
|
|
+ this.data.maxNum = 4;
|
|
|
+
|
|
|
+ this.data.mode = jsonData.getInteger("mode");
|
|
|
+ this.data.modev = jsonData.getInteger("modev");
|
|
|
+
|
|
|
+ // 连续打
|
|
|
+ if (this.data.mode == 1) {
|
|
|
+ this.data.maxRound = 9999;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按局数
|
|
|
+ if (this.data.mode == 2) {
|
|
|
+ this.data.maxRound = jsonData.getInteger("modev");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按时间
|
|
|
+ if (this.data.mode == 3) {
|
|
|
+ this.data.curTime = System.currentTimeMillis();
|
|
|
+ long time = jsonData.getInteger("modev") * 60L * 1000L;
|
|
|
+ this.data.maxTime = this.data.curTime + time;
|
|
|
+ this.data.maxRound = 9999;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.data.playerMap = new Player[this.data.maxNum];
|
|
|
// 是否有进还贡规则
|
|
|
this.data.isTribute = false;
|
|
|
// 初始化级牌点数
|
|
@@ -218,23 +239,62 @@ public class ZDRoom extends Room {
|
|
|
this.time = 0;
|
|
|
Log.debug("游戏结束: 房间号 : {}, 房间人数 : {}, 当前局数 : {}", this.data.roomId, this.actors.size(), this.data.curRound);
|
|
|
} else {
|
|
|
- // 小于最大局数,切等待状态
|
|
|
- if (this.data.curRound < this.data.maxRound) {
|
|
|
- this.resetNextRoom();
|
|
|
- this.state = 0;
|
|
|
- this.flag = false;
|
|
|
- this.time = 0;
|
|
|
- } else {
|
|
|
- // 120秒未开始直接解散
|
|
|
-// if (this.time >= 120 && this.type != 1) {
|
|
|
-// // 广播
|
|
|
-// for (Player tmPlayer : this.actors.values()) {
|
|
|
-// if (tmPlayer != null) {
|
|
|
-// tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// this.destroy();
|
|
|
-// }
|
|
|
+ // 根据类型判断结束走向
|
|
|
+ switch (this.data.mode) {
|
|
|
+ case 1:
|
|
|
+ // 连续打
|
|
|
+ this.resetNextRoom();
|
|
|
+ this.state = 0;
|
|
|
+ this.flag = false;
|
|
|
+ this.time = 0;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ // 按局数
|
|
|
+ // 小于最大局数,切等待状态
|
|
|
+ if (this.data.curRound < this.data.maxRound) {
|
|
|
+ this.resetNextRoom();
|
|
|
+ this.state = 0;
|
|
|
+ this.flag = false;
|
|
|
+ this.time = 0;
|
|
|
+ } else {
|
|
|
+ // 广播
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.destroy();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ // 按时间
|
|
|
+ // 小于最大时间,切等待状态
|
|
|
+ if (System.currentTimeMillis() < this.data.maxTime) {
|
|
|
+ this.resetNextRoom();
|
|
|
+ this.state = 0;
|
|
|
+ this.flag = false;
|
|
|
+ this.time = 0;
|
|
|
+ } else {
|
|
|
+ // 广播
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.destroy();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 120秒未开始直接解散
|
|
|
+ if (this.time >= 120) {
|
|
|
+ // 广播
|
|
|
+ for (Player tmPlayer : this.actors.values()) {
|
|
|
+ if (tmPlayer != null) {
|
|
|
+ tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.destroy();
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1230,8 +1290,13 @@ public class ZDRoom extends Room {
|
|
|
data.put("state", this.state);
|
|
|
data.put("time", this.time);
|
|
|
|
|
|
+ data.put("mode", this.data.mode);
|
|
|
+ data.put("modev", this.data.modev);
|
|
|
data.put("maxRound", this.data.maxRound);
|
|
|
+ data.put("maxTime", this.data.maxTime);
|
|
|
+
|
|
|
data.put("curRound", this.data.curRound);
|
|
|
+ data.put("curTime", this.data.curTime);
|
|
|
data.put("zhuangPos", this.data.zhuangPos);
|
|
|
// 当前级牌点数
|
|
|
data.put("curLevelPoint", this.data.curLevelPoint);
|