pull/198/merge
bobloy 4 years ago
parent 4183607372
commit 61fa006e33

@ -1,5 +1,6 @@
import asyncio import asyncio
import json import json
import logging
import os import os
import pathlib import pathlib
from abc import ABC from abc import ABC
@ -13,6 +14,8 @@ from redbot.core import Config, commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.data_manager import bundled_data_path, cog_data_path from redbot.core.data_manager import bundled_data_path, cog_data_path
log = logging.getLogger("red.fox_v3.conquest")
class Conquest(commands.Cog): class Conquest(commands.Cog):
""" """
@ -53,14 +56,20 @@ class Conquest(commands.Cog):
self.current_map = await self.config.current_map() self.current_map = await self.config.current_map()
if self.current_map: if self.current_map:
await self.current_map_load() if not await self.current_map_load():
await self.config.current_map.clear()
async def current_map_load(self): async def current_map_load(self):
map_data_path = self.asset_path / self.current_map / "data.json" map_data_path = self.asset_path / self.current_map / "data.json"
if not map_data_path.exists():
log.warning(f"{map_data_path} does not exist. Clearing current map")
return False
with map_data_path.open() as mapdata: with map_data_path.open() as mapdata:
self.map_data: dict = json.load(mapdata) self.map_data: dict = json.load(mapdata)
self.ext = self.map_data["extension"] self.ext = self.map_data["extension"]
self.ext_format = "JPEG" if self.ext.upper() == "JPG" else self.ext.upper() self.ext_format = "JPEG" if self.ext.upper() == "JPG" else self.ext.upper()
return True
@commands.group() @commands.group()
async def conquest(self, ctx: commands.Context): async def conquest(self, ctx: commands.Context):

@ -1,7 +1,7 @@
{ {
"maps": [ "maps": [
"simple_blank_map", "simple",
"test", "ck2",
"test2" "HoI"
] ]
} }
Loading…
Cancel
Save