diff options
Diffstat (limited to 'diplomacy/engine')
-rw-r--r-- | diplomacy/engine/game.py | 4 | ||||
-rw-r--r-- | diplomacy/engine/map.py | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/diplomacy/engine/game.py b/diplomacy/engine/game.py index 8da3480..5f0bb2e 100644 --- a/diplomacy/engine/game.py +++ b/diplomacy/engine/game.py @@ -79,8 +79,8 @@ class Game(Jsonable): e.g. {'PAR': 'FRANCE'} to indicate that PAR was lost by France (previous owner) - map: Contains a reference to the current map (Map instance) e.g. map = Map('standard') - - map_name: Contains a reference to the name of the map that was loaded - e.g. map_name = 'standard' + - map_name: Contains a reference to the name of the map that was loaded (or a full path to a custom map file) + e.g. map_name = 'standard' or map_name = '/some/path/to/file.map' - messages (only for non-observer games): history of messages exchanged inside this game. Sorted dict mapping message timestamps to message objects (instances of diplomacy.Message). Format: {message.time_sent => message} diff --git a/diplomacy/engine/map.py b/diplomacy/engine/map.py index 13d430b..65bcdfa 100644 --- a/diplomacy/engine/map.py +++ b/diplomacy/engine/map.py @@ -74,8 +74,8 @@ class Map(): e.g. {'MAO': 'WATER', 'SER': 'LAND', 'SYR': 'COAST', 'MOS': 'LAND', 'VEN': 'COAST', ... } - locs: List of 3 letter locations (With coasts) e.g. ['ADR', 'AEG', 'ALB', 'ANK', 'APU', 'ARM', 'BAL', 'BAR', 'BEL', 'BER', ... ] - - name: Name of the map - e.g. 'standard' + - name: Name of the map (or full path to a custom map file) + e.g. 'standard' or '/some/path/to/file.map' - own_word: Dict to indicate the word used to refer to people living in each power's country e.g. {'RUSSIA': 'RUSSIAN', 'FRANCE': 'FRENCH', 'UNOWNED': 'UNOWNED', 'TURKEY': 'TURKISH', ... } - owns: List that indicates which power have a OWNS or CENTERS line @@ -128,7 +128,7 @@ class Map(): def __init__(self, name='standard', use_cache=True): """ Constructor function - :param name: Name of the map to load + :param name: Name of the map to load (or full path to a custom map file) :param use_cache: Boolean flag to indicate we want a blank object that doesn't use cache """ if name in MAP_CACHE: @@ -302,8 +302,13 @@ class Map(): # Otherwise file_name is the file handler power = 0 if file_name is None: - file_name = '{}.map'.format(self.name) - file_path = os.path.join(settings.PACKAGE_DIR, 'maps', file_name) + file_name = '{}.map'.format(self.name) if not self.name.endswith('.map') else self.name + + # If file_name is a path to a custom map, we use that path, otherwise, we check in the maps folder + if os.path.exists(file_name): + file_path = file_name + else: + file_path = os.path.join(settings.PACKAGE_DIR, 'maps', file_name) # Checking if file exists: found_map = 1 if os.path.exists(file_path) else 0 |