public void PlayerLandsOnMortgagedProperty_NoRentIsCharged()
        {
            IDice          dice           = new Dice();
            GameController gameController = new GameController(dice);

            gameController.StartNewGame(4);

            Player player1 = gameController.Game.GetPlayer(0);

            player1.Location = 37;
            player1.AddCash(400);

            Player player2 = gameController.Game.GetPlayer(1);

            player2.AddCash(400);

            PropertySquare boardwalk = ((PropertySquare)gameController.Board.GetSquareAtPosition(39));

            boardwalk.Owner     = gameController.Game.GetPlayer(1);
            boardwalk.Mortgaged = true;

            Movement movement = new Movement(gameController.Board);

            movement.MovePlayer(player1, 2);
            gameController.ApplyEffectForCurrentPosition(player1, 2);

            Assert.AreEqual(400, player1.CashOnHand);
            Assert.AreEqual(400, player2.CashOnHand);
        }
Example #2
0
        public bool ShouldPurchase(Player p, PropertySquare s)
        {
            var cash  = p.Cash;
            var price = s.Price;

            return(cash - price >= _threshold);
        }
        public void SetPriceTo100_PriceIs100()
        {
            PropertySquare propertySquare = new PropertySquare();

            propertySquare.Price = 100;
            Assert.AreEqual(100, propertySquare.Price);
        }
        public void PropertySquare_RentIsDoubledWhenAllPropertiesAreOwnedButNoStructuresArePresent()
        {
            Board board = new Board();

            Player player1 = new Player("Player1");

            player1.AddCash(2000);

            Player player2 = new Player("Player2");

            player2.AddCash(2000);

            PropertySquare boardwalkSquare = (PropertySquare)board.GetSquareAtPosition(39);

            boardwalkSquare.Owner = player1;

            PropertySquare parkPlaceSquare = (PropertySquare)board.GetSquareAtPosition(37);

            parkPlaceSquare.Owner = player1;

            boardwalkSquare.ApplyEffect(board, player2, 2);

            Assert.AreEqual(1900, player2.CashOnHand);
            Assert.AreEqual(2100, player1.CashOnHand);
        }
Example #5
0
 public void BuyProperty(PropertySquare propertySquare)
 {
     if (this.cashOnHand >= propertySquare.Price)
     {
         propertySquare.Owner = this;
         this.cashOnHand     -= propertySquare.Price;
     }
 }
        public void PropertySquareConstructor_SetsNamePriceAndGroup()
        {
            PropertySquare propertySquare = new PropertySquare("Boardwalk", 400, OwnableSquare.PropertyGroup.Dark_Blue, new int[] { 0, 1, 2, 3, 4, 5 });

            Assert.AreEqual("Boardwalk", propertySquare.Name);
            Assert.AreEqual(400, propertySquare.Price);
            Assert.AreEqual(OwnableSquare.PropertyGroup.Dark_Blue, propertySquare.Group);
        }
        public void PropertySquare_CanSetOwner()
        {
            PropertySquare propertySquare = new PropertySquare();
            Player         player         = new Player("Horse");

            propertySquare.Owner = player;

            Assert.AreEqual(player, propertySquare.Owner);
        }
Example #8
0
 public void BuyPropertyIfUnowned(Player currentPlayer)
 {
     if (board.GetSquareAtPosition(currentPlayer.Location) is PropertySquare)
     {
         PropertySquare propertySquare = (PropertySquare)board.GetSquareAtPosition(currentPlayer.Location);
         if (propertySquare.Owner == null)
         {
             currentPlayer.BuyProperty(propertySquare);
         }
     }
 }
Example #9
0
        public void AttemptPurchase(PropertySquare s)
        {
            var price = s.Price;

            if (Cash < price)
            {
                return;
            }
            if (!_purchasingStrategy.ShouldPurchase(this, s))
            {
                return;
            }
            s.Owner = this;
            ReduceCash(price);
        }
        public void PropertySquare_RentIsStatedAmountWhenNotAllPropertiesAreOwned()
        {
            Board board = new Board();

            Player player1 = new Player("Player1");

            player1.AddCash(2000);

            Player player2 = new Player("Player2");

            player2.AddCash(2000);

            PropertySquare boardwalkSquare = (PropertySquare)board.GetSquareAtPosition(39);

            boardwalkSquare.Owner = player1;

            boardwalkSquare.ApplyEffect(board, player2, 2);

            Assert.AreEqual(1950, player2.CashOnHand);
            Assert.AreEqual(2050, player1.CashOnHand);
        }
Example #11
0
 public bool ShouldPurchase(Player p, PropertySquare s)
 {
     return(false);
 }
        public void PropertySquare_DefaultOwnerIsNull()
        {
            PropertySquare propertySquare = new PropertySquare();

            Assert.IsNull(propertySquare.Owner);
        }
        public void PropertySquare_PriceDefaultsToZero()
        {
            PropertySquare propertySquare = new PropertySquare();

            Assert.AreEqual(0, propertySquare.Price);
        }