Ejemplo n.º 1
0
    public static GamesRecord operator +(GamesRecord a, GamesRecord b)
    {
        int displayRecordIndex;

        if (b.gamesRecordCurrentSize < b.gamesRecordSize)
        {
            displayRecordIndex = 0;
        }
        else
        {
            displayRecordIndex = b.gamesRecordCurrentIndex;
        }

        if (a.gamesRecordCurrentSize + b.gamesRecordCurrentSize > a.gamesRecordSize)
        {
            GamesRecord Ap = new GamesRecord(a.gamesRecordCurrentSize + b.gamesRecordCurrentSize);
            for (int i = 0; i < a.gamesRecordCurrentSize; i++)
            {
                Ap.AddRecord(a.gamesRecord[i, 0],
                             a.gamesRecord[i, 1],
                             a.gamesRecord[i, 2]);
            }
            Ap.gamesRecordCurrentIndex = a.gamesRecordCurrentIndex;
            Ap.gamesRecordCurrentSize  = a.gamesRecordCurrentSize;
            a = Ap;
        }
        for (int i = 0; i < b.gamesRecordCurrentSize; i++)
        {
            a.AddRecord(b.gamesRecord[displayRecordIndex, 0],
                        b.gamesRecord[displayRecordIndex, 1],
                        b.gamesRecord[displayRecordIndex, 2]);
            displayRecordIndex = (displayRecordIndex + 1) % b.gamesRecordCurrentSize;
        }
        return(a);
    }
Ejemplo n.º 2
0
        public void Play()
        {
            Clear();
            playerOne.GetInput(inputTable);
            playerTwo.GetInput(inputTable);

            /* string firstPlayerChoiceString = GetPlayerInput(playerOne);
             * string secondPlayerChoiceString;
             *
             * Clear();
             * if(AI==false)
             *   secondPlayerChoiceString = GetPlayerInput(playerTwo);
             * else
             *   secondPlayerChoiceString = GetAiAnswer();
             * Clear();
             */

            string gameResult = yellWinner(DetermineWinner(playerOne.lastInput, playerTwo.lastInput));

            gamesRecord.AddRecord(playerOne.lastInput, playerTwo.lastInput, gameResult);

            Console.WriteLine("Doktor Biceps, czy chcesz się znowu upokorzyć? Wpisz [y] żeby walczyć o czarne złoto [PB]");
            if (ReadKey(true).Key == ConsoleKey.Y)
            {
                Play();
            }
        }
Ejemplo n.º 3
0
    public void Play()
    {
        Clear();
        string firstPlayerChoiceString = GetPlayerInput(playerOne);

        Clear();
        WriteLine("Wybrałeś: " + firstPlayerChoiceString + "\nWciśniej dowolny przycisk, aby kontynuować");
        Console.ReadKey();
        Clear();
        string secondPlayerChoiceString = GetPlayerInput(playerTwo);

        Clear();
        WriteLine("Wybrałeś: " + secondPlayerChoiceString + "\nWciśniej dowolny przycisk, aby kontynuować");
        Console.ReadKey();
        Clear();

        string gameResult = DetermineWinner(firstPlayerChoiceString,
                                            secondPlayerChoiceString);

        gamesRecord.AddRecord(firstPlayerChoiceString, secondPlayerChoiceString, gameResult);

        WriteLine("Czy chcesz rozegrać kolejną rundę? Jeśli tak wciśnij [y] \n\nAby zakończyć rozgrywkę wciśnij dowolny przycisk");
        if (ReadKey(true).Key == ConsoleKey.Y)
        {
            Play();
        }
    }
Ejemplo n.º 4
0
    public void Play(bool AI)
    {
        Clear();
        string firstPlayerChoiceString = GetPlayerInput(playerOne);
        string secondPlayerChoiceString;

        Clear();
        if (AI == false)
        {
            secondPlayerChoiceString = GetPlayerInput(playerTwo);
        }
        else
        {
            secondPlayerChoiceString = GetAiAnswer();
        }
        Clear();

        string gameResult = yellWinner(DetermineWinner(firstPlayerChoiceString, secondPlayerChoiceString));

        gamesRecord.AddRecord(firstPlayerChoiceString, secondPlayerChoiceString, gameResult);

        Console.WriteLine("Doktor Biceps, czy chcesz się znowu upokorzyć? Wpisz [y] żeby walczyć o czarne złoto [PB]");
        if (ReadKey(true).Key == ConsoleKey.Y)
        {
            Play(AI);
        }
    }
