/// <summary> /// Finds out what the rent of a property should be based off of the buildings /// and how many of the color group are owned by the same owner /// </summary> /// <param name="board">The list of all spots on the board</param> /// <returns>Returns the rent owned</returns> public int FindRentOfRegularProperty(List <Spot> board) { // Find base rent int rent = this.Rent; if (this.HasHotel) { rent = this.RentHotel; } else if (this.NumberOfHouses == 4) { rent = this.Rent4Houses; } else if (this.NumberOfHouses == 3) { rent = this.Rent3Houses; } else if (this.NumberOfHouses == 2) { rent = this.Rent2Houses; } else if (this.NumberOfHouses == 1) { rent = this.Rent1House; } else if (Game.CheckIfEligibleForHouse(this.Owner.GetPlayersPropertyList(board)).Contains(this.Color)) { // If owner owns all of the color current location is, double the rent on unimproved property rent *= 2; } return(rent); }
/// <summary> /// Initializes a new instance of the <see cref="UpgradeProperty"/> class /// </summary> /// <param name="game">brings forth the current game</param> /// <param name="currentPlayer">brings forth the currentPlayer</param> public UpgradeProperty(Game game, Player currentPlayer) { this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.ControlBox = false; this.MaximizeBox = false; this.MinimizeBox = false; this.InitializeComponent(); this.game = game; this.currentPlayer = currentPlayer; // fill the list with the list of spots that the currentPlayer has this.playerSpots = currentPlayer.GetPlayersPropertyList(this.game.Board); this.lblMoneyTotal.Text = currentPlayer.Money.ToString(); this.lblPlayerName.Text = currentPlayer.PlayerName; List <Spot> spotsEligible = new List <Spot>(); List <Color> colorsEligible = Game.CheckIfEligibleForHouse(this.playerSpots); List <Spot> mortgage = new List <Spot>(); foreach (Spot s in this.playerSpots) { if (s.IsMortgaged == true) { mortgage.Add(s); } } if (colorsEligible.Count > 0 || mortgage.Count > 0) { // Get every spot that matches a color in the list foreach (Spot s in this.playerSpots) { foreach (Color c in colorsEligible) { if ((s.Color == c || s.IsMortgaged == true) && !spotsEligible.Contains(s)) { spotsEligible.Add(s); } } if (!spotsEligible.Contains(s) && s.IsMortgaged) { spotsEligible.Add(s); } } // fill public slot this.eligible = spotsEligible; if (this.currentPlayer.IsAi == false) { // add them to the listView this.FillListView(this.listViewProperties, spotsEligible); } else { foreach (Spot s in this.eligible) { this.selectedSpot = s; // List that holds the spots of the same type this.sameType.Clear(); // Get a list of spots that share the same color foreach (Spot g in this.playerSpots) { if (g.Color == this.selectedSpot.Color && g.SpotName != this.selectedSpot.SpotName) { this.sameType.Add(g); } } // add houses/unmortgage/hotels to possible properties this.PropertyLogic(); } this.Close(); } } else { if (this.currentPlayer.IsAi == false) { MessageBox.Show("No Properties Eligible For Upgrade."); } this.Close(); } }
/// <summary> /// Fills the colors for the spots /// </summary> /// <param name="prop">The list of properties</param> private void FillColors(List <Spot> prop) { this.houseEligible = Game.CheckIfEligibleForHouse(prop); }