From 4457d51f0778c8868b7e19f3e5a7be3f759c9772 Mon Sep 17 00:00:00 2001 From: bobloy Date: Tue, 6 Oct 2020 17:36:36 -0400 Subject: [PATCH] More WIP conquest --- conquest/__init__.py | 2 +- conquest/conquest.py | 6 ++++-- conquest/conquestgame.py | 19 +++++++++++++++++++ conquest/regioner.py | 25 ------------------------- 4 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 conquest/conquestgame.py diff --git a/conquest/__init__.py b/conquest/__init__.py index e190e58..1466d52 100644 --- a/conquest/__init__.py +++ b/conquest/__init__.py @@ -8,4 +8,4 @@ async def setup(bot): data_manager.bundled_data_path(cog) await cog.load_data() - bot.add_cog(cog) \ No newline at end of file + bot.add_cog(cog) diff --git a/conquest/conquest.py b/conquest/conquest.py index f68857b..ebc59eb 100644 --- a/conquest/conquest.py +++ b/conquest/conquest.py @@ -60,7 +60,7 @@ class Conquest(commands.Cog): self.ext = "PNG" self.ext_format = "PNG" - self.mm: Union[MapMaker, None] = None + self.mm: Optional[MapMaker] = None async def red_delete_data_for_user(self, **kwargs): """Nothing to delete""" @@ -92,7 +92,9 @@ class Conquest(commands.Cog): map_name = map_data["map_name"] map_path = self._path_if_custom(map_data["is_custom"]) / map_name - self.current_maps[guild.id] = ConquestGame(map_path, map_name, self.current_map_folder / map_name) + self.current_maps[guild.id] = ConquestGame( + map_path, map_name, self.current_map_folder / map_name + ) async def current_map_load(self): map_path = self._path_if_custom() diff --git a/conquest/conquestgame.py b/conquest/conquestgame.py new file mode 100644 index 0000000..c2775be --- /dev/null +++ b/conquest/conquestgame.py @@ -0,0 +1,19 @@ +import pathlib + +from conquest.regioner import ConquestMap + + +class ConquestGame: + def __init__(self, map_path: pathlib.Path, game_name: str, custom_map_path: pathlib.Path): + super().__init__(custom_map_path / game_name) + self.blank_map = ConquestMap(map_path) + self.game_name = game_name + self.custom_map_path = custom_map_path + + async def save_region(self, region): + if not self.custom: + return False + pass # TODO: region data saving + + async def start_game(self): + pass diff --git a/conquest/regioner.py b/conquest/regioner.py index 652696d..06ec39c 100644 --- a/conquest/regioner.py +++ b/conquest/regioner.py @@ -260,31 +260,6 @@ class ConquestMap: return current_numbered_img -class ConquestGame(ConquestMap): - def __init__(self, map_path: pathlib.Path, game_name: str, custom_map_path: pathlib.Path): - super().__init__(map_path) - self.game_name = game_name - self.custom_map_path = custom_map_path - self.game_path = custom_map_path / game_name - - def game_data_path(self): - return self.game_path / "data.json" - - def game_current_path(self): - return self.game_path / "current.png" - - def game_current_numbered_path(self): - return self.game_path / "current_numbered.png" - - async def save_region(self, region): - if not self.custom: - return False - pass # TODO: region data saving - - async def start_game(self): - pass - - class MapMaker(ConquestMap): async def change_name(self, new_name: str, new_path: pathlib.Path): if new_path.exists() and new_path.is_dir():