I am making a Monopoly game and am trying to make it easier for myself and less lines to determine where the character with.
I made a list to show the rents and values of each address
Here it is:
BoardDirectory = {
'GO': {'name': 'GO'},
'Old Kent Road': {'name': 'Old Kent Road', 'cost': 60, 'PerHotel': 50, 'SiteRent': 2, 'SiteRentWithColour': 4,
'HouseRent': {'OneHouse': 10, 'TwoHouse': 30, 'ThreeHouse': 90, 'FourHouse': 160, 'Hotel': 250},
'LocHouses': 0},
'Community Chest1': {'name': 'Community Chest'},
'Whitechapel Road': {'name': 'Whitechapel Road', 'cost': 60, 'PerHotel': 50, 'SiteRent': 4, 'SiteRentWithColour': 8,
'HouseRent': {'OneHouse': 20, 'TwoHouse': 60, 'ThreeHouse': 180, 'FourHouse': 320, 'Hotel': 450},
'LocHouses': 0},
'Income Tax': {'name': 'Kings Cross Station'},
'Kings Cross Station': {'name': 'Kings Cross Station'},
'The Angel, Islington': {'name': 'The Angel, Islington', 'cost': 100, 'PerHotel': 50, 'SiteRent': 6, 'SiteRentWithColour': 12,
'HouseRent': {'OneHouse': 30, 'TwoHouse': 90, 'ThreeHouse': 270, 'FourHouse': 400, 'Hotel': 550},
'LocHouses': 0},
'Chance1': {'name': 'Chance'},
'Euston Road': {'name': 'Euston Road', 'cost': 100, 'PerHotel': 50, 'SiteRent': 6, 'SiteRentWithColour': 12,
'HouseRent': {'OneHouse': 30, 'TwoHouse': 90, 'ThreeHouse': 270, 'FourHouse': 400, 'Hotel': 550},
'LocHouses': 0},
'Pentonville Road': {'name': 'Pentonville Road', 'cost': 120, 'PerHotel': 50, 'SiteRent': 8, 'SiteRentWithColour': 16,
'HouseRent': {'OneHouse': 40, 'TwoHouse': 100, 'ThreeHouse': 300, 'FourHouse': 450, 'Hotel': 600},
'LocHouses': 0},
'JAIL': {'name': 'JAIL'},
'Pall Mall': {'name': 'Pall Mall', 'cost': 140, 'PerHotel': 100, 'SiteRent': 10, 'SiteRentWithColour': 20,
'HouseRent': {'OneHouse': 50, 'TwoHouse': 150, 'ThreeHouse': 450, 'FourHouse': 625, 'Hotel': 750},
'LocHouses': 0},
'Electric Company': {'name': 'Electric Company'},
'Whitehall': {'name': 'Whitehall', 'cost': 140, 'PerHotel': 100, 'SiteRent': 10, 'SiteRentWithColour': 20,
'HouseRent': {'OneHouse': 50, 'TwoHouse': 150, 'ThreeHouse': 450, 'FourHouse': 625, 'Hotel': 750},
'LocHouses': 0},
'Northumberland Avenue': {'name': 'Northumberland Avenue', 'cost': 160, 'PerHotel': 100, 'SiteRent': 12, 'SiteRentWithColour': 24,
'HouseRent': {'OneHouse': 60, 'TwoHouse': 180, 'ThreeHouse': 500, 'FourHouse': 700, 'Hotel': 900},
'LocHouses': 0},
'Marylebone Station': {'name': 'Marylebone Station'},
'Bow Street': {'name': 'Bow Street', 'cost': 180, 'PerHotel': 100, 'SiteRent': 14, 'SiteRentWithColour': 28,
'HouseRent': {'OneHouse': 70, 'TwoHouse': 200, 'ThreeHouse': 550, 'FourHouse': 750, 'Hotel': 950},
'LocHouses': 0},
'Community Chest2': {'name': 'Community Chest2'},
'Marlborough Street': {'name': 'Marlborough Street', 'cost': 180, 'PerHotel': 100, 'SiteRent': 14, 'SiteRentWithColour': 28,
'HouseRent': {'OneHouse': 70, 'TwoHouse': 200, 'ThreeHouse': 550, 'FourHouse': 750, 'Hotel': 950},
'LocHouses': 0},
'Vine Street': {'name': 'Vine Street', 'cost': 200, 'PerHotel': 100, 'SiteRent': 16, 'SiteRentWithColour': 32,
'HouseRent': {'OneHouse': 80, 'TwoHouse': 220, 'ThreeHouse': 600, 'FourHouse': 800, 'Hotel': 1000},
'LocHouses': 0},
'Free Parking': {'name': 'Free Parking'},
'Strand': {'name': 'Strand', 'cost': 220, 'PerHotel': 150, 'SiteRent': 18, 'SiteRentWithColour': 36,
'HouseRent': {'OneHouse': 90, 'TwoHouse': 220, 'ThreeHouse': 700, 'FourHouse': 875, 'Hotel': 1050},
'LocHouses': 0},
'Chance2': {'name': 'Chance'},
'Fleet Street': {'name': 'Fleet Street', 'cost': 220, 'PerHotel': 150, 'SiteRent': 18, 'SiteRentWithColour': 36,
'HouseRent': {'OneHouse': 90, 'TwoHouse': 250, 'ThreeHouse': 700, 'FourHouse': 875, 'Hotel': 1100},
'LocHouses': 0},
'Trafalgar Square': {'name': 'Trafalgar Square', 'cost': 240, 'PerHotel': 150, 'SiteRent': 20, 'SiteRentWithColour': 40,
'HouseRent': {'OneHouse': 100, 'TwoHouse': 300, 'ThreeHouse': 750, 'FourHouse': 925, 'Hotel': 1150},
'LocHouses': 0},
'Fenchurch St Station': {'name': 'Fenchurch St Station'},
'Leicester Square': {'name': 'Leicester Square', 'cost': 260, 'PerHotel': 150, 'SiteRent': 22, 'SiteRentWithColour': 44,
'HouseRent': {'OneHouse': 110, 'TwoHouse': 330, 'ThreeHouse': 800, 'FourHouse': 975, 'Hotel': 1150},
'LocHouses': 0},
'Coventry Street': {'name': 'Coventry Street', 'cost': 260, 'PerHotel': 150, 'SiteRent': 22, 'SiteRentWithColour': 44,
'HouseRent': {'OneHouse': 110, 'TwoHouse': 330, 'ThreeHouse': 800, 'FourHouse': 975, 'Hotel': 1200},
'LocHouses': 0},
'Water Works': {'name': 'Water Works'},
'Piccadilly': {'name': 'Piccadilly', 'cost': 280, 'PerHotel': 150, 'SiteRent': 24, 'SiteRentWithColour': 48,
'HouseRent': {'OneHouse': 120, 'TwoHouse': 360, 'ThreeHouse': 850, 'FourHouse': 1025, 'Hotel': 1275},
'LocHouses': 0},
'Go To Jail': {'name': 'Go To Jail'},
'Regent Street': {'name': 'Regent Street', 'cost': 300, 'PerHotel': 200, 'SiteRent': 26, 'SiteRentWithColour': 52,
'HouseRent': {'OneHouse': 130, 'TwoHouse': 390, 'ThreeHouse': 900, 'FourHouse': 1100, 'Hotel': 1275},
'LocHouses': 0},
'Oxford Street': {'name': 'Oxford Street', 'cost': 300, 'PerHotel': 200, 'SiteRent': 26, 'SiteRentWithColour': 52,
'HouseRent': {'OneHouse': 130, 'TwoHouse': 390, 'ThreeHouse': 900, 'FourHouse': 1100, 'Hotel': 1400},
'LocHouses': 0},
'Community Chest': {'name': 'Community Chest'},
'Bond Street': {'name': 'Bond Street', 'cost': 320, 'PerHotel': 200, 'SiteRent': 28, 'SiteRentWithColour': 56,
'HouseRent': {'OneHouse': 150, 'TwoHouse': 450, 'ThreeHouse': 1000, 'FourHouse': 1200, 'Hotel': 1500},
'LocHouses': 0},
'Liverpool St Station': {'name': 'Liverpool St Station'},
'Chance3': {'name': 'Chance'},
'Park Lane': {'name': 'Park Lane', 'cost': 350, 'PerHotel': 200, 'SiteRent': 35, 'SiteRentWithColour': 70,
'HouseRent': {'OneHouse': 175, 'TwoHouse': 500, 'ThreeHouse': 1100, 'FourHouse': 1300, 'Hotel': 2000},
'LocHouses': 0,},
'Mayfair': {'name': 'Mayfair', 'cost': 400, 'PerHotel': 400, 'SiteRent': 50, 'SiteRentWithColour': 100,
'HouseRent': {'OneHouse': 200, 'TwoHouse': 600, 'ThreeHouse': 1400, 'FourHouse': 1700, 'Hotel': 250,},
'LocHouses': 0,},
}
I am trying to index it, so that it is easier to implement dice rolls to put you in a new location. The code I was trying to use is as follows:
1die = random.randrange(1, 7)
2die = random.randrange(1, 7)
DiceAmount = 1die + 2die
place = 0
place += DiceAmount
currentloc = BoardDirectory.index(place)
But because it is a dictionary it cannot be indexed.
Can anyone offer alternatives?