示例#1
0
        public void NewCardSet(string[] setCardArray)
        {
            if (setCardArray.Length == 5)
            {
                foreach (Player player in this.Players)
                {
                    if (player.PlayerID.ToString() == setCardArray[1])
                    {
                        Card  card = null;
                        Color color;

                        if (Enum.IsDefined(typeof(Color), (int)(setCardArray[2].ToCharArray()[0])) == true)
                        {
                            color = (Color)(setCardArray[2].ToCharArray()[0]);

                            if (int.TryParse(setCardArray[3], out int number) == false)
                            {
                                if (Enum.IsDefined(typeof(ActionCardType), (int)(setCardArray[3].ToCharArray()[0])) == true)
                                {
                                    ActionCardType type = (ActionCardType)(setCardArray[3].ToCharArray()[0]);
                                    card = new ActionCard(color, type);
                                }
                            }
                            else
                            {
                                card = new NumericCard(color, number);
                            }

                            if (int.TryParse(setCardArray[4], out int uno) == true)
                            {
                                if (uno == 0 || uno == 1)
                                {
                                    if (this.CheckIfValidCard(card, player) == true)
                                    {
                                        this.RemoveCardAfterSet(card, player);

                                        player.NetworkManager.Send(ProtocolManager.OK());

                                        if (this.CheckIfGameOver() == true)
                                        {
                                            this.GameOver();
                                            break;
                                        }
                                        else
                                        {
                                            this.CheckIfUno(setCardArray[4]);
                                            this.ExecuteCardEffect(card, this.GetNextPlayer(), false);
                                            ChangePlayerTurn();
                                        }
                                    }
                                    else
                                    {
                                        player.NetworkManager.Send(ProtocolManager.Invalid());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 public ActionCard(Color color, ActionCardType type)
 {
     this.Color = color;
     this.Type  = type;
 }