public void testLandOn() { Utility util = new Utility(); //Create two players Player p1 = new Player("Bill"); Player p2 = new Player("Fred", 1500); string msg; //test landon normally with no rent payable msg = util.landOn(ref p1); Console.WriteLine(msg); //set owner to p1 util.setOwner(ref p1); //move p2 so that utility rent can be calculated p2.move(); //p2 lands on util and should pay rent msg = util.landOn(ref p2); Console.WriteLine(msg); //check that correct rent has been paid decimal balance = 1500 - (6 * p2.getLastMove()); Assert.AreEqual(balance, p2.getBalance()); }
public override void makePlay(int iPlayerIndex) { Console.Clear(); //make variable for player Player player = Board.access().getPlayer(iPlayerIndex); //Change the colour for the player Console.ForegroundColor = this.colors[iPlayerIndex]; //if inactive skip turn if (player.isNotActive()) { Console.WriteLine("\n{0} is inactive.\n", player.getName()); //check players to continue //check that there are still two players to continue int activePlayerCount = 0; foreach (Player p in Board.access().getPlayers()) { //if player is active if (!p.isNotActive()) { //increment activePlayerCount activePlayerCount++; } } //if less than two active players display winner if (activePlayerCount < 2) { this.printWinner(); } return; } //prompt player to make move Console.WriteLine("{0}Your turn. Press Enter to make move", playerPrompt(iPlayerIndex)); Console.ReadLine(); //move player player.move(); //Display making move Console.WriteLine("*****Move for {0}:*****", player.getName()); //Display rolling Console.WriteLine("{0}{1}\n", playerPrompt(iPlayerIndex), player.diceRollingToString()); Property propertyLandedOn = Board.access().getProperty(player.getLocation()); //landon property and output to console Console.WriteLine(propertyLandedOn.landOn(ref player)); //Display player details Console.WriteLine("\n{0}{1}", playerPrompt(iPlayerIndex), player.BriefDetailsToString()); //display player choice menu displayPlayerChoiceMenu(player); }
public void testPayRent() { Utility u = new Utility(); Player p = new Player("John", 1500); //move p so that utility rent can be calculated p.move(); u.payRent(ref p); //get p last move int i = p.getLastMove(); //check that p has played correct rent of 6 times last move decimal balance = 1500 - (6 * i); Assert.AreEqual(balance, p.getBalance()); }
public void displayJailMenu(Player player) { int resp = 0; Console.WriteLine("\n{0}Please make a selection:\n", playerPrompt(player)); Console.WriteLine("1. Pay $50"); Console.WriteLine("2. Use Get Out Of Jail Free Card"); Console.WriteLine("3. Roll The Dice"); Console.Write("(1-3)>"); //read response resp = inputInteger(); //if response is invalid redisplay menu if (resp == 0) this.displayJailMenu(player); //perform choice according to number input switch (resp) { case 1: player.payJailFine(); player.move(); displayPlayerChoiceMenu(player); break; case 2: break; case 3: player.attemptRollDouble(); Console.WriteLine("Press any key to continue.........."); Console.ReadLine(); break; } }