コード例 #1
0
ファイル: CommandParser.cs プロジェクト: Team-CLC/CardSharp
        private void ParsePlayerSubmitCard(Desk desk, Player player, string command)
        {
            switch (command)
            {
            case "过":

                #region Pass

            case "pass":
            case "passs":
            case "passss":
            case "passsss":
            case "passssss":
            case "passsssss":
            case "passssssss":
            case "passsssssss":
            case "passssssssss":
            case "passsssssssss":
            case "passssssssssss":     // 应LG的要求 别怪我 这里是暴力写法
            case "passsssssssssss":
            case "passssssssssssss":
            case "passsssssssssssss":
            case "passssssssssssssss":
            case "passsssssssssssssss":
            case "passssssssssssssssss":
            case "passsssssssssssssssss":
            case "passssssssssssssssssss":
            case "passsssssssssssssssssss":

                #endregion

            case "不出":
            case "不要":
            case "出你妈":
            case "要你妈":
                if (desk.CurrentRule == null)
                {
                    desk.AddMessage("为什么会这样呢...为什么你不出牌呢...");
                }
                else
                {
                    AnalyzeGiveUpAndMoveNext(desk);
                    RefreshCurrentRule(desk);
                    desk.BoardcastCards();
                }

                return;
            }

            if (command.StartsWith("出"))
            {
                desk.AddMessage("出的命令已经被替换为直接出牌. 如<出34567>被替换为<34567>");
                command = command.Substring(1);
            }
            var cardsCommand = command.ToUpper();
            if (cardsCommand.IsValidCardString())
            {
                if (Rules.Rules.IsCardsMatch(cardsCommand.ToCards(), desk))
                {
                    player.SendCards(desk);
                    if (CheckPlayerWin(desk))
                    {
                        return;
                    }
                    if (player.Cards.Count <= Constants.BoardcastCardNumThreshold)
                    {
                        desk.AddMessageLine($"{player.ToAtCodeWithRole()} 只剩{player.Cards.Count}张牌啦~");
                    }

                    if (desk.SuddenDeathEnabled)
                    {
                        desk.AddMessageLine("WARNING: SUDDEN DEATH ENABLED");
                    }

                    if (player.PublicCards)
                    {
                        desk.AddMessageLine($"明牌:{player.Cards.ToFormatString()}");
                    }

                    AnalyzeGiveUpAndMoveNext(desk);
                    RefreshCurrentRule(desk);
                    desk.BoardcastCards();
                }
                else
                {
                    if (desk.CurrentRule != null)
                    {
                        var rule = Rules.Rules.FirstMatchRule(cardsCommand.ToCards());
                        if (rule != null && rule != desk.CurrentRule)
                        {
                            desk.AddMessage($"你想出的牌匹配了规则{rule},但是当前规则是{desk.CurrentRule},所以你并不能出牌哟~~");
                        }
                        else
                        {
                            desk.AddMessage("你似乎不能出这些牌哟~");
                        }
                    }
                    else
                    {
                        desk.AddMessage("你似乎不能出这些牌哟~");
                    }
                }
            }
        }