Beispiel #1
0
        public void Add(String playerName)
        {
            Player player = new Player(playerName);

            playersService.Add(player);
            board.Add(player);

            MessagingService.Send(playerName + " was added");
            MessagingService.Send("They are player number " + playersService.Count());
        }
Beispiel #2
0
        public void Run()
        {
            InitializePlayers();

            List <int> rolls   = CreateRollsSequence();
            List <int> squares = CreateSquaresSequence();

            int next = 0;

            do
            {
                Roll(rolls[next]);

                if (squares[next] == 7)
                {
                    notAWinner = true;
                    MessagingService.Send("Question was incorrectly answered");
                    MessagingService.Send(playersService.Current().Name + " was sent to the penalty box");
                    board.PutInPenaltyBox(playersService.Current());
                    playersService.SetNextPlayerAsCurrent();
                }
                else
                {
                    if (board.IsInPenaltyBox(playersService.Current()))
                    {
                        playersService.SetNextPlayerAsCurrent();
                        notAWinner = true;
                    }
                    else
                    {
                        MessagingService.Send("Answer was corrent!!!!");
                        playersService.Current().IncrementGoldCoins();
                        MessagingService.Send(playersService.Current().Name
                                              + " now has "
                                              + playersService.Current().GoldCoins()
                                              + " Gold Coins.");

                        notAWinner = playersService.Current().GoldCoins() != COINS_TO_WIN;
                        playersService.SetNextPlayerAsCurrent();
                    }
                }

                next++;
            } while (notAWinner);

            writer.Close();
        }
Beispiel #3
0
        public void Roll(int roll)
        {
            MessagingService.Send(playersService.Current().Name + " is the current player");
            MessagingService.Send("They have rolled a " + roll);

            if (board.IsInPenaltyBox(playersService.Current()))
            {
                if (IsPair(roll))
                {
                    board.TakeOffPenaltyBox(playersService.Current());
                    board.MovePlayerForward(playersService.Current(), roll);

                    MessagingService.Send(playersService.Current().Name + " is getting out of the penalty box");
                    MessagingService.Send(playersService.Current().Name
                                          + "'s new location is "
                                          + board.PositionOf(playersService.Current()));
                    MessagingService.Send("The category is " + CurrentCategory().ToString());

                    AskQuestion();
                }
                else
                {
                    MessagingService.Send(playersService.Current().Name + " is not getting out of the penalty box");
                }
            }
            else
            {
                board.MovePlayerForward(playersService.Current(), roll);

                MessagingService.Send(playersService.Current().Name
                                      + "'s new location is "
                                      + board.PositionOf(playersService.Current()));
                MessagingService.Send("The category is " + CurrentCategory().ToString());

                AskQuestion();
            }
        }
Beispiel #4
0
 private void AskQuestion()
 {
     MessagingService.Send(questionsService.Next(CurrentCategory()).Content);
 }