//overwrite original virtual method declared in Property class public override string landOn(ref Player player) { //if the following is a jail property and player has gone past then set player in jail if(this.isJail == true) { //enable setIsInJail to true player.setIsInJail(); //don't let player pass GO and don't let collect $200 player.setLocation(10, false); return null; //return base.landOn(ref player) + String.Format(player.getName() + " has gone to jail!"); } else { if(player.getJailStats() == true) { return null; //return base.landOn(ref player) + String.Format(player.getName() + " you're now in jail, you cannot pass Go or collect $200.00\nTo Get out of jail you must:\n \t-pay $50\n \t-use a 'Get out of Jail Card'\n \t-or attempt to roll doubles.\n"); } else { return base.landOn(ref player) + String.Format(player.getName() + " is visiting jail!"); } //when player is only visiting Jail //player.setNotInJail(); } }
/*----- main menu display for players when playing -----*/ public void displayPlayerChoiceMenu(Player player) { if (player.getJailStats() == true) { int resp = 0; Console.WriteLine("\n\t1. End Turn"); resp = inputInteger(); switch (resp) { case 1: break; } } else { int resp = 0; Console.WriteLine("\n{0}Please make a selection:\n", playerPrompt(player)); Console.WriteLine("\t1. Finish turn"); Console.WriteLine("\t2. View your details"); Console.WriteLine("\t3. Purchase This Property"); Console.WriteLine("\t4. Buy House for Property"); Console.WriteLine("\t5. Trade Property with Player"); Console.WriteLine("\t7. Mortgage Property"); Console.WriteLine("\t8. Unmortgage Property"); //if (player.getJailStats() == true && player.firstTurnInJail == false) //{ // Console.WriteLine("\t6. Pay $50.00 fine to get out of Jail"); //} Console.Write("\t(1-7)>"); //read response resp = inputInteger(); //if response is invalid redisplay menu if (resp == 0) this.displayPlayerChoiceMenu(player); //perform choice according to number input switch (resp) { case 1: //set firstTimeInJail to false to reset condition of player's first turn in Jail //player.firstTurnInJail = false; break; case 2: Console.WriteLine("\n\t=================================="); Console.WriteLine(player.FullDetailsToString()); Console.WriteLine("\t===================================="); this.displayPlayerChoiceMenu(player); break; case 3: this.purchaseProperty(player); this.displayPlayerChoiceMenu(player); break; case 4: this.buyHouse(player); this.displayPlayerChoiceMenu(player); break; case 5: this.tradeProperty(player); this.displayPlayerChoiceMenu(player); break; case 6: player.payFine(); this.displayPlayerChoiceMenu(player); break; case 7: this.mortgageProperty(player); this.displayPlayerChoiceMenu(player); break; case 8: this.unMortgageProperty(player); this.displayPlayerChoiceMenu(player); break; default: Console.WriteLine("That option is not avaliable. Please try again."); this.displayPlayerChoiceMenu(player); break; } } }
public void test_PlayerGettersAndSetters() { Banker theTestBanker = new Banker(); Player theTestPlayer = new Player(); //hasRolledDoubles bool theTestPlayer.get_hasRolledDoubles(); theTestPlayer.is_hasRolledDoubles(); theTestPlayer.hasRolledDoubles = true; theTestPlayer.not_hasRolledDoubles(); //paidFine bool theTestPlayer.getPaidFine(); theTestPlayer.isPaidFine(); theTestPlayer.notPaidFine(); //landedInJailByThreeStraightDoubles bool theTestPlayer.get_LandedInJailByThreeStraightDoubles(); theTestPlayer.not_LandedInJailByThreeStraightDoubles(); theTestPlayer.is_LandedInJailByThreeStraightDoubles(); //inJail bool theTestPlayer.getJailStats(); theTestPlayer.setIsInJail(); theTestPlayer.setNotInJail(); //lastMove int theTestPlayer.getLastMove(); theTestPlayer.getLocation(); theTestPlayer.getName(); theTestPlayer.getPropertiesOwned(); theTestPlayer.getBalance(); theTestPlayer.getBalance(); theTestPlayer.hasRolledDoublesInJail(); theTestPlayer.isNotActive(); theTestPlayer.get_firstTurnInJail(); theTestPlayer.not_firstTurnInJail(); }