public string GetOptionResultDesc(GameOption option)
        {
            switch (option.Command)
            {
            case GameCommand.Identify:
                var roles    = option.Result.Select(a => Convert.ToInt32(a)).Cast <GameRole>();
                var roleInfo = string.Join(" 和 ", roles.Select(role => GetRoleDesc(role)));
                return($"{roleInfo}");

            case GameCommand.Feign:
                return(GetRoleDesc((GameRole)Convert.ToInt32(option.Result[0])));

            case GameCommand.Locate:
                if (option.Result.Length == 0)
                {
                    return("无");
                }
                var seatNos    = option.Result.Select(a => Convert.ToInt32(a));
                var playerInfo = string.Join(" 和 ", seatNos.Select(seatNo => {
                    var player = GetPlayerBySeatNo(seatNo);
                    return($"[P{player.SeatNo}]{player.UserNick}");
                }));
                return($"{playerInfo}");

            case GameCommand.Rob:
                return($"新身份是[{GetRoleDesc((GameRole)Convert.ToInt32(option.Result[0]))}]");

            case GameCommand.Exchange:
            case GameCommand.Vote:
            case GameCommand.None:
                return($"完成");

            case GameCommand.Result:
                var win      = (bool)option.Result[0];
                var roleName = GetRoleDesc((GameRole)Convert.ToInt32(option.Result[1]));
                if (option.Result[1] != option.Result[2])
                {
                    roleName = GetRoleDesc((GameRole)Convert.ToInt32(option.Result[2]));
                }
                var reason   = (DeadReason)Convert.ToInt32(option.Result[4]);
                var liveness = GetDeadReasonDesc(reason);
                var result   = $"{liveness}的{roleName},{(win ? "胜利" : "失败")}!";
                result += "\n";
                Room.StateStack.Last().Seats.Where(seat => seat.No >= 0).ToList()
                .ForEach(seat => {
                    var player         = GetPlayerBySeatNo(seat.No);
                    var playerRoleName = GetRoleDesc(GetPlayRole(seat.Card));
                    var vote           = player.HistoryOptions.FirstOrDefault(op => op.Command == GameCommand.Vote);
                    var voteSeatNo     = Convert.ToInt32(vote?.Arguments[0]);
                    var voteUserNick   = GetPlayerBySeatNo(voteSeatNo).UserNick;
                    result            += $"\n[P{seat.No}]{player.UserNick}是{GetDeadReasonDesc(seat.DeadReason)}的{playerRoleName},投杀[P{voteSeatNo}]{voteUserNick}。";
                });
                return(result);
            }
            return("");
        }
        public GameOption Action(int seatNo, GameOption option)
        {
            var currentSeat = Room.StateStack.Last().Seats.FirstOrDefault(seat => seat.No == seatNo);

            if (currentSeat.Option != null)
            {
                return(currentSeat.Option);
            }


            List <int> seatNos  = null;
            GameSeat   seat0    = null;
            GameSeat   seat1    = null;
            GameCard   cardTemp = null;

            switch (option.Command)
            {
            case GameCommand.Identify:
                seatNos = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                var roles = new object[seatNos.Count];
                if (seatNos.Count > 0)
                {
                    for (var i = 0; i < seatNos.Count; i++)
                    {
                        roles[i] = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[i] == seat.No).Card.Role;
                    }
                }
                option.Result = roles;
                break;

            case GameCommand.Feign:
                seatNos          = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                seat0            = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[0] == seat.No);
                seat1            = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[1] == seat.No);
                seat0.Card.Extra = seat1.Card.Role.ToString();
                option.Result    = new object[] { seat1.Card.Role };
                break;

            case GameCommand.Locate:
                if ((GameRole)Convert.ToInt32(option.Arguments[0]) == GameRole.Werewolf)
                {
                    var seats = Room.StateStack.First().Seats
                                .Where(seat => seat.No != seatNo && seat.No >= 0 &&
                                       GetPlayRole(seat.Card) == GameRole.Werewolf)
                                .ToList();
                    seatNos       = seats.Select(seat => seat.No).ToList();
                    option.Result = seatNos.Cast <object>().ToArray();
                }
                else if ((GameRole)Convert.ToInt32(option.Arguments[0]) == GameRole.Masons)
                {
                    var seats = Room.StateStack.First().Seats
                                .Where(seat => seat.No != seatNo && seat.No >= 0 &&
                                       GetPlayRole(seat.Card) == GameRole.Masons)
                                .ToList();
                    seatNos       = seats.Select(seat => seat.No).ToList();
                    option.Result = seatNos.Cast <object>().ToArray();
                }
                break;

            case GameCommand.Rob:
                seatNos       = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                seat0         = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[0] == seat.No);
                seat1         = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[1] == seat.No);
                cardTemp      = seat0.Card;
                seat0.Card    = seat1.Card;
                seat1.Card    = cardTemp;
                option.Result = new object[] { seat0.Card.Role };
                break;

            case GameCommand.Exchange:
                seatNos       = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                seat0         = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[0] == seat.No);
                seat1         = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[1] == seat.No);
                cardTemp      = seat0.Card;
                seat0.Card    = seat1.Card;
                seat1.Card    = cardTemp;
                option.Result = new object[] { "done" };
                break;

            case GameCommand.Vote:
                seatNos = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                Room.StateStack.Last().Seats.ForEach(seat =>
                {
                    if (seatNos.Contains(seat.No))
                    {
                        seat.Vote++;
                    }
                });
                option.Result = new object[] { "done" };
                break;

            case GameCommand.Result:
                seatNos       = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                seat0         = Room.StateStack.Last().Seats.FirstOrDefault(seat => seatNos[0] == seat.No);
                option.Result = new object[] { seat0.Win, seat0.Card.Role, GetPlayRole(seat0.Card), seat0.Dead, seat0.DeadReason };
                break;

            case GameCommand.None:
                option.Result = new object[] { "done" };
                break;
            }

            var player = GetPlayerBySeatNo(seatNo);

            player.HistoryOptions.Add(option);
            currentSeat.Option = option;


            if (CanNextPhase())
            {
                if (GetCurrentPhase() == GamePhase.Day)
                {
                    var maxVote = Room.StateStack.Last().Seats.Max(seat => seat.Vote);
                    if (maxVote > 1)
                    {
                        var deadSeats = Room.StateStack.Last().Seats.Where(seat => seat.Vote == maxVote).ToList();
                        deadSeats.ForEach(seat => {
                            seat.Dead       = true;
                            seat.DeadReason = DeadReason.Vote;
                            if (GetPlayRole(seat.Card) == GameRole.Hunter)
                            {
                                Room.StateStack.Last().Seats.ForEach(voteSeat =>
                                {
                                    if (voteSeat.No >= 0 && voteSeat.No == Convert.ToInt32(seat.Option.Arguments[0]))
                                    {
                                        voteSeat.Dead       = true;
                                        voteSeat.DeadReason = DeadReason.Hunter;
                                    }
                                });
                            }
                        });
                    }
                    var isVillageWin  = JudgeVillageWin();
                    var isWerewolfWin = JudgeWerewolfWin();
                    Room.StateStack.Last().Seats.ForEach(seat => {
                        switch (seat.Card.Role)
                        {
                        case GameRole.Tanner:
                            seat.Win = seat.Dead;
                            break;

                        case GameRole.Doppelgänger:
                            if (seat.Card.Extra == GameRole.Tanner.ToString())
                            {
                                seat.Win = seat.Dead;
                            }
                            else if (seat.Card.Extra == GameRole.Werewolf.ToString() || seat.Card.Extra == GameRole.Minion.ToString())
                            {
                                seat.Win = isWerewolfWin;
                            }
                            else
                            {
                                seat.Win = isVillageWin;
                            }
                            break;

                        case GameRole.Werewolf:
                        case GameRole.Minion:
                            seat.Win = isWerewolfWin;
                            break;

                        default:
                            seat.Win = isVillageWin;
                            break;
                        }
                    });
                }
                if (GetCurrentPhase() != GamePhase.Over)
                {
                    var clone = CloneGameState(Room.StateStack.Last());
                    clone.Phase = GetNextPhase();
                    if (clone.Phase == GamePhase.Day)
                    {
                        clone.DawnTime = DateTime.Now;
                    }
                    if (clone.Phase == GamePhase.Over)
                    {
                        clone.OverTime = DateTime.Now;
                    }
                    Room.StateStack.Add(clone);
                }
            }
            return(option);
        }
        public string GetOptionDesc(GameOption option)
        {
            List <int> seatNos    = null;
            string     playerInfo = null;

            switch (option.Command)
            {
            case GameCommand.Identify:
                if (option.Phase == GamePhase.Day)
                {
                    return($"我的身份");
                }
                else
                {
                    seatNos    = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                    playerInfo = string.Join(" 和 ", seatNos.Select(seatNo => {
                        if (seatNo < 0)
                        {
                            return($"[中{-seatNo}]");
                        }
                        else
                        {
                            var player = GetPlayerBySeatNo(seatNo);
                            return($"[P{player.SeatNo}]{player.UserNick}");
                        }
                    }));
                    return($"查看 {playerInfo}");
                }

            case GameCommand.Feign:
                seatNos = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                return($"化身为 [P{seatNos[1]}]{GetPlayerBySeatNo(seatNos[1]).UserNick}");

            case GameCommand.Locate:
                if ((GameRole)Convert.ToInt32(option.Arguments[0]) == GameRole.Werewolf)
                {
                    return($"寻找 {GetRoleDesc(GameRole.Werewolf)} 同伴");
                }
                else if ((GameRole)Convert.ToInt32(option.Arguments[0]) == GameRole.Masons)
                {
                    return($"寻找 {GetRoleDesc(GameRole.Masons)} 同伴");
                }
                break;

            case GameCommand.Rob:
                seatNos = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                return($"与 [P{seatNos[1]}]{GetPlayerBySeatNo(seatNos[1]).UserNick} 交换");

            case GameCommand.Exchange:
                if (option.Phase == GamePhase.NightDrunk)
                {
                    seatNos = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                    return($"与 [中{-seatNos[1]}]交换");
                }
                else
                {
                    seatNos    = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                    playerInfo = string.Join(" 和 ", seatNos.Select(seatNo => {
                        var player = GetPlayerBySeatNo(seatNo);
                        return($"[P{player.SeatNo}]{player.UserNick}");
                    }));
                    return($"交换 {playerInfo} ");
                }

            case GameCommand.Vote:
                seatNos    = option.Arguments.Select(a => Convert.ToInt32(a)).ToList();
                playerInfo = string.Join(" 和 ", seatNos.Select(seatNo => {
                    var player = GetPlayerBySeatNo(seatNo);
                    return($"[P{player.SeatNo}]{player.UserNick}");
                }));
                return($"投 {playerInfo}");

            case GameCommand.Result:
                return("结果");

            case GameCommand.None:
                return("无行动");
            }
            return("");
        }