def generate_name(self, number, direction): """Generate a street name.""" config = self.city.game.config number_to_ordinal = { 1: '1st', 2: '2nd', 3: '3rd', 4: '4th', 5: '5th', 6: '6th', 7: '7th', 8: '8th', 9: '9th' } if direction == 'E' or direction == 'W': street_type = 'Street' if random.random() < config.chance_street_gets_numbered_name: name = number_to_ordinal[number] else: if random.random() < 0.5: name = Names.any_surname() else: name = Names.a_place_name() else: street_type = 'Avenue' if random.random() < config.chance_avenue_gets_numbered_name: name = number_to_ordinal[number] else: if random.random() < 0.5: name = Names.any_surname() else: name = Names.a_place_name() # name = "{0} {1} {2}".format(name, street_type, direction) name = "{0} {1}".format(name, street_type) return name
def generate_name(number, direction): """Generate a street name.""" number_to_ordinal = { 1: '1st', 2: '2nd', 3: '3rd', 21: '21st', 22: '22nd', 23: '23rd', 31: '31st', 32: '32nd', 33: '33rd', 41: '41st', 42: '42nd', 43: '43rd', } if number in number_to_ordinal: ordinal = number_to_ordinal[number] else: ordinal = str(number) + 'th' if direction == 'ew': street_type = 'Street' if random.random() < CONFIG.chance_street_gets_numbered_name: name = ordinal else: if random.random() < 0.5: name = Names.any_surname() else: name = Names.a_place_name() else: street_type = 'Avenue' if random.random() < CONFIG.chance_avenue_gets_numbered_name: name = ordinal else: if random.random() < 0.5: name = Names.any_surname() else: name = Names.a_place_name() name = "{0} {1}".format(name, street_type) return name