Kaynağa Gözat

优化麻将自动操作等待时间和推送给客户端的等待倒计时时间

johnclot69 1 ay önce
ebeveyn
işleme
2c85db0a17

+ 1 - 1
DotNet/Hotfix/Helper/ProtoHelper.cs

@@ -43,7 +43,7 @@ namespace ET.Server
             if (hghhComponent != null)
             {
                 info.State = hghhComponent.State;
-                info.Time = hghhComponent.Time;
+                // info.Time = hghhComponent.Time;
                 info.Rand1 = hghhComponent.Rand[0];
                 info.Rand2 = hghhComponent.Rand[1];
                 info.CardNum = hghhComponent.CardList.Count;

+ 67 - 54
DotNet/Hotfix/Scenes/Game/Room/HGHHComponentSystem.cs

@@ -328,7 +328,7 @@ namespace ET.Server
             // 设置当前操作玩家
             self.CurrentPlayer = drawCardPlayer;
             // 重置时间和流程标记
-            self.Time = 30;
+            self.Time = 0;
             self.Flag = true;
             
             Log.Info($"摸牌... 玩家ID:{drawCardPlayer.Id}, 位置:{drawCardPlayer.Pos}, 手牌大小:{drawCardPlayer.RemainCards.Length}, 手牌信息:{string.Join(", ", drawCardPlayer.RemainCards)}, 摸的牌:{card}");
@@ -336,7 +336,9 @@ namespace ET.Server
             // 推送摸牌广播
             foreach (Player player in room.GetAllPlayers().Values.Where(player => player != null))
             {
-                MessageHelper.SendToClient(player, new G2C_HGHHDrawCardPush(){info = ProtoHelper.RoomToProto(room, player, drawCardPlayer)});
+                RoomInfo info = ProtoHelper.RoomToProto(room, player, drawCardPlayer);
+                info.Time = 30;
+                MessageHelper.SendToClient(player, new G2C_HGHHDrawCardPush(){info = info});
             }
         }
 
@@ -559,20 +561,27 @@ namespace ET.Server
                     }
                     
                     // 重置时间和流程标记
-                    self.Time = 30;
+                    self.Time = 0;
                     self.Flag = false;
                     
                     // 给出牌人广播
-                    MessageHelper.SendToClient(player, new G2C_HGHHDisCardPush(){info = ProtoHelper.RoomToProto(room, player, self.CurrentPlayer)});
+                    RoomInfo info = ProtoHelper.RoomToProto(room, player, self.CurrentPlayer);
+                    info.Time = 30;
+                    MessageHelper.SendToClient(player, new G2C_HGHHDisCardPush(){info = info});
+                    
                     // 给其他三家广播
                     foreach (int index in nextPos)
                     {
                         Player otherPlayer = self.Players[index];
-                        if (otherPlayer != null)
+                        if (otherPlayer == null)
                         {
-                            // 广播其它三家
-                            MessageHelper.SendToClient(otherPlayer, new G2C_HGHHDisCardPush(){info = ProtoHelper.RoomToProto(room, otherPlayer, self.CurrentPlayer)});
+                            continue;
                         }
+
+                        // 广播其它三家
+                        info = ProtoHelper.RoomToProto(room, otherPlayer, self.CurrentPlayer);
+                        info.Time = 30;
+                        MessageHelper.SendToClient(otherPlayer, new G2C_HGHHDisCardPush(){info = info});
                     }
                 }
             }
@@ -662,7 +671,7 @@ namespace ET.Server
             self.OperableList.Clear();
             
             // 重置时间和流程标记
-            self.Time = 30;
+            self.Time = 0;
             self.Flag = true;
             
             Log.Info($"玩家吃牌... 玩家ID:{player.Id}, 位置:{player.Pos}, 手牌大小:{player.RemainCards.Length}, 手牌信息:{string.Join(", ", player.RemainCards)}, 吃的牌:{card}");
@@ -671,6 +680,7 @@ namespace ET.Server
             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
             {
                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
+                info.Time = 30;
                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 1});
             }
         }
@@ -742,7 +752,7 @@ namespace ET.Server
             self.OperableList.Clear();
                 
             // 重置时间和摸牌标记
-            self.Time = 30;
+            self.Time = 0;
             self.Flag = true;
                 
             Log.Info($"玩家碰牌... 玩家ID:{player.Id}, 位置:{player.Pos}, 手牌大小:{player.RemainCards.Length}, 手牌信息:{string.Join(", ", player.RemainCards)}, 碰的牌:{self.DisCard}");
@@ -751,6 +761,7 @@ namespace ET.Server
             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
             {
                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
+                info.Time = 30;
                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 2});
             }
         }
@@ -919,7 +930,7 @@ namespace ET.Server
 
             self.OperableList.Clear();
             // 重置时间和摸牌标记
-            self.Time = 30;
+            self.Time = 0;
             self.Flag = false;
             
             // bool flag = true;
@@ -942,6 +953,7 @@ namespace ET.Server
             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
             {
                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
+                info.Time = 30;
                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 3});
             }
         }
