|
@@ -327,6 +327,9 @@ namespace ET.Server
|
|
|
|
|
|
// 设置当前操作玩家
|
|
|
self.CurrentPlayer = drawCardPlayer;
|
|
|
+ // 重置时间和流程标记
|
|
|
+ self.Time = 30;
|
|
|
+ self.Flag = true;
|
|
|
|
|
|
Log.Info($"摸牌... 玩家ID:{drawCardPlayer.Id}, 位置:{drawCardPlayer.Pos}, 手牌大小:{drawCardPlayer.RemainCards.Length}, 手牌信息:{string.Join(", ", drawCardPlayer.RemainCards)}, 摸的牌:{card}");
|
|
|
|
|
@@ -405,100 +408,99 @@ namespace ET.Server
|
|
|
foreach (int index in nextPos)
|
|
|
{
|
|
|
Player otherPlayer = self.Players[index];
|
|
|
- if (otherPlayer != null)
|
|
|
+ if (otherPlayer is not { State: 2 })
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 吃,碰,杠,胡,过
|
|
|
+ int[] act = new int[5];
|
|
|
+ List<Struct.Kezi> gangs = new List<Struct.Kezi>();
|
|
|
+ List<Struct.Kezi> pengs = new List<Struct.Kezi>();
|
|
|
+ List<Struct.Kezi> chis = new List<Struct.Kezi>();
|
|
|
+ // todo 玩家听牌状态不允许有动作
|
|
|
+ // 出牌是否杠
|
|
|
+ gangs = HGHHHelper.IsDiscardGang(otherPlayer, card, player.Id);
|
|
|
+ // 出牌是否碰
|
|
|
+ pengs = HGHHHelper.IsDiscardPeng(otherPlayer, card, player.Id);
|
|
|
+ // 出牌是否吃
|
|
|
+ if (otherPlayer.Pos == nextPos[0])
|
|
|
+ {
|
|
|
+ chis = HGHHHelper.IsDiscardChi(otherPlayer, card, player.Id);
|
|
|
+ }
|
|
|
+
|
|
|
+ bool hasAct = false;
|
|
|
+
|
|
|
+ int[] tmpCards = new int[otherPlayer.RemainCards.Length];
|
|
|
+ Array.Copy(otherPlayer.RemainCards, 0, tmpCards, 0, otherPlayer.RemainCards.Length);
|
|
|
+ tmpCards = CardHelper.Add(tmpCards, card);
|
|
|
+ // 校验胡牌
|
|
|
+ Struct.HuRes huType = HGHHHelper.CheckHu(tmpCards);
|
|
|
+
|
|
|
+ if (huType.Type != HGHHConst.HU_DEFAULT)
|
|
|
{
|
|
|
- // 吃,碰,杠,胡,过
|
|
|
- int[] act = new int[5];
|
|
|
- List<Struct.Kezi> gangs = new List<Struct.Kezi>();
|
|
|
- List<Struct.Kezi> pengs = new List<Struct.Kezi>();
|
|
|
- List<Struct.Kezi> chis = new List<Struct.Kezi>();
|
|
|
- // todo 玩家听牌状态不允许有动作
|
|
|
- // 出牌是否杠
|
|
|
- gangs = HGHHHelper.IsDiscardGang(otherPlayer, card, player.Id);
|
|
|
- // 出牌是否碰
|
|
|
- pengs = HGHHHelper.IsDiscardPeng(otherPlayer, card, player.Id);
|
|
|
- // 出牌是否吃
|
|
|
- if (otherPlayer.Pos == nextPos[0])
|
|
|
+ hasAct = true;
|
|
|
+ act[3] = 1;
|
|
|
+ // 放入可胡玩家列表
|
|
|
+ if (!self.CanHuIds.Contains(otherPlayer.Id))
|
|
|
{
|
|
|
- chis = HGHHHelper.IsDiscardChi(otherPlayer, card, player.Id);
|
|
|
+ self.CanHuIds.Add(otherPlayer.Id);
|
|
|
}
|
|
|
- // 游戏中才会动作
|
|
|
- if (otherPlayer.State == 2)
|
|
|
+ // 加入可操作玩家list
|
|
|
+ if (!self.OperableList.Contains(otherPlayer.Id))
|
|
|
{
|
|
|
- bool hasAct = false;
|
|
|
-
|
|
|
- int[] tmpCards = new int[otherPlayer.RemainCards.Length];
|
|
|
- Array.Copy(otherPlayer.RemainCards, 0, tmpCards, 0, otherPlayer.RemainCards.Length);
|
|
|
- tmpCards = CardHelper.Add(tmpCards, card);
|
|
|
- // 校验胡牌
|
|
|
- Struct.HuRes huType = HGHHHelper.CheckHu(tmpCards);
|
|
|
-
|
|
|
- if (huType.Type != HGHHConst.HU_DEFAULT)
|
|
|
- {
|
|
|
- hasAct = true;
|
|
|
- act[3] = 1;
|
|
|
- // 放入可胡玩家列表
|
|
|
- if (!self.CanHuIds.Contains(otherPlayer.Id))
|
|
|
- {
|
|
|
- self.CanHuIds.Add(otherPlayer.Id);
|
|
|
- }
|
|
|
- // 加入可操作玩家list
|
|
|
- if (!self.OperableList.Contains(otherPlayer.Id))
|
|
|
- {
|
|
|
- self.OperableList.Add(otherPlayer.Id);
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否杠
|
|
|
- if (gangs.Count > 0)
|
|
|
- {
|
|
|
- hasAct = true;
|
|
|
- act[2] = 1;
|
|
|
- foreach (Struct.Kezi kezi in gangs.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
- {
|
|
|
- otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否碰
|
|
|
- if (pengs.Count > 0)
|
|
|
- {
|
|
|
- hasAct = true;
|
|
|
- act[1] = 1;
|
|
|
- foreach (Struct.Kezi kezi in pengs.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
- {
|
|
|
- otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否吃
|
|
|
- if (chis.Count > 0)
|
|
|
- {
|
|
|
- hasAct = true;
|
|
|
- act[0] = 1;
|
|
|
- foreach (Struct.Kezi kezi in chis.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
- {
|
|
|
- otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否过
|
|
|
- if (hasAct) {
|
|
|
- act[4] = 1;
|
|
|
- }
|
|
|
- if (act[2] == 1 || act[1] == 1 || act[0] == 1) {
|
|
|
- // 加入可操作玩家list
|
|
|
- if (!self.OperableList.Contains(otherPlayer.Id)) {
|
|
|
- self.OperableList.Add(otherPlayer.Id);
|
|
|
- }
|
|
|
- // 加入可碰杠玩家集合
|
|
|
- if (!self.CanPgIds.Contains(otherPlayer.Id)) {
|
|
|
- self.CanPgIds.Add(otherPlayer.Id);
|
|
|
- }
|
|
|
- }
|
|
|
- // 设置玩家动作
|
|
|
- otherPlayer.Act = act;
|
|
|
+ self.OperableList.Add(otherPlayer.Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 是否杠
|
|
|
+ if (gangs.Count > 0)
|
|
|
+ {
|
|
|
+ hasAct = true;
|
|
|
+ act[2] = 1;
|
|
|
+ foreach (Struct.Kezi kezi in gangs.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
+ {
|
|
|
+ otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 是否碰
|
|
|
+ if (pengs.Count > 0)
|
|
|
+ {
|
|
|
+ hasAct = true;
|
|
|
+ act[1] = 1;
|
|
|
+ foreach (Struct.Kezi kezi in pengs.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
+ {
|
|
|
+ otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 是否吃
|
|
|
+ if (chis.Count > 0)
|
|
|
+ {
|
|
|
+ hasAct = true;
|
|
|
+ act[0] = 1;
|
|
|
+ foreach (Struct.Kezi kezi in chis.Where(kezi => kezi is { Card: >= 0 }))
|
|
|
+ {
|
|
|
+ otherPlayer.ActInfo.Add(new Struct.Kezi(kezi.Type, kezi.Card, kezi.PlayerId));
|
|
|
}
|
|
|
-
|
|
|
- // // 广播其它三家
|
|
|
- // MessageHelper.SendToClient(otherPlayer, new G2C_HGHHDisCardPush(){info = ProtoHelper.RoomToProto(room, otherPlayer, player)});
|
|
|
}
|
|
|
+ // 是否过
|
|
|
+ if (hasAct) {
|
|
|
+ act[4] = 1;
|
|
|
+ }
|
|
|
+ if (act[2] == 1 || act[1] == 1 || act[0] == 1) {
|
|
|
+ // 加入可操作玩家list
|
|
|
+ if (!self.OperableList.Contains(otherPlayer.Id)) {
|
|
|
+ self.OperableList.Add(otherPlayer.Id);
|
|
|
+ }
|
|
|
+ // 加入可碰杠玩家集合
|
|
|
+ if (!self.CanPgIds.Contains(otherPlayer.Id)) {
|
|
|
+ self.CanPgIds.Add(otherPlayer.Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 设置玩家动作
|
|
|
+ otherPlayer.Act = act;
|
|
|
+
|
|
|
+ // // 广播其它三家
|
|
|
+ // MessageHelper.SendToClient(otherPlayer, new G2C_HGHHDisCardPush(){info = ProtoHelper.RoomToProto(room, otherPlayer, player)});
|
|
|
}
|
|
|
|
|
|
if (self.CanHuIds.Count <= 0)
|
|
@@ -556,6 +558,10 @@ namespace ET.Server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 重置时间和流程标记
|
|
|
+ self.Time = 30;
|
|
|
+ self.Flag = false;
|
|
|
+
|
|
|
// 给出牌人广播
|
|
|
MessageHelper.SendToClient(player, new G2C_HGHHDisCardPush(){info = ProtoHelper.RoomToProto(room, player, self.CurrentPlayer)});
|
|
|
// 给其他三家广播
|
|
@@ -657,7 +663,7 @@ namespace ET.Server
|
|
|
|
|
|
// 重置时间和流程标记
|
|
|
self.Time = 30;
|
|
|
- self.Flag = false;
|
|
|
+ self.Flag = true;
|
|
|
|
|
|
Log.Info($"玩家吃牌... 玩家ID:{player.Id}, 位置:{player.Pos}, 手牌大小:{player.RemainCards.Length}, 手牌信息:{string.Join(", ", player.RemainCards)}, 吃的牌:{card}");
|
|
|
|
|
@@ -665,7 +671,6 @@ namespace ET.Server
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
- info.Time = 15;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 1});
|
|
|
}
|
|
|
}
|
|
@@ -736,9 +741,9 @@ namespace ET.Server
|
|
|
|
|
|
self.OperableList.Clear();
|
|
|
|
|
|
- // 重置时间和流程标记
|
|
|
- self.Time = 15;
|
|
|
- self.Flag = false;
|
|
|
+ // 重置时间和摸牌标记
|
|
|
+ self.Time = 30;
|
|
|
+ self.Flag = true;
|
|
|
|
|
|
Log.Info($"玩家碰牌... 玩家ID:{player.Id}, 位置:{player.Pos}, 手牌大小:{player.RemainCards.Length}, 手牌信息:{string.Join(", ", player.RemainCards)}, 碰的牌:{self.DisCard}");
|
|
|
|
|
@@ -746,7 +751,6 @@ namespace ET.Server
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
- info.Time = 15;
|
|
|
MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 2});
|
|
|
}
|
|
|
}
|
|
@@ -863,19 +867,22 @@ namespace ET.Server
|
|
|
Array.Copy(p.RemainCards, 0, tmpCards, 0, p.RemainCards.Length);
|
|
|
tmpCards = CardHelper.Add(tmpCards, card);
|
|
|
Struct.HuRes result = HGHHHelper.CheckHu(tmpCards);
|
|
|
- if (result.Type != HGHHConst.HU_DEFAULT) {
|
|
|
- flag = true;
|
|
|
- if (!self.CanHuIds.Contains(p.Id)) {
|
|
|
- self.CanHuIds.Add(p.Id);
|
|
|
- }
|
|
|
- if (!self.OperableList.Contains(p.Id)) {
|
|
|
- self.OperableList.Add(p.Id);
|
|
|
- }
|
|
|
- if (!self.GangHuIds.Contains(p.Id)) {
|
|
|
- self.GangHuIds.Add(p.Id);
|
|
|
- }
|
|
|
- p.Act = new [] { 0, 0, 0, 1, 1 };
|
|
|
+ if (result.Type == HGHHConst.HU_DEFAULT)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ flag = true;
|
|
|
+ if (!self.CanHuIds.Contains(p.Id)) {
|
|
|
+ self.CanHuIds.Add(p.Id);
|
|
|
}
|
|
|
+ if (!self.OperableList.Contains(p.Id)) {
|
|
|
+ self.OperableList.Add(p.Id);
|
|
|
+ }
|
|
|
+ if (!self.GangHuIds.Contains(p.Id)) {
|
|
|
+ self.GangHuIds.Add(p.Id);
|
|
|
+ }
|
|
|
+ p.Act = new [] { 0, 0, 0, 1, 1 };
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
@@ -889,48 +896,54 @@ namespace ET.Server
|
|
|
/// <param name="card"></param>
|
|
|
public static void Gang(this HGHHComponent self, Room room, Player player, int card)
|
|
|
{
|
|
|
- if (card > 0 && self.IsCanPengGang(player))
|
|
|
+ if (card <= 0 || !self.IsCanPengGang(player))
|
|
|
{
|
|
|
- int type = (int)HGHHConst.KeziType.DEFAULT;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int type = (int)HGHHConst.KeziType.DEFAULT;
|
|
|
|
|
|
- if (self.DrawCardPlayer.Id == player.Id)
|
|
|
- {
|
|
|
- type = self.GangPaiDraw(room, player, card);
|
|
|
- }
|
|
|
- else if (self.DrawCardPlayer.Id != player.Id && self.DisCard == card)
|
|
|
- {
|
|
|
- type = self.GangPaiDisCard(room, player, card);
|
|
|
- }
|
|
|
+ if (self.DrawCardPlayer.Id == player.Id)
|
|
|
+ {
|
|
|
+ type = self.GangPaiDraw(room, player, card);
|
|
|
+ }
|
|
|
+ else if (self.DrawCardPlayer.Id != player.Id && self.DisCard == card)
|
|
|
+ {
|
|
|
+ type = self.GangPaiDisCard(room, player, card);
|
|
|
+ }
|
|
|
|
|
|
- if (type != (int)HGHHConst.KeziType.DEFAULT)
|
|
|
- {
|
|
|
- self.OperableList.Clear();
|
|
|
- // bool flag = true;
|
|
|
- if (self.GangType == (int)HGHHConst.KeziType.HUI_GANG)
|
|
|
- {
|
|
|
- if (self.CheckQangGangHu(room, self.GangPlayer, self.GangPai))
|
|
|
- {
|
|
|
- // 当前操作玩家
|
|
|
- Player tmpPlayer = room.GetPlayer(self.CanHuIds.First());
|
|
|
- if (tmpPlayer != null)
|
|
|
- {
|
|
|
- self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
- }
|
|
|
+ if (type == (int)HGHHConst.KeziType.DEFAULT)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- self.Time = 15;
|
|
|
- // flag = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 广播
|
|
|
- foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
+ self.OperableList.Clear();
|
|
|
+ // 重置时间和摸牌标记
|
|
|
+ self.Time = 30;
|
|
|
+ self.Flag = false;
|
|
|
+
|
|
|
+ // bool flag = true;
|
|
|
+ if (self.GangType == (int)HGHHConst.KeziType.HUI_GANG)
|
|
|
+ {
|
|
|
+ if (self.CheckQangGangHu(room, self.GangPlayer, self.GangPai))
|
|
|
+ {
|
|
|
+ // 当前操作玩家
|
|
|
+ Player tmpPlayer = room.GetPlayer(self.CanHuIds.First());
|
|
|
+ if (tmpPlayer != null)
|
|
|
{
|
|
|
- RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
- info.Time = 15;
|
|
|
- MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 3});
|
|
|
+ self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
}
|
|
|
+
|
|
|
+ // flag = false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 广播
|
|
|
+ foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
+ {
|
|
|
+ RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
|
|
|
+ MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 3});
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|