public Transport(string name) { Name = name; Price = 200; MortgageValue = 100; Rent = 50; Owner = Banker.Access(); }
public void TradeProperty(ref TradeableProperty property, ref Player purchaser, decimal amount, decimal mortgageAmount) { // If the property isn't mortgaged the mortgage amount will just be 0 purchaser.Pay(amount + mortgageAmount); Receive(amount); property.SetOwner(ref purchaser); Banker.Access().Receive(mortgageAmount); }
// Need to save the banker's current state as well private static void SaveBanker() { Stream testFileStream = File.Create("SavedBanker.bin"); var serializer = new BinaryFormatter(); serializer.Serialize(testFileStream, Banker.Access()); testFileStream.Close(); }
public override string LandOn(ref Player player) { if ((GetOwner() != Banker.Access()) && (GetOwner() != player)) { PayRent(ref player); return(string.Format("You rolled a total of {0}. So your rent is {0} x {1} = ${2}", player.GetLastMove(), _rentMultiplier, (player.GetLastMove() * _rentMultiplier))); } else { return(base.LandOn(ref player)); } }
public void SellHouse() { // Owner receives half the house cost from banker var halfHouseCost = HouseCost / 2; Owner.Receive(halfHouseCost); Banker.Access().Pay(halfHouseCost); // Board gets house back Board.Access().Houses++; // Property loses the house HouseCount--; }
public override string LandOn(ref Player player) { if ((GetOwner() != Banker.Access()) && (GetOwner() != player)) { //pay rent PayRent(ref player); return(base.LandOn(ref player) + string.Format("\nRent has been paid for {0} of ${1} to {2}", GetName(), GetRent(), Owner.GetName())); } else { return(base.LandOn(ref player)); } }
public bool MortgageProperty() { // Property must be undeveloped and can't // already be mortagaged if (GetHouseCount() != 0 || IsMortgaged) { return(false); } IsMortgaged = true; Banker.Access().Pay(MortgageValue); Owner.Receive(MortgageValue); return(true); }
public bool UnmortgageProperty() { // Property must be mortgaged if (!IsMortgaged) { return(false); } var mortgageValuePlus10PercentInterest = MortgageValue + (MortgageValue * 10 / 100); Owner.Pay(mortgageValuePlus10PercentInterest); Banker.Access().Receive(mortgageValuePlus10PercentInterest); IsMortgaged = false; return(true); }
public override void CheckBankrupt() { if (GetBalance() <= 0) { if (PlayerBankrupt != null) { PlayerBankrupt(this, new EventArgs()); var banker = Banker.Access(); foreach (Property property in GetPropertiesOwnedFromBoard()) { property.SetOwner(ref banker); } } _isActive = false; } }
/// <summary> /// Loads a saved instance of Board from the SavedBoard.bin file /// </summary> /// <returns>The board instance</returns> public Board ReadBoardFromBin() { const string fileName = "SavedBoard.bin"; Board board = null; if (File.Exists(fileName)) { Stream testFileStream = File.OpenRead(fileName); var deserializer = new BinaryFormatter(); board = (Board)deserializer.Deserialize(testFileStream); testFileStream.Close(); /* * We need to set the properties on the board that * were owned by the banker originally to be the banker * again when reloading the properties */ foreach (var property in board.GetProperties()) { var prop = (Property)property; var banker = Banker.Access(); if (prop.GetOwner().GetName() != "Leeroy Jenkins") { continue; } // If it's attached to leeroy who is the banker then // set that propety to be owned by the actual banker var banksProperty = board.GetProperty(prop.GetName()); banksProperty.SetOwner(ref banker); } } return(board); }
public Utility(string name) { Name = name; Owner = Banker.Access(); }
public override bool AvailableForPurchase() { // Only if banker owns the property is it available for purchase return(Owner == Banker.Access()); }
public override decimal GetRent() { // Mortgaged properties cannot have rent collected on them if (IsMortgaged) { return(0); } // This is the rent value for a property with a hotel if (HasHotel) { return(Rent + (Rent * 5)); } // The rent is double if the owner owns all the properties of this colour and the property is undeveloped (exclude the banker) if ((Board.Access().GetAllPropertiesOfColour(HouseColour).All(x => x.Owner == Owner && Owner != Banker.Access())) && (HouseCount == 0)) { return(Rent * 2); } // The rent multiplier is dependent on if the property // is at the hotel stage or not yet return(Rent + (Rent * HouseCount)); }
public Property(string name) { Name = name; Owner = Banker.Access(); }