예제 #1
0
        public void addPlayers(int numbPlayers)
        {
            for (int i = 0; i < numbPlayers; i++)
            {
                Player player = new Player();
                //ComputerPlayer compPlayer = new ComputerPlayer();
                m_mainMenuView.showYahtzeeHeader();
                m_mainMenuView.enterNameOfPlayer();

                string name = Console.ReadLine();

                //Check if the name is Numeric
                //Numeric == Player is a Computer
               if (player.checkIfComputerPlayer(name))
                {
                    player.setName("Comp" + i);
                }
                else
                {
                    player.setName(name);
                }
                playerList.Add(player);

            }
        }
예제 #2
0
        protected int[] sequenceRollOfDices(Player player)
        {
            int sleep = 2000;
            //First roll
            int[] rollDice = m_yahtzeeGame.rollDice(player);
            m_yahtzeeView.showDices(rollDice);
            m_yahtzeeView.showIfUserWantsToHold();

            //Checks if player wants to hold any dices
            int[] diceHold = m_yahtzeeGame.holdedDice();

            //User Pressed enter and not held any dices
            if (diceHold == null || diceHold.Length == 0)
            {
                //Second roll
                rollDice = m_yahtzeeGame.rollDice(player);
                m_yahtzeeView.showDices(rollDice);
                m_yahtzeeView.showIfUserWantsToHold();

                //Checks if player wants to hold any dices
                diceHold = m_yahtzeeGame.holdedDice();

                //User Pressed enter and not held any dices
                //Returns the last roll of dices
                if (diceHold == null || diceHold.Length == 0)
                {
                    //Third roll
                    rollDice = m_yahtzeeGame.rollDice(player);
                    m_yahtzeeView.showDices(rollDice);
                    m_yahtzeeView.showFinalDices(player.getRolledDices());
                    Thread.Sleep(sleep);
                    return player.getRolledDices(); ;
                }
                //User wanted to hold dice's
                else
                {
                    //Holds the dices in array
                    diceHold = m_yahtzeeGame.holdDice(player, diceHold, rollDice);
                    m_yahtzeeView.showTheDicesHeld(diceHold);

                    //Rolls the remaining dices
                    //Third roll
                    rollDice = m_yahtzeeGame.rollDice(player);

                    m_yahtzeeView.showFinalDices(player.getRolledDices());
                    Thread.Sleep(sleep);
                    //returns the final dices
                    return player.getRolledDices();
                }
            }

            //User wanted to hold dice's
            else
            {

                diceHold = m_yahtzeeGame.holdDice(player, diceHold, rollDice);
                m_yahtzeeView.showTheDicesHeld(diceHold);

                //Second roll
                rollDice = m_yahtzeeGame.rollDice(player);
                m_yahtzeeView.showDices(rollDice);
                m_yahtzeeView.showIfUserWantsToHold();

                //Checks if player wants to hold any dices
                int[] diceHold2 = m_yahtzeeGame.holdedDice();
                if (diceHold2 == null || diceHold2.Length == 0)
                {
                    //Third roll
                    rollDice = m_yahtzeeGame.rollDice(player);
                    m_yahtzeeView.showDices(rollDice);

                    m_yahtzeeView.showFinalDices(player.getRolledDices());
                    Thread.Sleep(sleep);
                    //returns the final dices
                    return player.getRolledDices();
                }
                else
                {
                    diceHold = m_yahtzeeGame.holdDice(player, diceHold2, rollDice);
                    m_yahtzeeView.showTheDicesHeld(diceHold);

                    rollDice = m_yahtzeeGame.rollDice(player);
                    m_yahtzeeView.showDices(rollDice);

                    m_yahtzeeView.showFinalDices(player.getRolledDices());
                    Thread.Sleep(sleep);
                    //returns the final dices
                    return player.getRolledDices();
                }
            }
        }
예제 #3
0
 public void showPlayersTurn(Player p)
 {
     Console.WriteLine("Player {0} turn to roll", p.getName());
 }
예제 #4
0
 public int[] rollDice(Player player)
 {
     return player.rollDices(startingDices - player.getdicesTurn().Length, startingDices);
 }
예제 #5
0
 public int[] holdDice(Player player, int[] diceHold, int[] rollDice)
 {
     return player.holdDice(diceHold, rollDice);
 }
예제 #6
0
 public void addData(Player player)
 {
     listOfPlayers.Add(player);
 }