public void RailroadRentTest() { var group = new Group(4); var rail1 = new Railroads(15, group, 200, "Pennsylvania Railroad"); var rail2 = new Railroads(5, group, 200, "Reading Railroad"); var rail3 = new Railroads(25, group, 200, "B & 0 Railroad"); var rail4 = new Railroads(35, group, 200, "Short Line"); //get rent when one railroad is owned rail1.BoughtByPlayer(0); Assert.AreEqual(25, rail1.GetRent()); //get rent when railroad is mortgaged rail1.DevelopProperty(-1); Assert.AreEqual(0, rail1.GetRent()); //get rent with two railroads rail1.DevelopProperty(0); rail2.BoughtByPlayer(0); Assert.AreEqual(50, rail1.GetRent()); //get rent with 3 railroads rail3.BoughtByPlayer(0); Assert.AreEqual(100, rail1.GetRent()); //get rent with 4 railroads rail4.BoughtByPlayer(0); Assert.AreEqual(200, rail1.GetRent()); }
public void CanBeMortagedTest() { //testing can be mortgaged var group = new Group(1); var rail1 = new Railroads(15, group, 200, "Pennsylvania Railroad"); //test can be mortgaged and can player build Assert.AreEqual(true, rail1.CanBeMortaged()); //separate method for this }
public void CanPlayerBuildTest() { //testing can player build var player = new Player(); var group = new Group(1); var rail1 = new Railroads(15, group, 200, "Pennsylvania Railroad"); //test can be mortgaged and can player build Assert.AreEqual(false, rail1.CanPlayerBuild(0)); //separate method for this }
public override void action(Player player) { //reading railroad = 5 //pennsylvania railroad = 15 //B and O railroad = 25 //short line railroad = 35 int railIndex = 0; if (player.index <= 5) { railIndex = 5; } else if (player.index <= 15) { railIndex = 15; } else if (player.index <= 25) { railIndex = 25; } else if (player.index <= 35) { railIndex = 35; } else if (player.index <= 39) { railIndex = 5; } else { Debug.Log("Game Broken in ChanceScript3"); railIndex = 0; } player.index = railIndex; player.chanceAction = true; Railroads railroad = layout.boardTrack[player.index] as Railroads; if (railroad != null && railroad.owner == null) { card.landedOnSpace = true; } else if (railroad != null && railroad.owner != player) { int rent = railroad.calculateRent(railroad.owner) * 2; player.changeMoney(-rent); railroad.owner.changeMoney(rent); } }
private void checkForChanges(Purchasable p, Player oldOwner) { Railroads railroad = p as Railroads; Utilities utilitiy = p as Utilities; if (railroad != null) { --oldOwner.railroads; ++p.owner.railroads; } else if (utilitiy != null) { --oldOwner.utilities; ++p.owner.utilities; } }
public void AddPropertyTest() { var player = new Player(); var street = new Street(6, new Group(2, 50), 100, new int[] { 6, 30, 90, 270, 400, 550 }, "Oriental Ave"); var railroad = new Railroads(15, new Group(4), 200, "Pennsylvania Railroad"); var utility = new Utility(28, new Group(2), 150, "Water Works"); var utility1 = new Utility(12, new Group(2), 150, "Water Works"); player.addProperty(street); player.addProperty(railroad); player.addProperty(utility); player.addProperty(utility1); Assert.AreEqual(true, player.getPropertiesOwned().Contains(street)); Assert.AreEqual(true, player.getPropertiesOwned().Contains(railroad)); Assert.AreEqual(true, player.getPropertiesOwned().Contains(utility)); Assert.AreEqual(true, player.getPropertiesOwned().Contains(utility1)); }