Ejemplo n.º 5
0
    void GameLoop()
    {
        bool playGame = true;

        int[] numbers1 = new int[5];
        int[] numbers2 = new int[5];


        Random rnd = new Random();

        RollPlayerOneSum = 0;
        RollPlayerTwoSum = 0;

        for (int i = 0; i < numbers1.Length; i++)
        {
            numbers1[i] = rnd.Next(1, 7);
            numbers2[i] = rnd.Next(1, 7);
        }
        Clear();
        WriteLine(playerOne.PlayerName + ", press Enter to Roll&Dice!");
        while (ReadKey().Key != ConsoleKey.Enter)
        {
            WriteLine("Press correct key");
        }
        foreach (var nr in numbers1)
        {
            Write(nr + " ");
        }
        WriteLine();
        WriteLine(playerTwo.PlayerName + ", press Enter to Roll&Dice!");
        while (ReadKey().Key != ConsoleKey.Enter)
        {
            WriteLine("Press correct key");
        }
        foreach (var nr in numbers2)
        {
            Write(nr + " ");
        }
        WriteLine();

        WriteLine("Press Enter to start round 2");


        while (ReadKey().Key != ConsoleKey.Enter)
        {
            WriteLine("Press correct key");
        }

        WriteLine(playerOne.PlayerName + ", press 1 to re-roll dice 1 or press any other key to skip.");
        RerollPlayer(rnd, numbers1, ConsoleKey.D1, 0);
        WriteLine(playerOne.PlayerName + ", press 2 to re-roll dice 2 or press any other key to skip.");
        RerollPlayer(rnd, numbers1, ConsoleKey.D2, 1);
        WriteLine(playerOne.PlayerName + ", press 3 to re-roll dice 3 or press any other key to skip.");
        RerollPlayer(rnd, numbers1, ConsoleKey.D3, 2);
        WriteLine(playerOne.PlayerName + ", press 4 to re-roll dice 4 or press any other key to skip.");
        RerollPlayer(rnd, numbers1, ConsoleKey.D4, 3);
        WriteLine(playerOne.PlayerName + ", press 5 to re-roll dice 5 or press any other key to skip.");
        RerollPlayer(rnd, numbers1, ConsoleKey.D5, 4);
        WriteLine();

        foreach (var nr in numbers1)
        {
            Write(nr + " ");
        }
        WriteLine();
        WriteLine(playerTwo.PlayerName + ", press 1 to re-roll dice 1 or press any other key to skip.");
        RerollPlayer(rnd, numbers2, ConsoleKey.D1, 0);
        WriteLine(playerTwo.PlayerName + ", press 2 to re-roll dice 2 or press any other key to skip.");
        RerollPlayer(rnd, numbers2, ConsoleKey.D2, 1);
        WriteLine(playerTwo.PlayerName + ", press 3 to re-roll dice 3 or press any other key to skip.");
        RerollPlayer(rnd, numbers2, ConsoleKey.D3, 2);
        WriteLine(playerTwo.PlayerName + ", press 4 to re-roll dice 4 or press any other key to skip.");
        RerollPlayer(rnd, numbers2, ConsoleKey.D4, 3);
        WriteLine(playerTwo.PlayerName + ", press 5 to re-roll dice 5 or press any other key to skip.");
        RerollPlayer(rnd, numbers2, ConsoleKey.D5, 4);
        WriteLine();

        foreach (var nr in numbers2)
        {
            Write(nr + " ");
        }
        WriteLine();
        WriteLine("Press Enter to see results");
        while (ReadKey().Key != ConsoleKey.Enter)
        {
            WriteLine("Press correct key");
        }

        Clear();

        for (int i = 0; i < numbers1.Length; i++)
        {
            RollPlayerOneSum += numbers1[i];
        }
        WriteLine();
        WriteLine(RollPlayerOneSum);
        for (int i = 0; i < numbers2.Length; i++)
        {
            RollPlayerTwoSum += numbers2[i];
        }
        WriteLine(RollPlayerTwoSum);

        gamesRecord.AddRecord(new Record(RollPlayerOneSum.ToString(), RollPlayerTwoSum.ToString(), DetermineWinner()));

        WriteLine("Do you want to play another round? [y]");
        if (ReadKey(true).Key == ConsoleKey.Y)
        {
            Clear();
            GameLoop();
        }


        Clear();
    }