示例#1
0
        PlayerHasToChoose(int digit, Domino computerDomino, string result, IList <Domino> shuffledDeck, Domino playerDomino,
                          List <Domino> playerDeck, string dominoOutput)
        {
            if (result.ToLower() == "a")
            {
                //add new domino
                while (true)
                {
                    Console.Title = ($"Your dominoes are : \n" + String.Join(",   ", playerDeck));
                    Console.Write($"Select a number (1-{shuffledDeck.Count})");

                    digit        = int.Parse(Console.ReadLine()) - 1;
                    playerDomino = shuffledDeck[digit];
                    shuffledDeck.Remove(playerDomino);
                    playerDeck.Add(playerDomino);

                    if (playerDomino.FirstN == computerDomino.SecondN)
                    {
                        dominoOutput += " (P) " + playerDomino.ToString();

                        break;
                    }
                    else if (playerDomino.SecondN == computerDomino.SecondN)
                    {
                        dominoOutput += " (P) " + playerDomino.Reverse();
                        playerDomino  = new Domino(playerDomino.Reverse());
                        break;
                    }
                }
                //Clear the console
                Console.Clear();
            }
            else if (result.ToLower() == "r")
            {
                //reverse
                dominoOutput += " (P) " + playerDeck[digit].Reverse();
                playerDomino  = new Domino(playerDeck[digit].Reverse());
                playerDeck.RemoveAt(digit);
            }
            else
            {
                //Just add it to the dominoes
                playerDomino  = playerDeck[digit];
                dominoOutput += " (P) " + playerDeck[digit];
                playerDeck.RemoveAt(digit);
            }
            return(digit, playerDomino, computerDomino, shuffledDeck, playerDeck, dominoOutput);
        }
示例#2
0
        //returns computerDomino and dominoOutput(the string result)
        public (Domino, string) IsThereAnAppropriateDominoInTheComputerDeck(Domino domino, Domino playerDomino)
        {
            var    computerDomino = new Domino();
            string compResult     = "";

            if (domino.FirstN == playerDomino.SecondN)
            {
                compResult    += " (C) " + domino.ToString();
                computerDomino = domino;
                return(computerDomino, compResult);
            }
            else if (domino.SecondN == playerDomino.SecondN)
            {
                compResult    += " (C) " + domino.Reverse();
                computerDomino = new Domino(domino.Reverse());
                return(computerDomino, compResult);
            }
            else
            {
                return(computerDomino, compResult);
            }
        }