/// <summary>
        /// Allows players check to see if they can buy a property
        /// </summary>
        /// <param name="p">Player Callee</param>
        /// <returns></returns>
        public bool canBuy(Player p)
        {
            Game_Tile t = playersCurrentTile[p.index];

            if (tileOwners[t.index] == null && playersMoney[p.index] >= t.price && t.canBuy)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 public Game_Tile_Safe(Game_Tile t)
 {
     name                 = t.name;
     price                = t.price;
     rents                = t.rents;
     assets               = t.assets;
     assetPrice           = t.assetPrice;
     mortgaged            = t.mortgaged;
     utility              = t.utility;
     railroad             = t.railroad;
     color                = t.color;
     index                = t.index;
     associatedProperties = t.associatedProperties;
 }
        /// <summary>
        /// Lets players attempt to buy a property
        /// </summary>
        /// <param name="p"></param>
        /// <returns>true if purchase is successful, false otherwise</returns>
        public bool buyProperty(Player p)
        {
            Game_Tile t = playersCurrentTile[p.index];

            if (tileOwners[t.index] == null && playersMoney[p.index] >= t.price && t.canBuy)
            {
                payPlayer(p, -t.price);
                tileOwners[t.index] = p;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void populateBoard()
        {
            Game_Tile tile = new Game_Tile(this, board.Count, "none", "Start", 0, 0, new int[] { 0 }, false);

            board.Add(tile);
            List <int> associatedProperties = new List <int>();

            associatedProperties.Add(3);
            tile = new Game_Tile(this, board.Count, "purple", "Mediterranean Avenue", 60, 50, new int[] { 2, 10, 30, 90, 160, 250 }, true, associatedProperties);
            board.Add(tile);

            tile = new Game_Tile(this, board.Count, "none", "Community Chest", 0, 0, new int[] { 0 }, false);
            board.Add(tile);
            associatedProperties.Clear();
            associatedProperties.Add(1);

            tile = new Game_Tile(this, board.Count, "purple", "Baltic Avenue", 60, 50, new int[] { 4, 20, 60, 180, 320, 450 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Income Tax", 0, 0, new int[] { 0 }, false);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "rail", "Reading Railroad", 200, 0, new int[] { 25, 50, 100, 200 }, true, false, true);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(8);
            associatedProperties.Add(9);
            tile = new Game_Tile(this, board.Count, "light blue", "Oriental Avenue", 100, 50, new int[] { 6, 30, 90, 270, 400, 550 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Chance", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(6);
            associatedProperties.Add(9);
            tile = new Game_Tile(this, board.Count, "light blue", "Vermont Avenue", 100, 50, new int[] { 6, 30, 90, 270, 400, 550 }, true, associatedProperties);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(6);
            associatedProperties.Add(8);
            tile = new Game_Tile(this, board.Count, "light blue", "Connecticut Avenue", 120, 60, new int[] { 8, 40, 100, 300, 450, 600 }, true, associatedProperties);
            board.Add(tile);


            tile = new Game_Tile(this, board.Count, "none", "Jail", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(13);
            associatedProperties.Add(14);
            tile = new Game_Tile(this, board.Count, "pink", "St. Charles Place", 140, 100, new int[] { 10, 50, 150, 450, 625, 750 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Electric Company", 150, 0, new int[] { 0 }, true, true, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(11);
            associatedProperties.Add(14);
            tile = new Game_Tile(this, board.Count, "pink", "States Avenue", 140, 100, new int[] { 10, 50, 150, 450, 625, 750 }, true, associatedProperties);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(11);
            associatedProperties.Add(13);
            tile = new Game_Tile(this, board.Count, "pink", "Virginia Avenue", 160, 100, new int[] { 12, 60, 180, 500, 700, 900 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "rail", "Pennsylvania Railroad", 200, 0, new int[] { 25, 50, 100, 200 }, true, false, true);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(19);
            associatedProperties.Add(18);
            tile = new Game_Tile(this, board.Count, "orange", "St. James Place", 180, 100, new int[] { 14, 70, 200, 550, 750, 950 }, true, associatedProperties);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(16);
            associatedProperties.Add(19);
            tile = new Game_Tile(this, board.Count, "orange", "Tennessee Avenue", 180, 100, new int[] { 14, 70, 200, 550, 750, 950 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Community Chest", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(18);
            associatedProperties.Add(16);
            tile = new Game_Tile(this, board.Count, "orange", "New York Avenue", 200, 100, new int[] { 16, 80, 220, 600, 800, 1000 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Free Parking", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(23);
            associatedProperties.Add(24);
            tile = new Game_Tile(this, board.Count, "red", "Kentucky Avenue", 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Chance", 0, 0, new int[] { 0 }, false);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(21);
            associatedProperties.Add(24);
            tile = new Game_Tile(this, board.Count, "red", "Indiana Avenue", 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 }, true, associatedProperties);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(23);
            associatedProperties.Add(21);
            tile = new Game_Tile(this, board.Count, "red", "Illinois Avenue", 240, 150, new int[] { 20, 100, 300, 750, 925, 1100 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "rail", "B & O Railroad", 200, 0, new int[] { 25, 50, 100, 200 }, true, false, true);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(27);
            associatedProperties.Add(29);
            tile = new Game_Tile(this, board.Count, "yellow", "Atlantic Avenue", 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 }, true, associatedProperties);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(26);
            associatedProperties.Add(29);
            tile = new Game_Tile(this, board.Count, "yellow", "Ventnor Avenue", 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 }, true, associatedProperties);
            board.Add(tile);

            tile = new Game_Tile(this, board.Count, "none", "Water Works", 150, 0, new int[] { 0 }, true, true, false);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(27);
            associatedProperties.Add(26);
            tile = new Game_Tile(this, board.Count, "yellow", "Marvin Gardens", 280, 150, new int[] { 24, 120, 360, 850, 1025, 1200 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Goto Jail", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(32);
            associatedProperties.Add(34);
            tile = new Game_Tile(this, board.Count, "green", "Pacific Avenue", 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 }, true, associatedProperties);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(31);
            associatedProperties.Add(34);
            tile = new Game_Tile(this, board.Count, "green", "North Carolina Avenue", 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 }, true, associatedProperties);
            board.Add(tile);

            tile = new Game_Tile(this, board.Count, "none", "Community Chest", 0, 0, new int[] { 0 }, false);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(32);
            associatedProperties.Add(31);
            tile = new Game_Tile(this, board.Count, "green", "Pennsylvania Avenue", 320, 200, new int[] { 28, 150, 450, 1000, 1200, 1400 }, true, associatedProperties);
            board.Add(tile);

            tile = new Game_Tile(this, board.Count, "rail", "Short Line Railroad", 200, 0, new int[] { 25, 50, 100, 200 }, true, false, true);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Chance", 0, 0, new int[] { 0 }, false);
            board.Add(tile);


            associatedProperties.Clear();
            associatedProperties.Add(39);
            tile = new Game_Tile(this, board.Count, "blue", "Park Place", 350, 200, new int[] { 35, 175, 500, 1100, 1300, 1500 }, true, associatedProperties);
            board.Add(tile);
            tile = new Game_Tile(this, board.Count, "none", "Free Parking", 0, 0, new int[] { 0 }, false);
            board.Add(tile);

            associatedProperties.Clear();
            associatedProperties.Add(37);
            tile = new Game_Tile(this, board.Count, "blue", "Boardwalk", 400, 200, new int[] { 50, 200, 600, 1400, 1700, 2000 }, true, associatedProperties);
            board.Add(tile);
        }