public void Clear() { for (var i = 0; i < layer.Length; i++) { layer[i] = new LandCell(); } }
public void MonopolyPlayerBuyWithChangeTest() { Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; Tuple <ReturnState, Dictionary <MoneyType, int> > actualReturn; cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 80, LandType.State); mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50); using (StringReader sr = new StringReader("0\n0\n0\n0\n0\n1\n0\n0\n0\n2")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(mediteranianCard, cell); } Assert.AreEqual(ReturnState.Success, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 320); }
public void OnLandCellSteppedTest() { List <int> receivedEvents = new List <int>(); LandCell cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 100, LandType.State); cell.CellStepped += (object sender, LandCellEvtArgs e) => receivedEvents.Add(e.Price); cell.Step(); Assert.AreEqual(1, receivedEvents.Count); Assert.AreEqual(cell.Price, receivedEvents[0]); }
public void Load(Scenario scenario) { var theater = scenario.Theater; var cells = scenario.Cells; for (var i = 0; i < cells.Length; i++) { var templateId = cells[i].templateId; var index = cells[i].templateIndex; var landtype = theater.GetTemplate(templateId).GetLandType(index); layer[i] = new LandCell(templateId, index, landtype); } }
public void MonopolyPlayerBuyLandErrorTest() { // Act BuyLand(); Tuple <ReturnState, Dictionary <MoneyType, int> > actualReturn; Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; // Buy same land again --LandAlreadyBoughtError using (StringReader sr = new StringReader("10\n2\n4\n2\n0")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(mediteranianCard, cell); } Assert.AreEqual(ReturnState.LandAlreadyBoughtError, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 300); // buy another land -- InsufficientMoney LandCell cellUS = new LandCell(5, 5, 1, 1, "US Avenue", "US Avenue", 500, LandType.State); LandCard USCard = new LandCard("US Avenue", prices, rents, 50); using (StringReader sr = new StringReader("0\n0\n0\n0\n4\n3")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(USCard, cellUS); } Assert.AreEqual(ReturnState.InsufficientMoney, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 300); }
public void BuyLand() { Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 100, LandType.State); mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50); using (StringReader sr = new StringReader("10\n2\n4\n2\n0")) { Console.SetIn(sr); mplayer.BuyLand(mediteranianCard, cell); } }