public static void MortgageUtility(UtilityTile utlity) { // Check if property can be mortgaged first - No houses and not already mortgaged if (!utlity.MortgageStatus) { utlity.MortgageStatus = true; // Set mortgage status to True utlity.Owner.BankPaysPlayer(utlity.getMortgageValue); // Pay the owner of the property the mortgage value of the property } else Game1.debugMessageQueue.addMessageToQueue("Warning: Utility cannot be mortgaged"); }
public static void UnmortgageUtility(UtilityTile utility) { // Check if property is mortgaged if (utility.MortgageStatus) { int payment = (int)(utility.getMortgageValue * 1.1f); // Calculate mortgage + 10% interest utility.Owner.PlayerPaysBank(payment); // Pay bank amount } else { Game1.debugMessageQueue.addMessageToQueue("Warning: Utility cannot be unmortgaged"); } }
public static void MortgageUtility(UtilityTile utlity) { // Check if property can be mortgaged first - No houses and not already mortgaged if (!utlity.MortgageStatus) { utlity.MortgageStatus = true; // Set mortgage status to True utlity.Owner.BankPaysPlayer(utlity.getMortgageValue); // Pay the owner of the property the mortgage value of the property } else { Game1.debugMessageQueue.addMessageToQueue("Warning: Utility cannot be mortgaged"); } }
public bool PurchaseUtility(UtilityTile utility) { if (Money >= utility.getPropertyPrice) { Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" purchased \"" + utility.getName + "\" for $" + utility.getPropertyPrice); removeMoney(utility.getPropertyPrice); utility.Owner = this; netWorth += utility.getPropertyPrice; return(true); } else { Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" does not have enough to purchase \"" + utility.getName + "\""); return(false); } }
public void InitializeTiles(Tile[] tiles) { // This probably isn't the most efficient way of creating the Tiles, // But it'll only be run once at the start of a game. // XML Reading Variables XmlReader xmlReader; xmlReader = XmlReader.Create("GameData/PropertyCards.xml"); // Set the XML file to read // First, reserve spots in array for non-property Tiles tiles[0] = new Tile("Go", TileType.Go); tiles[5] = new Tile("Special Luxury", TileType.SpecialLuxuryTax); tiles[8] = new Tile("Chance", TileType.Chance); tiles[12] = new Tile("Hello Baby", TileType.Jail); tiles[15] = new UtilityTile("Soshi Bond"); tiles[20] = new Tile("Community Chest", TileType.CommunityChest); tiles[24] = new Tile("Fan Meeting", TileType.FanMeeting); tiles[27] = new Tile("Chance", TileType.Chance); tiles[33] = new UtilityTile("Forever 9"); tiles[36] = new Tile("Babysit Kyung San", TileType.GoToJail); tiles[40] = new Tile("Community Chest", TileType.CommunityChest); tiles[45] = new Tile("Shopping Spree", TileType.ShoppingSpree); // Fill in the gaps with Colored Property Tiles int counter = 0; // Keep track of current location in array Color currentColor = Color.White; // Keep track of current Color in XML string currentTileName = ""; // Keep track of current Tile Name string currentMember = ""; // Name of SNSD member who owns the Property int currentBaseRent = 0; // Rent int currentHouse1Rent = 0; // Rent with 1 House int currentHouse2Rent = 0; // Rent with 2 Houses int currentHouse3Rent = 0; // Rent with 3 Houses int currentHouse4Rent = 0; // Rent with 4 Houses int currentHotelRent = 0; // Rent with Hotel int currentMortgageValue = 0; // Mortgage Value int currentHouseCost = 0; // Cost for each house int currentHotelCost = 0; // Cost for Hotel (+ 4 houses) int currentPropertyPrice = 0; // Cost to initially purchase property int propertyCardInfoCounter = 0; // This is a counter to ensure that the current property card has read all the required data // Read in XML data for Properties while (xmlReader.Read()) { XmlNodeType nodeType = xmlReader.NodeType; if (nodeType == XmlNodeType.Element) { switch (xmlReader.Name) { // If the current element is a Color case "Color": // Checks if there is only one attribute // THIS MUST BE TRUE! Otherwise the XML structure is wrong if (xmlReader.AttributeCount == 1) { try { currentColor = getColorFromNumber(Convert.ToInt16(xmlReader.GetAttribute(0))); } catch (Exception e) { Console.Error.WriteLine("Warning: Invalid color value in XML file. " + " ERROR: " + e.Message); } } else { Console.Error.WriteLine("Warning: Color in XML file is missing attribute value"); } break; // If the current element is a Tile case "Tile": if (xmlReader.AttributeCount == 1) { try { currentTileName = xmlReader.GetAttribute(0); propertyCardInfoCounter++; } catch (Exception e) { Console.Error.WriteLine("Warning: Invalid string value in XML file. " + " ERROR: " + e.Message); } } else { Console.Error.WriteLine("Warning: Tile in XML file is missing attribute value"); } break; case "Member": currentMember = ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter); break; case "Rent": currentBaseRent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House1Rent": currentHouse1Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House2Rent": currentHouse2Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House3Rent": currentHouse3Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House4Rent": currentHouse4Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "Hotel": currentHotelRent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "Mortgage Value": currentMortgageValue = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "HouseCost": currentHouseCost = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "HotelCost": currentHotelCost = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "PropertyPrice": currentPropertyPrice = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); // Check if enough data has been pulled if (propertyCardInfoCounter == 11) { // Skip over pre-made tiles while (tiles[counter] != null) { counter++; } // Create the Tile tiles[counter] = new PropertyTile( TileType.Property, currentTileName, currentColor, currentBaseRent, currentHouse1Rent, currentHouse2Rent, currentHouse3Rent, currentHouse4Rent, currentHotelRent, currentMortgageValue, currentHouseCost, currentHotelCost, currentPropertyPrice); // Reset the Card Counter propertyCardInfoCounter = 0; } else { Console.Error.WriteLine("ERROR! Tile is missing data"); } break; } } } }
public void InitializeTiles(Tile[] tiles) { // This probably isn't the most efficient way of creating the Tiles, // But it'll only be run once at the start of a game. // XML Reading Variables XmlReader xmlReader; xmlReader = XmlReader.Create("GameData/PropertyCards.xml"); // Set the XML file to read // First, reserve spots in array for non-property Tiles tiles[0] = new Tile("Go", TileType.Go); tiles[5] = new Tile("Special Luxury", TileType.SpecialLuxuryTax); tiles[8] = new Tile("Chance", TileType.Chance); tiles[12] = new Tile("Hello Baby", TileType.Jail); tiles[15] = new UtilityTile("Soshi Bond"); tiles[20] = new Tile("Community Chest", TileType.CommunityChest); tiles[24] = new Tile("Fan Meeting", TileType.FanMeeting); tiles[27] = new Tile("Chance", TileType.Chance); tiles[33] = new UtilityTile("Forever 9"); tiles[36] = new Tile("Babysit Kyung San", TileType.GoToJail); tiles[40] = new Tile("Community Chest", TileType.CommunityChest); tiles[45] = new Tile("Shopping Spree", TileType.ShoppingSpree); // Fill in the gaps with Colored Property Tiles int counter = 0; // Keep track of current location in array Color currentColor = Color.White; // Keep track of current Color in XML string currentTileName = ""; // Keep track of current Tile Name string currentMember = ""; // Name of SNSD member who owns the Property int currentBaseRent = 0; // Rent int currentHouse1Rent = 0; // Rent with 1 House int currentHouse2Rent = 0; // Rent with 2 Houses int currentHouse3Rent = 0; // Rent with 3 Houses int currentHouse4Rent = 0; // Rent with 4 Houses int currentHotelRent = 0; // Rent with Hotel int currentMortgageValue = 0; // Mortgage Value int currentHouseCost = 0; // Cost for each house int currentHotelCost = 0; // Cost for Hotel (+ 4 houses) int currentPropertyPrice = 0; // Cost to initially purchase property int propertyCardInfoCounter = 0; // This is a counter to ensure that the current property card has read all the required data // Read in XML data for Properties while (xmlReader.Read()) { XmlNodeType nodeType = xmlReader.NodeType; if (nodeType == XmlNodeType.Element) { switch (xmlReader.Name) { // If the current element is a Color case "Color": // Checks if there is only one attribute // THIS MUST BE TRUE! Otherwise the XML structure is wrong if (xmlReader.AttributeCount == 1) { try { currentColor = getColorFromNumber(Convert.ToInt16(xmlReader.GetAttribute(0))); } catch (Exception e) { Console.Error.WriteLine("Warning: Invalid color value in XML file. " + " ERROR: " + e.Message); } } else Console.Error.WriteLine("Warning: Color in XML file is missing attribute value"); break; // If the current element is a Tile case "Tile": if (xmlReader.AttributeCount == 1) { try { currentTileName = xmlReader.GetAttribute(0); propertyCardInfoCounter++; } catch (Exception e) { Console.Error.WriteLine("Warning: Invalid string value in XML file. " + " ERROR: " + e.Message); } } else Console.Error.WriteLine("Warning: Tile in XML file is missing attribute value"); break; case "Member": currentMember = ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter); break; case "Rent": currentBaseRent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House1Rent": currentHouse1Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House2Rent": currentHouse2Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House3Rent": currentHouse3Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "House4Rent": currentHouse4Rent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "Hotel": currentHotelRent = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "Mortgage Value": currentMortgageValue = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "HouseCost": currentHouseCost = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "HotelCost": currentHotelCost = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); break; case "PropertyPrice": currentPropertyPrice = Convert.ToUInt16(ReadStringFromCurrentNode(xmlReader, ref propertyCardInfoCounter)); // Check if enough data has been pulled if (propertyCardInfoCounter == 11) { // Skip over pre-made tiles while (tiles[counter] != null) counter++; // Create the Tile tiles[counter] = new PropertyTile( TileType.Property, currentTileName, currentColor, currentBaseRent, currentHouse1Rent, currentHouse2Rent, currentHouse3Rent, currentHouse4Rent, currentHotelRent, currentMortgageValue, currentHouseCost, currentHotelCost, currentPropertyPrice); // Reset the Card Counter propertyCardInfoCounter = 0; } else Console.Error.WriteLine("ERROR! Tile is missing data"); break; } } } }
public static void UnmortgageUtility(UtilityTile utility) { // Check if property is mortgaged if (utility.MortgageStatus) { int payment = (int)(utility.getMortgageValue * 1.1f); // Calculate mortgage + 10% interest utility.Owner.PlayerPaysBank(payment); // Pay bank amount } else Game1.debugMessageQueue.addMessageToQueue("Warning: Utility cannot be unmortgaged"); }
private void PlayerOptions(Player player) { int currentTile = player.CurrentBoardPosition; TileType currentTileType = Tiles[currentTile].getTileType; optionPurchaseOrAuctionProperty = false; optionDevelopProperty = false; // Determine Player Options and take any actions required switch (currentTileType) { case TileType.Property: PropertyTile currentProperty = (PropertyTile)Tiles[currentTile]; if (currentProperty.Owner == null) // If the property is not owned yet { optionPurchaseOrAuctionProperty = true; } else if (currentProperty.Owner != player && !currentProperty.MortgageStatus) // If the property is owned by another player and not mortgaged { if (player.getMoney >= currentProperty.getRent) // Check if the player has enough money to pay Rent { player.CurrentPlayerPaysPlayer(currentProperty.Owner, currentProperty.getRent); // Pay rent turnPhase = 2; // Go to next phase } else { optionPromptMortgageOrTrade = true; // Player must decide to mortgage or trade to get money } } else { // Otherwise, player landed on his or her own property, so go to next phase turnPhase = 2; } break; case TileType.Utility: UtilityTile currentUtility = (UtilityTile)Tiles[currentTile]; UtilityTile otherUtility; if (currentTile == 15) { otherUtility = (UtilityTile)Tiles[33]; } else { otherUtility = (UtilityTile)Tiles[15]; } if (currentUtility.Owner == null) // If the property is not owned yet { optionPurchaseOrAuctionUtility = true; } else if (currentUtility.Owner != player && !currentUtility.MortgageStatus) // If the property is owned by another player { int utilityRent; // Calculate the amount to pay for Utility Rent if (currentUtility.Owner == otherUtility.Owner) // Check if player owns both utilities { utilityRent = (int)currentDiceRoll * 10; } else { utilityRent = (int)currentDiceRoll * 4; } if (player.getMoney >= utilityRent) // Check if the player has enough money to pay Rent { player.CurrentPlayerPaysPlayer(currentUtility.Owner, utilityRent); // Pay rent turnPhase = 2; // Go to next phase } else { optionPromptMortgageOrTrade = true; // Player must decide to mortgage or trade to get money } } else { // Otherwise, player landed on his or her own property, so go to next phase turnPhase = 2; } break; case TileType.Chance: Card drawnChanceCard = ChanceCards.drawCard(); // Draw the Chance card SoshiLandGameFunctions.FollowCardInstructions(drawnChanceCard, player, ListOfPlayers); turnPhase = 2; break; case TileType.CommunityChest: Card drawnCommunityChestCard = CommunityChestCards.drawCard(); // Draw the Community Chest card SoshiLandGameFunctions.FollowCardInstructions(drawnCommunityChestCard, player, ListOfPlayers); turnPhase = 2; break; case TileType.FanMeeting: turnPhase = 2; // Nothing happens, so go to last phase break; case TileType.Jail: turnPhase = 2; // Nothing happens, so go to last phase break; case TileType.ShoppingSpree: currentTurnsPlayers.PlayerPaysBank(75); // Pay Bank taxes turnPhase = 2; break; case TileType.SpecialLuxuryTax: Game1.debugMessageQueue.addMessageToQueue("Player " + "\"" + currentTurnsPlayers.getName + "\"" + " must choose to pay 10% of net worth, or $200"); Game1.debugMessageQueue.addMessageToQueue("Press K to pay 10% of net worth, or L to pay $200"); optionPromptLuxuryTax = true; break; case TileType.GoToJail: SoshiLandGameFunctions.MovePlayerToJail(player); break; case TileType.Go: turnPhase = 2; break; } optionsCalculated = true; if (Game1.DEBUG) { string optionsMessage = "Options Available: Trade,"; if (optionDevelopProperty) { optionsMessage = optionsMessage + " Develop,"; } if (optionPurchaseOrAuctionProperty || optionPurchaseOrAuctionUtility) { optionsMessage = optionsMessage + " Purchase/Auction"; } Game1.debugMessageQueue.addMessageToQueue(optionsMessage); } }
public bool PurchaseUtility(UtilityTile utility) { if (Money >= utility.getPropertyPrice) { Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" purchased \"" + utility.getName + "\" for $" + utility.getPropertyPrice); removeMoney(utility.getPropertyPrice); utility.Owner = this; netWorth += utility.getPropertyPrice; return true; } else { Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" does not have enough to purchase \"" + utility.getName + "\""); return false; } }