Example #1
0
 public ChanceFactory(IBanker banker, IJailRoster jailRoster, 
     GameBoard board, IDice dice)
 {
     this.banker = banker;
     this.jailRoster = jailRoster;
     this.board = board;
     this.dice = dice;
 }
Example #2
0
 public void SetUp()
 {
     playerId = 0;
     var faker = new MotherFaker();
     banker = faker.Banker;
     jailRoster = faker.JailRoster;
     gameBoard = faker.GameBoard;
     goToJail = new GoToJail(30, "Go To Jail", 10, banker, jailRoster, gameBoard);
 }
Example #3
0
 public void SetUp()
 {
     var faker = new MotherFaker();
     jailRoster = faker.JailRoster;
     banker = faker.Banker;
     gameBoard = faker.GameBoard;
     dice = faker.Dice;
     PutPlayerInJail();
 }
Example #4
0
 public MotherFaker()
 {
     Dice = new FakeDice();
     Banker = new TraditionalBanker(new[] { 0 });
     JailRoster = new TraditionalJailRoster(Banker);
     GameBoard = new GameBoard(Banker);
     var cardDeckFactory = new TraditionalCardDeckFactory(Banker, JailRoster, GameBoard, Dice);
     LocationFactory = new TraditionalLocationFactory(Banker, Dice, JailRoster, GameBoard, cardDeckFactory);
     GameBoard.SetLocations(LocationFactory.GetLocations(), LocationFactory.GetRailroads(), LocationFactory.GetUtilities());
 }
        public void TestGetDeckReturnsACardDeck()
        {
            var banker = new TraditionalBanker(new[] { 0, 1 });
            var jailRoster = new TraditionalJailRoster(banker);
            var locationManager = new GameBoard(banker);
            var communityChestFactory = new CommunityChestFactory(banker, jailRoster, locationManager);

            var deck = communityChestFactory.GetCards();
            Assert.That(deck.Count(), Is.EqualTo(16));
        }
Example #6
0
 public void SetUp()
 {
     playerId = 0;
     banker = new TraditionalBanker(new[] { playerId });
     jailRoster = new TraditionalJailRoster(banker);
     board = new GameBoard(banker);
     cardDeckFactory = new FakeCardDeckFactory(CreateCards());
     var locationFactory = new TraditionalLocationFactory(banker, dice, jailRoster, board, cardDeckFactory);
     board.SetLocations(locationFactory.GetLocations(), locationFactory.GetRailroads(), locationFactory.GetUtilities());
 }
Example #7
0
        private GameBoard CreateBoard()
        {
            var gameBoard = new GameBoard(banker);
            dice = new TraditionalDice();
            jailRoster = new TraditionalJailRoster(banker);
            var traditionalCardDeckFactory = new TraditionalCardDeckFactory(banker, jailRoster, gameBoard, dice);
            var locationFactory = new TraditionalLocationFactory(banker, dice, jailRoster, gameBoard, traditionalCardDeckFactory);

            gameBoard.SetLocations(locationFactory.GetLocations(), locationFactory.GetRailroads(), locationFactory.GetUtilities());

            return gameBoard;
        }
Example #8
0
 public virtual void SetUp()
 {
     playerOneId = 0;
     playerTwoId = 1;
     playerThreeId = 2;
     playerFourId = 3;
     playerFiveId = 4;
     banker = new TraditionalBanker(new[] { playerOneId, playerTwoId, playerThreeId, playerFourId, playerFiveId });
     jailRoster = new TraditionalJailRoster(banker);
     gameBoard = new GameBoard(banker);
     dice = new FakeDice();
     var cardDeckFactory = new TraditionalCardDeckFactory(banker, jailRoster, gameBoard, dice);
     var locationFactory = new TraditionalLocationFactory(banker, dice, jailRoster, gameBoard, cardDeckFactory);
     gameBoard.SetLocations(locationFactory.GetLocations(), locationFactory.GetRailroads(), locationFactory.GetUtilities());
 }
 public TraditionalCardDeckFactory(IBanker banker, IJailRoster jailRoster,
     GameBoard board, IDice dice)
 {
     this.communityChestFactory = new CommunityChestFactory(banker, jailRoster, board);
     this.chanceFactory = new ChanceFactory(banker, jailRoster, board, dice);
 }