@@ -971,7 +983,7 @@ namespace ET.Server
                     foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
                     {
                         RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
-                        info.Time = 15;
+                        info.Time = 30;
                         MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 4});
                     }
                     
@@ -1026,11 +1038,12 @@ namespace ET.Server
                 self.HuResult = (int)HGHHConst.Result.DIANPAO;
             }
             player.HuCards.Add(self.GangPai);
+            
             // 广播
             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
             {
                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
-                info.Time = 15;
+                info.Time = 30;
                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 4});
             }
         }
@@ -1055,44 +1068,48 @@ namespace ET.Server
                 card = self.DisCard;
             }
 
-            if (self.CanHuIds.Contains(player.Id))
+            if (!self.CanHuIds.Contains(player.Id))
             {
-                int[] userCards = player.RemainCards;
-                int[] tmpCards = new int[userCards.Length];
-                Array.Copy(userCards, 0, tmpCards, 0, userCards.Length);
-                tmpCards = CardHelper.Add(tmpCards, card);
-                Struct.HuRes res = HGHHHelper.CheckHuType(player.KeZi, tmpCards, card);
-                if (res.Type != HGHHConst.HU_DEFAULT)
-                {
-                    if (!self.ClickHuIds.Contains(player.Id))
-                    {
-                        self.ClickHuIds.Add(player.Id);
-                    }
-                    self.CanPgIds.Clear();
-                    self.OperableList.Remove(player.Id);
-                    self.CanHuIds.Remove(player.Id);
-                    // 广播
-                    self.DianPaoHuPaiBroadcast(room, player, res.Type, isGangHU);
+                return;
+            }
+
+            int[] userCards = player.RemainCards;
+            int[] tmpCards = new int[userCards.Length];
+            Array.Copy(userCards, 0, tmpCards, 0, userCards.Length);
+            tmpCards = CardHelper.Add(tmpCards, card);
+            Struct.HuRes res = HGHHHelper.CheckHuType(player.KeZi, tmpCards, card);
+            if (res.Type == HGHHConst.HU_DEFAULT)
+            {
+                return;
+            }
+
+            if (!self.ClickHuIds.Contains(player.Id))
+            {
+                self.ClickHuIds.Add(player.Id);
+            }
+            self.CanPgIds.Clear();
+            self.OperableList.Remove(player.Id);
+            self.CanHuIds.Remove(player.Id);
+            // 广播
+            self.DianPaoHuPaiBroadcast(room, player, res.Type, isGangHU);
                     
-                    if (self.CanHuIds.Count == 0)
-                    {
-                        // 点炮胡结算
-                        self.SettlementHu();
-                        self.GameOver(room);
-                    }
-                    else
-                    {
-                        long id = self.CanHuIds.First();
+            if (self.CanHuIds.Count == 0)
+            {
+                // 点炮胡结算
+                self.SettlementHu();
+                self.GameOver(room);
+            }
+            else
+            {
+                long id = self.CanHuIds.First();
                         
-                        Player tmpPlayer = room.GetPlayer(id);
-                        if (tmpPlayer != null)
-                        {
-                            self.CurrentPlayer = tmpPlayer;
-                        }
-
-                        self.Time = 15;
-                    }
+                Player tmpPlayer = room.GetPlayer(id);
+                if (tmpPlayer != null)
+                {
+                    self.CurrentPlayer = tmpPlayer;
                 }
+
+                self.Time = 0;
             }
         }
 
@@ -1153,12 +1170,12 @@ namespace ET.Server
                         if (self.CurrentPlayer.Id == player.Id)
                         {
                             self.CurrentPlayer = room.GetPlayer(self.GangHuIds.First());
-                            self.Time = 15;
+                            self.Time = 0;
                             // 广播过
                             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
                             {
                                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
-                                info.Time = 15;
+                                info.Time = 30;
                                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 5});
                             }
                         }
@@ -1198,29 +1215,25 @@ namespace ET.Server
                     {
                         if (self.CurrentPlayer.Id == player.Id)
                         {
-                            long opId = 0;
                             if (self.CanHuIds.Count > 0)
                             {
                                 self.CurrentPlayer = self.Players[room.GetPlayer(self.CanHuIds.First()).Pos];
-                                opId = self.CanHuIds.First();
                             }
                             else if (self.CanPgIds.Count > 0)
                             {
                                 self.CurrentPlayer = self.Players[room.GetPlayer(self.CanPgIds.First()).Pos];
-                                opId = self.CanPgIds.First();
                             }
                             else
                             {
                                 self.CurrentPlayer = self.Players[room.GetPlayer(self.OperableList.First()).Pos];
-                                opId = self.OperableList.First();
                             }
 
-                            self.Time = 15;
+                            self.Time = 0;
                             // 广播过
                             foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
                             {
                                 RoomInfo info = ProtoHelper.RoomToProto(room, p, player);
-                                info.Time = 15;
+                                info.Time = 30;
                                 MessageHelper.SendToClient(p, new G2C_HGHHOperationPush(){info = info, OpType = 5});
                             }
                         }