|
@@ -29,8 +29,8 @@ namespace ET.Server
|
|
|
self.Rand = new[] { 0, 0 };
|
|
|
self.GangType = -1;
|
|
|
self.AdmitDefeatList = new List<long>();
|
|
|
- self.CanHuIds = new List<Player>();
|
|
|
- self.CanPgIds = new List<Player>();
|
|
|
+ self.CanPgIds = new List<long>();
|
|
|
+ self.CanHuIds = new List<long>();
|
|
|
self.OperableList = new List<long>();
|
|
|
self.ClickHuIds = new List<Player>();
|
|
|
self.CardList = new List<int>();
|
|
@@ -263,7 +263,7 @@ namespace ET.Server
|
|
|
{
|
|
|
hasAct = true;
|
|
|
drawCardPlayer.Act[3] = 1;
|
|
|
- self.CanHuIds.Add(drawCardPlayer);
|
|
|
+ self.CanHuIds.Add(drawCardPlayer.Id);
|
|
|
if (!self.OperableList.Contains(drawCardPlayer.Id))
|
|
|
{
|
|
|
self.OperableList.Add(drawCardPlayer.Id);
|
|
@@ -280,9 +280,9 @@ namespace ET.Server
|
|
|
{
|
|
|
self.OperableList.Add(drawCardPlayer.Id);
|
|
|
}
|
|
|
- if (!self.CanPgIds.Contains(drawCardPlayer))
|
|
|
+ if (!self.CanPgIds.Contains(drawCardPlayer.Id))
|
|
|
{
|
|
|
- self.CanPgIds.Add(drawCardPlayer);
|
|
|
+ self.CanPgIds.Add(drawCardPlayer.Id);
|
|
|
}
|
|
|
}
|
|
|
// 过牌
|
|
@@ -401,9 +401,9 @@ namespace ET.Server
|
|
|
hasAct = true;
|
|
|
act[3] = 1;
|
|
|
// 放入可胡玩家列表
|
|
|
- if (!self.CanHuIds.Contains(otherPlayer))
|
|
|
+ if (!self.CanHuIds.Contains(otherPlayer.Id))
|
|
|
{
|
|
|
- self.CanHuIds.Add(otherPlayer);
|
|
|
+ self.CanHuIds.Add(otherPlayer.Id);
|
|
|
}
|
|
|
// 加入可操作玩家list
|
|
|
if (!self.OperableList.Contains(otherPlayer.Id))
|
|
@@ -439,8 +439,8 @@ namespace ET.Server
|
|
|
self.OperableList.Add(otherPlayer.Id);
|
|
|
}
|
|
|
// 加入可碰杠玩家集合
|
|
|
- if (!self.CanPgIds.Contains(otherPlayer)) {
|
|
|
- self.CanPgIds.Add(otherPlayer);
|
|
|
+ if (!self.CanPgIds.Contains(otherPlayer.Id)) {
|
|
|
+ self.CanPgIds.Add(otherPlayer.Id);
|
|
|
}
|
|
|
}
|
|
|
// 设置玩家动作
|
|
@@ -486,21 +486,24 @@ namespace ET.Server
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ long id = 0;
|
|
|
+
|
|
|
if (self.CanHuIds.Count > 0)
|
|
|
{
|
|
|
- self.CurrentPlayer = self.Players[self.CanHuIds.First().Pos];
|
|
|
+ id = self.CanHuIds.First();
|
|
|
} else if (self.CanPgIds.Count > 0)
|
|
|
{
|
|
|
- self.CurrentPlayer = self.Players[self.CanPgIds.First().Pos];
|
|
|
+ id = self.CanPgIds.First();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- long id = self.OperableList.First();
|
|
|
- Player tmpPlayer = room.GetPlayer(id);
|
|
|
- if (tmpPlayer != null)
|
|
|
- {
|
|
|
- self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
- }
|
|
|
+ id = self.OperableList.First();
|
|
|
+ }
|
|
|
+
|
|
|
+ Player tmpPlayer = room.GetPlayer(id);
|
|
|
+ if (tmpPlayer != null)
|
|
|
+ {
|
|
|
+ self.CurrentPlayer = self.Players[tmpPlayer.Pos];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -530,19 +533,19 @@ namespace ET.Server
|
|
|
{
|
|
|
if (self.CanPgIds.Count > 0)
|
|
|
{
|
|
|
- if (self.CanPgIds.Any(p => p != null && p.Id != player.Id))
|
|
|
+ if (self.CanPgIds.Any(id => id > 0 && id != player.Id))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return self.CanHuIds.Contains(player);
|
|
|
+ return self.CanHuIds.Contains(player.Id);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (self.CanPgIds.Count > 0)
|
|
|
{
|
|
|
- return self.CanPgIds.Contains(player);
|
|
|
+ return self.CanPgIds.Contains(player.Id);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -584,11 +587,12 @@ namespace ET.Server
|
|
|
// 刻子
|
|
|
player.KeZi.Add(new Struct.Kezi((int)HGHuangHuangConst.KeziType.CHI, card, self.DisCardPlayer.Id));
|
|
|
|
|
|
- self.OperableList.Clear();
|
|
|
// 重置摸牌人
|
|
|
self.DrawCardPlayer = player;
|
|
|
self.PengPlayer = player;
|
|
|
|
|
|
+ self.OperableList.Clear();
|
|
|
+
|
|
|
// 重置时间和流程标记
|
|
|
self.Time = 15;
|
|
|
self.Flag = false;
|
|
@@ -598,19 +602,87 @@ namespace ET.Server
|
|
|
// 广播
|
|
|
foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- MessageHelper.SendToClient(p, new G2C_DrawCardPush(){info = ProtoHelper.RoomToProto(room, p, p)});
|
|
|
+ MessageHelper.SendToClient(p, new G2C_OperationPush(){info = ProtoHelper.RoomToProto(room, p, p)});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 玩家是否可以操作碰
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="player"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static bool IsCanPengGang(this HGHuangHuangComponent self, Player player)
|
|
|
+ {
|
|
|
+ if (!self.CanPgIds.Contains(player.Id))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.ClickHuIds.Count > 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return self.CanHuIds.Count switch
|
|
|
+ {
|
|
|
+ > 1 => false,
|
|
|
+ 1 => self.CanHuIds.Contains(player.Id),
|
|
|
+ _ => true
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 玩家操作碰
|
|
|
/// </summary>
|
|
|
/// <param name="self"></param>
|
|
|
/// <param name="room"></param>
|
|
|
/// <param name="player"></param>
|
|
|
- public static void Peng(this HGHuangHuangComponent self, Room room, Player player)
|
|
|
+ public static void Peng(this HGHuangHuangComponent self, Room room, Player player)
|
|
|
{
|
|
|
+ if (!self.IsCanPengGang(player))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ int num = CardHelper.CountCardNum(player.RemainCards, self.DisCard);
|
|
|
+ if (num < 2)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除出牌人打出的牌堆
|
|
|
+ int[] temp = CardHelper.Remove(self.DisCardPlayer.DisCards, self.DisCard);
|
|
|
+ self.DisCardPlayer.DisCards = temp;
|
|
|
+
|
|
|
+ // 碰牌玩家的手牌
|
|
|
+ int[] remainCards = player.RemainCards;
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ remainCards = CardHelper.Remove(remainCards, self.DisCard);
|
|
|
+ }
|
|
|
+ player.RemainCards = remainCards;
|
|
|
+
|
|
|
+ // 刻子
|
|
|
+ player.KeZi.Add(new Struct.Kezi((int)HGHuangHuangConst.KeziType.PENG, self.DisCard, self.DisCardPlayer.Id));
|
|
|
+
|
|
|
+ // 重置摸牌人
|
|
|
+ self.DrawCardPlayer = player;
|
|
|
+ self.PengPlayer = player;
|
|
|
+
|
|
|
+ self.OperableList.Clear();
|
|
|
+
|
|
|
+ // 重置时间和流程标记
|
|
|
+ self.Time = 15;
|
|
|
+ self.Flag = false;
|
|
|
+
|
|
|
+ Log.Info($"玩家碰牌... 玩家ID:{player.Id}, 位置:{player.Pos}, 手牌大小:{player.RemainCards.Length}, 手牌信息:{string.Join(", ", player.RemainCards)}, 碰的牌:{self.DisCard}");
|
|
|
+
|
|
|
+ // 广播
|
|
|
+ foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
+ {
|
|
|
+ MessageHelper.SendToClient(p, new G2C_OperationPush(){info = ProtoHelper.RoomToProto(room, p, player)});
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|