コード例 #1
0
ファイル: Program.cs プロジェクト: SizeableThink/yahtzee
    public void TakeTurn()
    ///TakeTurn for AI is giving the AI five rolls. Each roll is evaluated to see which slot is the max potential for points for that
    /// roll, all the max points are then compared and the highest is chosen to be set in a slot. This should be re-written as a loop.
    {
        int[] dice = new int[5];
        Console.WriteLine("{0}'s turn!\n", name);
        Console.WriteLine("{0} roll 1: ", name);
        RollDice(dice);
        Console.WriteLine("");
        Thread.Sleep(1000);
        Console.WriteLine("{0} roll 2: ", name);
        ReRoll(dice);
        Console.WriteLine("");
        Thread.Sleep(1000);
        Console.WriteLine("{0} roll 3: ", name);
        ReRoll(dice);
        Console.WriteLine("");
        Thread.Sleep(1000);
        Console.Write("Please enter which slot you would like to put your score: ");
        int slot = EvaluateMaximumScore(dice);

        Console.WriteLine(slot);
        score.SetScore(dice, slot);
        Console.WriteLine("");
        Console.WriteLine("Press enter to take your turn!");
        Console.ReadKey();
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: SizeableThink/yahtzee
    public void TakeTurn()
    /// TakeTurn is used in the main loop. It is different for Human v AI because the Human player will choose which dice
    /// to hold and which slot to set the score by different conventions than the AI. This method rolls the dice three times,
    /// asks where to put the score, makes sure that slot is open, then sets the score the open slot.
    {
        int[] dice = new int[5];
        Console.WriteLine("{0}'s turn!\n", name);
        Console.WriteLine("{0} roll 1: ", name);
        RollDice(dice);
        Console.WriteLine("");
        Console.WriteLine("{0} roll 2: ", name);
        ReRoll(dice);
        Console.WriteLine("");
        Console.WriteLine("{0} roll 3: ", name);
        ReRoll(dice);
        Console.WriteLine("");
        Console.WriteLine("Please enter 0 to quit!");
        Console.WriteLine("Please enter which slot you would like to put your score: ");
        int slot = UI.PromptInt("Please enter which slot you would like to put your score: ");

        while (score.SlotOpen(slot) == false)
        {
            if (slot == 0)
            {
                Quit();
            }
            else
            {
                slot = UI.PromptInt("Please enter a valid slot number: ");
            }
        }
        score.SetScore(dice, slot);
        Console.WriteLine("\n");
    }