Example #10
0
        //Method that is used to determine what the player action should be.
        //Method depends heavliy on what space is sent over.
        public void Action(Space space, GameBoard board, List <Player> players)
        {
            if (space is PropertySpace)
            {
                PropertySpace temp = (PropertySpace)space;
                PropertySpaceAction(temp);
            }
            else if (space is ChanceSpace)
            {
                //Player draws a chance card and the card effect is applied
                ChanceCards card = ChanceSpace.DrawCard();
                MessageBox.Show(card.GetChanceDescription());
                card.CardEffect(this, board, card, players);

                //Activates the property space action when player is moved to a property space.
                if (card.GetChanceEffect() == 2 || card.GetChanceEffect() == 3 || card.GetChanceEffect() == 13 || card.GetChanceEffect() == 12)
                {
                    PropertySpace temp = (PropertySpace)GetSpaceOccupied();
                    PropertySpaceAction(temp);
                }
            }
            else if (space is CommunityChestSpace)
            {
                //Player draws a community chest card and the card effect is applied
                CommunuityChestCards card = CommunityChestSpace.DrawCard();
                MessageBox.Show(card.GetCommunuityChestName());
                card.CardEffect(this, card);
            }
            else if (space is UtilitySpace)
            {
                UtilityAction(space);
            }
            else if (space is FreeParkingSpace)
            {
                //Gives player who landed on free parking the total money given to free parking.
                FreeParkingSpace fpSpace = (FreeParkingSpace)space;
                MessageBox.Show($"Player {playerId} has collect {fpSpace.GetAccumulatedMoney().ToString("C2")}");
                fpSpace.CollectMoney(this);
            }
            else if (space is RailroadSpace)
            {
                RailroadSpace temp = (RailroadSpace)space;
                RailroadSpaceAction(temp);
            }
            else if (space is GoToJailSpace)
            {
                //Sends player to jail space and jails them
                MessageBox.Show("Sent to Jail");
                MovePlayerToSpace(board.GetJailSpace());
                JailSpace jailSpace = (JailSpace)spaceOccupied;

                if (!isJailed)
                {
                    jailSpace.AddPlayerToJail(this);
                }
                else
                {
                    jailSpace.EscapeJail(this);
                }
            }
            else if (space is JailSpace || IsPlayerJailed() == true)
            {
                //If player is jailed, it allows them to attempt escape or if they
                //have a get out of jail free card, they can instantly escape.
                JailSpace jailSpace = (JailSpace)board.GetJailSpace();

                if (HasGetOutOfJailFreeCard())
                {
                    jailSpace.RemovePlayerFromJail(this);
                }

                if (isJailed)
                {
                    jailSpace.EscapeJail(this);
                }
            }

            CheckForLost();
        }
Example #11
0
 public NormalTurn(Int32 playerId, IDice dice, IJailRoster jailRoster, GameBoard board)
     : base(playerId, dice, jailRoster, board)
 {
 }
Example #12
0
        public void TestSetLocationsBuildsLocationsList()
        {
            var board = new GameBoard(banker);
            var location = new NullLocation(0, "null");
            var railroad = new Railroad(1, "railroad", 10, 10, banker, new Railroad[] {});
            var utility = new Utility(2, "utility", 10, 10, banker, new Utility[] {}, new FakeDice());
            board.SetLocations(new Location[] { location }, new Railroad[] { railroad }, new Utility[] { utility });

            Assert.That(board.Locations.Count(), Is.EqualTo(3));
        }
Example #13
0
 public TraditionalTurnFactory(TraditionalBanker banker)
 {
     this.banker = banker;
     board = CreateBoard();
 }
Example #14
0
 public CommunityChestFactory(IBanker banker, IJailRoster jailRoster, GameBoard board)
 {
     this.banker = banker;
     this.jailRoster = jailRoster;
     this.board = board;
 }