public void DevelopableLand_CorrectRentReturned() { int[] rentTable = new int[6] { 10, 30, 90, 160, 250, 350 }; DevelopableLand crapperStreet = new DevelopableLand("Crapper Street", 60, Colour.Brown, rentTable); IPlayer player = new HumanPlayer("Bob", 0, Token.Goblet); // Bob buys crapper street, rent = £10 player.BuyProperty(crapperStreet); Assert.AreEqual(10, crapperStreet.GetRent()); // Bob goes to jail, rent = £0 player.GoToJail(31); Assert.AreEqual(0, crapperStreet.GetRent()); // Bob is released from jail and develops property by 1 house, rent = £30 // note: development difference rule is enforced by PropertyTycoon player.ReleaseFromJail(); player.DevelopProperty(crapperStreet); Assert.AreEqual(30, crapperStreet.GetRent()); // Bob develops more player.DevelopProperty(crapperStreet); player.DevelopProperty(crapperStreet); Assert.AreEqual(160, crapperStreet.GetRent()); // Bob sells 1 house player.UndevelopProperty(crapperStreet); Assert.AreEqual(90, crapperStreet.GetRent()); }
public void SellDevelopableLand_Developed_Unmortgaged() { int[] rentTable = new int[6] { 4, 20, 60, 180, 320, 500 }; DevelopableLand gangstersParadise = new DevelopableLand("Gangsters Paradise", 60, Colour.Brown, rentTable); // develop property with 1 house gangstersParadise.Develop(); Assert.AreEqual(1, gangstersParadise.GetHouses()); // check if property can be sold Assert.IsFalse(gangstersParadise.CanSellProperty()); // cannot sell, must undevelop property first gangstersParadise.Undevelop(); Assert.AreEqual(0, gangstersParadise.GetHouses()); // unmortgaged property sells for original price value (£60) Assert.IsTrue(gangstersParadise.CanSellProperty()); int sellingPrice = gangstersParadise.SellPropertyToBank(); Assert.AreEqual(60, sellingPrice); // property is unowned after selling Assert.IsNull(gangstersParadise.GetOwner()); }
public void InitaliseDevelopableLandWithCorrectData() { int[] rentTable = new int[6] { 30, 60, 100, 150, 200, 320 }; int price = 200; Colour group = Colour.Blue; DevelopableLand reyLane = new DevelopableLand("Rey Lane", price, group, rentTable); // correct name Assert.AreEqual("Rey Lane", reyLane.GetPropertyName()); // correct price Assert.AreEqual(200, reyLane.GetPrice()); // correct group Assert.AreEqual(Colour.Blue, reyLane.GetColourGroup()); // correct rent table var actualRentTable = reyLane.GetRentTable(); for (int i = 0; i < 5; i++) { Assert.AreEqual(rentTable[i], actualRentTable[i]); } // initially unowned Assert.IsNull(reyLane.GetOwner()); // initially unmortgaged Assert.IsFalse(reyLane.IsMortgaged()); // initially undeveloped Assert.AreEqual(0, reyLane.GetHouses()); // implements IProperty interface Assert.IsTrue(reyLane is IProperty); }
public void Player_TradeProperty() { DevelopableLand crapperStreet = new DevelopableLand("Crapper Street", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 100 }); DevelopableLand gangsters = new DevelopableLand("Gangsters Paradise", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 100 }); Station lewes = new Station("Lewes Station", 200); HumanPlayer sarah = new HumanPlayer("Sarah", 0, Token.Boot); HumanPlayer bob = new HumanPlayer("Bob", 1, Token.Hatstand); // sarah buys crapper street, gangsters paradise and bob buys lewes station sarah.BuyProperty(crapperStreet); sarah.BuyProperty(gangsters); bob.BuyProperty(lewes); // assume bob and sarah agree to trade 2 brown properties for lewes station // trade method only handles updated player property lists and station/utility counts List <IProperty> tradeOff = new List <IProperty>() { crapperStreet, gangsters }; List <IProperty> tradeReturn = new List <IProperty>() { lewes }; sarah.TradeProperties(tradeOff, tradeReturn); bob.TradeProperties(tradeReturn, tradeOff); // check player's owned property lists are updated correctly Assert.IsTrue(bob.GetPropertiesOwned().Contains(crapperStreet)); Assert.IsTrue(bob.GetPropertiesOwned().Contains(gangsters)); Assert.IsFalse(bob.GetPropertiesOwned().Contains(lewes)); Assert.AreEqual(0, bob.GetNumberOfStations()); // check stations count updated Assert.IsFalse(sarah.GetPropertiesOwned().Contains(crapperStreet)); Assert.IsFalse(sarah.GetPropertiesOwned().Contains(gangsters)); Assert.IsTrue(sarah.GetPropertiesOwned().Contains(lewes)); Assert.AreEqual(1, sarah.GetNumberOfStations()); // check stations count updated // ensure owner of property objects updated correctly Assert.AreEqual(bob, crapperStreet.GetOwner()); Assert.AreEqual(bob, gangsters.GetOwner()); Assert.AreEqual(sarah, lewes.GetOwner()); // attempting to trade property that isn't owned by that player throws exception try { sarah.TradeProperties(tradeOff, tradeReturn); } catch (HumanPlayerException e) { Console.WriteLine(e.Message); Assert.AreEqual(e.Message, "Cannot trade a property because the player doesn't own it."); } }
int spaceID = 1; //change this and the script name I suppose... // Use this for initialization void Start() { controller = GameObject.Find("GameController"); controllerScript = controller.GetComponent <ControllerScript>(); // don't check what space the current player is on because they don't need to be on the space to view the property info // instead we will hard code the board space number to each script and copy and paste... PropertyTycoon game = controllerScript.game; PropertySpace space = ((PropertySpace)game.GetBoardSpace(spaceID)); IProperty property = space.GetProperty(); if (property.IsDevelopable()) { DevelopableLand devLand = (DevelopableLand)property; if (devLand.GetColourGroup() == Colour.Blue) { this.GetComponent <UnityEngine.UI.Image>().color = Color.cyan; } else if (devLand.GetColourGroup() == Colour.Brown) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(165, 42, 42); } else if (devLand.GetColourGroup() == Colour.DeepBlue) { this.GetComponent <UnityEngine.UI.Image>().color = Color.blue; } else if (devLand.GetColourGroup() == Colour.Green) { this.GetComponent <UnityEngine.UI.Image>().color = Color.green; } else if (devLand.GetColourGroup() == Colour.Orange) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(255, 165, 0); } else if (devLand.GetColourGroup() == Colour.Purple) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(160, 32, 240); } else if (devLand.GetColourGroup() == Colour.Red) { this.GetComponent <UnityEngine.UI.Image>().color = Color.red; } else if (devLand.GetColourGroup() == Colour.Yellow) { this.GetComponent <UnityEngine.UI.Image>().color = Color.yellow; } } }
public void Player_DevelopProperty() { HumanPlayer player = new HumanPlayer("Bob", 0, Token.Boot); DevelopableLand crapperStreet = new DevelopableLand("Crapper Street", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 100 }); DevelopableLand gangsters = new DevelopableLand("Gangsters Paradise", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 100 }); // attempt to develop crapper street without buying property first throws error try { player.DevelopProperty(crapperStreet); } catch (Exception e) { Assert.AreEqual("Cannot develop a property that you don't own!", e.Message); } // bob buys property and buys 2 houses, development = 2 player.BuyProperty(crapperStreet); int cash = player.PeekCash(); player.DevelopProperty(crapperStreet); player.DevelopProperty(crapperStreet); Assert.AreEqual(cash - 100, player.PeekCash()); Assert.AreEqual(2, crapperStreet.GetHouses()); // bob sells developments player.UndevelopProperty(crapperStreet); player.UndevelopProperty(crapperStreet); Assert.AreEqual(cash, player.PeekCash()); Assert.AreEqual(0, crapperStreet.GetHouses()); // bob sells the property and attempts to sell developments player.SellProperty(crapperStreet); try { player.UndevelopProperty(crapperStreet); } catch (HumanPlayerException e) { Assert.AreEqual("Cannot undevelop a property that you don't own!", e.Message); } }
public void Player_CheckOwnedColours() { HumanPlayer player = new HumanPlayer("Bob", 0, Token.Boot); // brown group test (2 properties) Assert.IsFalse(player.OwnsAllColour(Colour.Brown)); // player owns 0/2 brown properties DevelopableLand crapperStreet = new DevelopableLand("Crapper Street", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 120 }); DevelopableLand gangsters = new DevelopableLand("Gangsters Paradise", 100, Colour.Brown, new int[6] { 20, 20, 40, 60, 80, 120 }); player.BuyProperty(crapperStreet); // player owns 1/2 brown properties Assert.IsFalse(player.OwnsAllColour(Colour.Brown)); player.BuyProperty(gangsters); // player owns 2/2 brown properties Assert.IsTrue(player.OwnsAllColour(Colour.Brown)); // player sells a brown property player.SellProperty(crapperStreet); Assert.IsFalse(player.OwnsAllColour(Colour.Brown)); // red group test (3 properties) Assert.IsFalse(player.OwnsAllColour(Colour.Red)); // player owns 0/3 red properties DevelopableLand yueFei = new DevelopableLand("Yue Fei Square", 10, Colour.Red, new int[6] { 20, 20, 40, 60, 80, 120 }); DevelopableLand mulan = new DevelopableLand("Mulan Rouge", 10, Colour.Red, new int[6] { 20, 20, 40, 60, 80, 120 }); DevelopableLand hanXin = new DevelopableLand("Han Xin Gardens", 10, Colour.Red, new int[6] { 20, 20, 40, 60, 80, 120 }); player.BuyProperty(yueFei); Assert.IsFalse(player.OwnsAllColour(Colour.Red)); // player owns 1/3 red properties player.BuyProperty(mulan); Assert.IsFalse(player.OwnsAllColour(Colour.Red)); // player owns 2/3 red properties player.BuyProperty(hanXin); Assert.IsTrue(player.OwnsAllColour(Colour.Red)); // player owns 3/3 red properties }
public void DevelopableLand_CalculateTotalValue() { int[] rentTable = new int[6] { 30, 60, 100, 150, 200, 320 }; int price = 200; Colour group = Colour.Blue; DevelopableLand reyLane = new DevelopableLand("Rey Lane", price, group, rentTable); // total value = original price (unmortgaged, undeveloped) Assert.AreEqual(200, reyLane.CalculateTotalValue()); // mortgage undeveloped property reyLane.Mortgage(); Assert.IsTrue(reyLane.IsMortgaged()); // total value = original price / 2 Assert.AreEqual(100, reyLane.CalculateTotalValue()); // unmortgaged property reyLane.Unmortgage(); Assert.IsFalse(reyLane.IsMortgaged()); // develop property with 3 houses for (int i = 0; i < 3; i++) { reyLane.Develop(); } Assert.AreEqual(3, reyLane.GetHouses()); // get correct house price int housePrice = reyLane.GetDevelopCost(); Assert.AreEqual(50, housePrice); // total value = original price + (3 * houseprice) int correctTotal = 200 + (3 * 50); Assert.AreEqual(correctTotal, reyLane.CalculateTotalValue()); // mortgage property reyLane.Mortgage(); Assert.IsTrue(reyLane.IsMortgaged()); //total value = (original price / 2) + (3 * houseprice) int correctTotal2 = (200 / 2) + (3 * housePrice); Assert.AreEqual(correctTotal2, reyLane.CalculateTotalValue()); }
public void SellDevelopableLand_Mortgaged() { int[] rentTable = new int[6] { 4, 20, 60, 180, 320, 450 }; DevelopableLand gangstersParadise = new DevelopableLand("Gangsters Paradise", 60, Colour.Brown, rentTable); // mortgage property gangstersParadise.Mortgage(); Assert.IsTrue(gangstersParadise.IsMortgaged()); // mortgaged property sells for half price (£30) Assert.IsTrue(gangstersParadise.CanSellProperty()); int sellingPrice = gangstersParadise.SellPropertyToBank(); Assert.AreEqual(30, sellingPrice); // property is unowned and unmortgaged after selling Assert.IsNull(gangstersParadise.GetOwner()); Assert.IsFalse(gangstersParadise.IsMortgaged()); }
public void DevelopableLand_SellProperty() { int[] rentTable = new int[6] { 60, 70, 80, 90, 100, 200 }; DevelopableLand ibisClose = new DevelopableLand("Ibis Close", 400, Colour.DeepBlue, rentTable); // sell property to bank Assert.AreEqual(400, ibisClose.SellPropertyToBank()); // develop the property and attempt to sell it ibisClose.Develop(); try { ibisClose.SellPropertyToBank(); } catch (DevelopableLandException e) { Console.WriteLine(e.Message); Assert.AreEqual("Cannot sell the property while it is developed!", e.Message); } }
public void DevelopableLand_GetDevelopCost() { int[] rentTable = new int[6] { 60, 70, 80, 90, 100, 200 }; DevelopableLand ibisClose = new DevelopableLand("Ibis Close", 400, Colour.DeepBlue, rentTable); // Deep Blue houses = £200 Assert.AreEqual(Colour.DeepBlue, ibisClose.GetColourGroup()); Assert.AreEqual(200, ibisClose.GetDevelopCost()); DevelopableLand picardAvenue = new DevelopableLand("Picard Avenue", 260, Colour.Yellow, rentTable); // Yellow houses = £150 Assert.AreEqual(Colour.Yellow, picardAvenue.GetColourGroup()); Assert.AreEqual(150, picardAvenue.GetDevelopCost()); DevelopableLand pennyLane = new DevelopableLand("Penny Lane", 260, Colour.Orange, rentTable); // Orange houses = £100 Assert.AreEqual(Colour.Orange, pennyLane.GetColourGroup()); Assert.AreEqual(100, pennyLane.GetDevelopCost()); }