Beispiel #1
0
        public static void DecideWinner(string name, Outcomes human, Outcomes cpu)
        {
            Node stone    = new Node();
            Node paper    = new Node(Outcomes.paper, stone);
            Node scissors = new Node(Outcomes.scissors, paper);

            stone.data = Outcomes.rock; stone.next = scissors;
            Node current = paper;

            for (int i = 0; i < 3; i++)
            {
                if (current.data == cpu)
                {
                    break;
                }
                else
                {
                    current = current.next;
                }
            }

            if (human == current.data)
            {
                Console.WriteLine("It's a tie!");
            }
            if (human == current.next.data)
            {
                var i = DBkomunikacija.NumberofVictories(name);
                int k = i + 1;
                Console.WriteLine($"Congratulations, You won! Your opponent chose {FirstCharToUpper(cpu.ToString())}. Your number of wins is: " + k);
                DBkomunikacija.InsertDataIntoDB(name, k);
            }
            if (human == current.next.next.data)
            {
                Console.WriteLine($"Too bad, the opponent chose {FirstCharToUpper(cpu.ToString())}. You lost...");
            }
        }