Ejemplo n.º 1
0
        public bool PurchaseProperty(PropertyTile property)
        {
            if (Money >= property.getPropertyPrice)
            {
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" purchased \"" + property.getName + "\" for $" + property.getPropertyPrice);

                removeMoney(property.getPropertyPrice);
                property.Owner = this;
                netWorth      += property.getPropertyPrice;
                return(true);
            }
            else
            {
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" does not have enough to purchase \"" + property.getName + "\"");
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool UnmortgageProperty(PropertyTile property)
        {
            // Calculate unmortgage value (110% of mortgage price
            int newPrice = (int)Math.Round(property.getMortgageValue * 1.1);

            if (Money >= newPrice)                  // Check if player has enough money to unmortgage
            {
                PlayerPaysBank(newPrice);           // Pay bank
                property.MortgageStatus = false;    // Unmortgage house
                return(true);
            }
            else
            {
                // Player cannot unmortgage
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + getName + "\" does not have enough money to unmortgage " + property.getName);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool MortgageProperty(PropertyTile property)
        {
            // Check if property has zero houses
            if (property.getNumberOfHouses == 0)
            {
                property.MortgageStatus = true;                 // Set the property to mortgaged
                BankPaysPlayer(property.getMortgageValue);      // Give player money equal to mortgage value
                netWorth -= property.getMortgageValue;          // Set net worth back before it was mortgaged (net worth shouldn't change)

                return(true);
            }
            else
            {
                // Player cannot mortgage
                Game1.debugMessageQueue.addMessageToQueue("Cannot mortgage " + property.getName + " when there are still houses.");
                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool MortgageProperty(PropertyTile property)
        {
            // Check if property has zero houses
            if (property.getNumberOfHouses == 0)
            {
                property.MortgageStatus = true;                 // Set the property to mortgaged
                BankPaysPlayer(property.getMortgageValue);      // Give player money equal to mortgage value
                netWorth -= property.getMortgageValue;          // Set net worth back before it was mortgaged (net worth shouldn't change)

                return true;
            }
            else
            {
                // Player cannot mortgage
                Game1.debugMessageQueue.addMessageToQueue("Cannot mortgage " + property.getName + " when there are still houses.");
                return false;
            }
        }
Ejemplo n.º 5
0
        public bool UnmortgageProperty(PropertyTile property)
        {
            // Calculate unmortgage value (110% of mortgage price
            int newPrice = (int)Math.Round(property.getMortgageValue * 1.1);

            if (Money >= newPrice)                  // Check if player has enough money to unmortgage
            {
                PlayerPaysBank(newPrice);           // Pay bank
                property.MortgageStatus = false;    // Unmortgage house
                return true;
            }
            else
            {
                // Player cannot unmortgage
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + getName + "\" does not have enough money to unmortgage " + property.getName);
                return false;
            }
        }
Ejemplo n.º 6
0
        public bool PurchaseProperty(PropertyTile property)
        {
            if (Money >= property.getPropertyPrice)
            {
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" purchased \"" + property.getName + "\" for $" + property.getPropertyPrice);

                removeMoney(property.getPropertyPrice);
                property.Owner = this;
                netWorth += property.getPropertyPrice;
                return true;
            }
            else
            {
                Game1.debugMessageQueue.addMessageToQueue("Player \"" + this.getName + "\" does not have enough to purchase \"" + property.getName + "\"");
                return false;
            }
        }
Ejemplo n.º 7
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        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;
                    }

                }
            }
        }