|
@@ -42,14 +42,7 @@ namespace ET.Server
|
|
|
self.Difen = 1;
|
|
|
|
|
|
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
- {
|
|
|
- foreach (int value in HGHHConst.Values)
|
|
|
- {
|
|
|
- self.CardList.Add(value);
|
|
|
- }
|
|
|
- RandomGenerator.Shuffle(self.CardList);
|
|
|
- }
|
|
|
+ self.InitCardList();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -87,7 +80,7 @@ namespace ET.Server
|
|
|
{
|
|
|
case 0:
|
|
|
|
|
|
- Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}, 状态:检测是否可开局...");
|
|
|
+ Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}, 当前局数:{self.CurrentRound}, 状态:检测是否可开局...");
|
|
|
if (self.CheckReadyStart(room))
|
|
|
{
|
|
|
self.State = 1;
|
|
@@ -110,7 +103,7 @@ namespace ET.Server
|
|
|
self.Start(room);
|
|
|
self.Flag = true;
|
|
|
self.Time = 0;
|
|
|
- Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}, 状态:开局...VS动画...");
|
|
|
+ Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}, 当前局数:{self.CurrentRound}, 状态:开局...VS动画...");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -172,14 +165,25 @@ namespace ET.Server
|
|
|
{
|
|
|
self.Flag = true;
|
|
|
self.Time = 0;
|
|
|
- Log.Debug($"游戏结束: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}");
|
|
|
+ Log.Debug($"游戏结束: 黄冈晃晃-房间号:{room.RoomId}, 房间人数:{room.Players.Count}, 当前局数:{self.CurrentRound}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- if (self.Time >= 60)
|
|
|
+
|
|
|
+ if (self.CurrentRound < room.MaxRound)
|
|
|
+ {
|
|
|
+ self.ClearRoom();
|
|
|
+ self.State = 0;
|
|
|
+ self.Flag = false;
|
|
|
+ self.Time = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- room.Dispose();
|
|
|
+
|
|
|
+ if (self.Time >= 60)
|
|
|
+ {
|
|
|
+ room.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -189,6 +193,23 @@ namespace ET.Server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static void InitCardList(this HGHHComponent self)
|
|
|
+ {
|
|
|
+
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ foreach (int value in HGHHConst.Values)
|
|
|
+ {
|
|
|
+ self.CardList.Add(value);
|
|
|
+ }
|
|
|
+ RandomGenerator.Shuffle(self.CardList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -288,16 +309,16 @@ namespace ET.Server
|
|
|
self.CardList.RemoveAt(0);
|
|
|
|
|
|
self.DrawCard = card;
|
|
|
- drawCardPlayer.Act = new int[5];
|
|
|
drawCardPlayer.ActInfo.Clear();
|
|
|
|
|
|
+ int[] act = new int[5];
|
|
|
bool hasAct = false;
|
|
|
|
|
|
Struct.HuRes huRes = HGHHHelper.CheckHu(drawCardPlayer.RemainCards);
|
|
|
if (huRes.Type != HGHHConst.HU_DEFAULT)
|
|
|
{
|
|
|
hasAct = true;
|
|
|
- drawCardPlayer.Act[3] = 1;
|
|
|
+ act[3] = 1;
|
|
|
self.CanHuIds.Add(drawCardPlayer.Id);
|
|
|
if (!self.OperableList.Contains(drawCardPlayer.Id))
|
|
|
{
|
|
@@ -306,26 +327,35 @@ namespace ET.Server
|
|
|
}
|
|
|
|
|
|
|
|
|
- List<Struct.Kezi> gang = HGHHHelper.IsDrawGang(drawCardPlayer);
|
|
|
- if (gang is { Count: > 0 })
|
|
|
+ List<Struct.Kezi> gangs = HGHHHelper.IsDrawGang(drawCardPlayer);
|
|
|
+ if (gangs is { Count: > 0 })
|
|
|
{
|
|
|
hasAct = true;
|
|
|
- drawCardPlayer.Act[2] = 1;
|
|
|
- if (!self.OperableList.Contains(drawCardPlayer.Id))
|
|
|
+ act[2] = 1;
|
|
|
+ foreach (Struct.Kezi kezi in gangs.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
{
|
|
|
- self.OperableList.Add(drawCardPlayer.Id);
|
|
|
- }
|
|
|
- if (!self.CanPgIds.Contains(drawCardPlayer.Id))
|
|
|
- {
|
|
|
- self.CanPgIds.Add(drawCardPlayer.Id);
|
|
|
+ drawCardPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- drawCardPlayer.Act[4] = hasAct? 1 : 0;
|
|
|
+ act[4] = hasAct? 1 : 0;
|
|
|
if (drawCardPlayer.HuCards.Any(_card => _card > 0 && _card == self.DrawCard))
|
|
|
{
|
|
|
- drawCardPlayer.Act[4] = 0;
|
|
|
+ act[4] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (act[2] == 1 || act[1] == 1 || act[0] == 1) {
|
|
|
+
|
|
|
+ if (!self.OperableList.Contains(drawCardPlayer.Id)) {
|
|
|
+ self.OperableList.Add(drawCardPlayer.Id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!self.CanPgIds.Contains(drawCardPlayer.Id)) {
|
|
|
+ self.CanPgIds.Add(drawCardPlayer.Id);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ drawCardPlayer.Act = act;
|
|
|
|
|
|
|
|
|
self.CurrentPlayer = drawCardPlayer;
|
|
@@ -338,7 +368,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player player in room.GetAllPlayers().Values.Where(player => player != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, player, drawCardPlayer);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, player, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(player, new G2C_HGHHDrawCardPush(){info = info});
|
|
|
}
|
|
@@ -555,13 +585,15 @@ namespace ET.Server
|
|
|
Player tmpPlayer = room.GetPlayer(id);
|
|
|
if (tmpPlayer != null)
|
|
|
{
|
|
|
- self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
+
|
|
|
+ self.CurrentPlayer = tmpPlayer;
|
|
|
+
|
|
|
+ self.Flag = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- self.Time = 0;
|
|
|
- self.Flag = false;
|
|
|
+ self.Time = 30;
|
|
|
|
|
|
|
|
|
RoomInfo info = ProtoHelper.RoomToProto(room, player, self.CurrentPlayer);
|
|
@@ -664,6 +696,7 @@ namespace ET.Server
|
|
|
|
|
|
|
|
|
self.DrawCardPlayer = player;
|
|
|
+ self.CurrentPlayer = player;
|
|
|
self.PengPlayer = player;
|
|
|
|
|
|
self.OperableList.Clear();
|
|
@@ -677,7 +710,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.CHI});
|
|
|
}
|
|
@@ -745,6 +778,7 @@ namespace ET.Server
|
|
|
|
|
|
|
|
|
self.DrawCardPlayer = player;
|
|
|
+ self.CurrentPlayer = player;
|
|
|
self.PengPlayer = player;
|
|
|
|
|
|
self.OperableList.Clear();
|
|
@@ -758,7 +792,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.PENG});
|
|
|
}
|
|
@@ -940,7 +974,7 @@ namespace ET.Server
|
|
|
Player tmpPlayer = room.GetPlayer(self.CanHuIds.First());
|
|
|
if (tmpPlayer != null)
|
|
|
{
|
|
|
- self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
+ self.CurrentPlayer = tmpPlayer;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -950,7 +984,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.GANG});
|
|
|
}
|
|
@@ -969,9 +1003,14 @@ namespace ET.Server
|
|
|
Struct.HuRes res = HGHHHelper.CheckHuType(player.KeZi, player.RemainCards, self.DrawCard);
|
|
|
if (res.Type != HGHHConst.HU_DEFAULT)
|
|
|
{
|
|
|
+ if (!self.ClickHuIds.Contains(player.Id))
|
|
|
+ {
|
|
|
+ self.ClickHuIds.Add(player.Id);
|
|
|
+ }
|
|
|
+
|
|
|
self.OperableList.Remove(player.Id);
|
|
|
self.CanHuIds.Remove(player.Id);
|
|
|
- self.ClickHuIds.Remove(player.Id);
|
|
|
+
|
|
|
|
|
|
player.RemainCards = CardHelper.Remove(player.RemainCards, self.DrawCard);
|
|
|
|
|
@@ -980,7 +1019,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.HU});
|
|
|
}
|
|
@@ -1040,7 +1079,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.HU});
|
|
|
}
|
|
@@ -1172,7 +1211,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.GUO});
|
|
|
}
|
|
@@ -1230,7 +1269,7 @@ namespace ET.Server
|
|
|
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, self.CurrentPlayer);
|
|
|
info.Time = 30;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = (int)OperationType.GUO});
|
|
|
}
|
|
@@ -1339,7 +1378,8 @@ namespace ET.Server
|
|
|
}
|
|
|
break;
|
|
|
case (int)HGHHConst.Result.ZIMO:
|
|
|
- if (self.ClickHuIds.Count > 0 && self.OperableList.Count <= 0)
|
|
|
+ if (self.ClickHuIds.Count > 0)
|
|
|
+
|
|
|
{
|
|
|
Player winPlayer = room.GetAllPlayers()[self.ClickHuIds.First()];
|
|
|
if (winPlayer != null)
|
|
@@ -1550,5 +1590,40 @@ namespace ET.Server
|
|
|
}
|
|
|
Log.Info($"牌局结束...roomId={room.RoomId}");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static void ClearRoom(this HGHHComponent self)
|
|
|
+ {
|
|
|
+ foreach (Player player in self.Players)
|
|
|
+ {
|
|
|
+ player.State = 0;
|
|
|
+ player.RemainCards = Array.Empty<int>();
|
|
|
+ player.DisCards = Array.Empty<int>();
|
|
|
+ player.KeZi.Clear();
|
|
|
+ player.Act = new int[5];;
|
|
|
+ player.ActInfo.Clear();
|
|
|
+ player.HuCards.Clear();
|
|
|
+ }
|
|
|
+ Log.Debug($"清理玩家数据...");
|
|
|
+
|
|
|
+ self.ZhuangPos = 0;
|
|
|
+ self.GangType = -1;
|
|
|
+ self.AdmitDefeatList.Clear();
|
|
|
+ self.CanPgIds.Clear();
|
|
|
+ self.GangHuIds.Clear();
|
|
|
+ self.CanHuIds.Clear();
|
|
|
+ self.OperableList.Clear();
|
|
|
+ self.ClickHuIds.Clear();
|
|
|
+ self.HuResult = -1;
|
|
|
+ self.CardList.Clear();
|
|
|
+ self.UpdateTime = 0;
|
|
|
+ Log.Debug($"清理桌子数据...");
|
|
|
+
|
|
|
+
|
|
|
+ self.InitCardList();
|
|
|
+ }
|
|
|
}
|
|
|
}
|