public static void DoAutoSubmitCard(Desk desk) { var validstr = UnoRule.ExtractCommand(desk.CurrentPlayer.Cards, desk.LastCard, desk.State); desk.AddMessage($"{(desk.CurrentPlayer is FakePlayer ? "机器人" : "托管玩家")}命令: {validstr}"); Thread.Sleep(100); var cp = desk.CurrentPlayer.PlayerId; if (desk.CurrentPlayer.Cards.Count == 2) { desk.Events.Add(new TimerEvent(() => desk.ParseMessage(cp, "uno"), 1, -1)); } desk.ParseMessage(desk.CurrentPlayer.PlayerId, validstr); }
private void TimerDraw(Desk desk, Player player, Card deskLastCard) { var genCard = Card.Generate(); player.AddCardAndSort(genCard); if (UnoRule.IsValid(genCard, deskLastCard, desk.State)) { desk.AddMessageLine("摸牌结束. 强制打出."); desk.ParseMessage(player.PlayerId, genCard.ToShortString()); } else { desk.AddMessage("没有摸到....继续摸牌"); desk.Events.Add(new TimerEvent(() => { TimerDraw(desk, player, deskLastCard); }, 2, desk.Step)); } }
public override void Parse(Desk desk, Player player, string command) { if (!desk.Players.Contains(player)) { return; } if (ParseUnoCommand(desk, player, command)) { return; } if (!IsValidPlayer(desk, player)) { return; } // uno draw switch (command) { case "摸": case "摸牌": case "mo": case "draw": case "画画": switch (desk.State) { case GamingState.Gaming: player.AddCardsAndSort(1); desk.AddMessageLine("已为你摸牌."); break; case GamingState.WaitingDrawTwoOverlay: case GamingState.WaitingDrawFourOverlay: desk.FinishDraw(desk.CurrentPlayer); break; case GamingState.Doubting: desk.AddMessage("我在问你要不要质疑! 不是问你摸不摸!"); return; } MoveNext(desk); desk.SendLastCardMessage(); return; } // uno doubt if (desk.State == GamingState.Doubting) { switch (command) { case "质疑": FinishDoubt(desk, player, true); return; case "不质疑": FinishDoubt(desk, player, false); return; default: desk.AddMessage("不是一个标准的质疑命令."); return; } } // uno submit card var card = command.ToCard(); if (card == null) { desk.AddMessage("无法匹配你想出的牌."); return; } if (!UnoRule.IsValid(card, desk.LastCard, desk.State)) { desk.AddMessage("你想出的牌并不匹配 UNO 规则."); return; } if (!card.IsValidForPlayerAndRemove(player)) { desk.AddMessage("你的手里并没有这些牌."); return; } desk.LastCard = card; if (card.Type != CardType.DrawFour) { desk.LastNonDrawFourCard = card; } if (player.Cards.Count == 0) { desk.FinishGame(player); return; } player.LastSendTime = DateTime.Now; desk.LastSendPlayer = player; Behave(desk, player, card); desk.SendLastCardMessage(); }
public override void Parse(Desk desk, Player player, string command) { command = ToGenericCommand(command); switch (command) { case "lastCard": desk.SendLastCardMessage(); return; } if (!desk.Players.Contains(player)) { return; } if (ParseUnoCommand(desk, player, command)) { return; } switch (command) { case "publicCard": player.PublicCard = true; desk.AddMessage("明牌成功."); return; case "myRound": desk.AddMessage("是是, 我们都知道是你的回合"); return; case "autoSubmit": desk.AddMessage("完成."); player.AutoSubmitCard = true; return; case "disableAutoSubmit": desk.AddMessage("完成."); player.AutoSubmitCard = false; return; } var card = command.ToCard(); if (card != null && UnoRule.IsValidForFollowCard(card, desk.LastCard, desk.State)) { if (!card.IsValidForPlayerAndRemove(player)) { desk.AddMessage("你的手里并没有这些牌."); return; } After(desk, player, card); CurrentIndex = desk.PlayerList.FindIndex(p => p == player); MoveNext(desk); desk.SendLastCardMessage(); } if (!IsValidPlayer(desk, player)) { return; } // uno draw switch (command) { case "draw": switch (desk.State) { case GamingState.Gaming: TimerDraw(desk, player, desk.LastCard); return; case GamingState.WaitingDrawTwoOverlay: case GamingState.WaitingDrawFourOverlay: desk.FinishDraw(desk.CurrentPlayer); break; case GamingState.Doubting: desk.AddMessage("我在问你要不要质疑! 不是问你摸不摸!"); return; } MoveNext(desk); desk.SendLastCardMessage(); return; } // uno doubt if (desk.State == GamingState.Doubting) { switch (command) { case "doubt": FinishDoubt(desk, player, true); return; case "nonDoubt": FinishDoubt(desk, player, false); return; default: desk.AddMessage("不是一个标准的质疑命令."); return; } } // uno submit card if (card == null) { desk.AddMessage("无法匹配你想出的牌."); return; } if (!UnoRule.IsValid(card, desk.LastCard, desk.State)) { desk.AddMessage("你想出的牌并不匹配 UNO 规则."); return; } if (!card.IsValidForPlayerAndRemove(player)) { desk.AddMessage("你的手里并没有这些牌."); return; } After(desk, player, card); desk.SendLastCardMessage(); }