Пример #1
0
        public Color ReturnTrick(Color baseColor, bool wizzard)
        {
            var tricksToReturn = new List <Color>(3);

            if (Tricks.Contains(Color.White))
            {
                tricksToReturn.Add(Color.White);
            }

            if (wizzard && Tricks.Contains(Color.Red))
            {
                tricksToReturn.Add(Color.Red);
            }

            if (Tricks.Contains(baseColor))
            {
                tricksToReturn.Add(baseColor);
            }

            if (tricksToReturn.Count == 0)
            {
                return(Color.Black);
            }
            else if (tricksToReturn.Count == 1)
            {
                return(tricksToReturn.First());
            }
            else
            {
                return(ChooseTrickToRemove(tricksToReturn));
            }
        }
Пример #2
0
        public bool RequestTrick(Color trickColor)
        {
            if (!trickColor.IsCardColor())
            {
                return(false);
            }

            if (Tricks.Contains(trickColor))
            {
                Tricks[trickColor]--;
                return(true);
            }

            if (Tricks.Contains(Color.White))
            {
                for (int i = 0; i < Players.Length; i++)
                {
                    Player player = Players[(NextPlayer + i) % Players.Length];
                    if (player.Tricks.Contains(trickColor))
                    {
                        player.Tricks[trickColor]--;
                        player.Tricks[Color.White]++;
                        return(true);
                    }
                }
            }
            return(false);
        }