|
|
@ -23,17 +23,7 @@ class Conquest(commands.Cog):
|
|
|
|
|
|
|
|
|
|
|
|
default_zoom_json = {"enabled": False, "x": -1, "y": -1, "zoom": 1.0}
|
|
|
|
default_zoom_json = {"enabled": False, "x": -1, "y": -1, "zoom": 1.0}
|
|
|
|
|
|
|
|
|
|
|
|
default_custom_map = {
|
|
|
|
default_maps_json = {"maps": []}
|
|
|
|
"name": "",
|
|
|
|
|
|
|
|
"regions": {},
|
|
|
|
|
|
|
|
"region_max": 0,
|
|
|
|
|
|
|
|
"extension": "png",
|
|
|
|
|
|
|
|
"custom": True,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default_maps_json = {
|
|
|
|
|
|
|
|
"maps": []
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, bot: Red):
|
|
|
|
def __init__(self, bot: Red):
|
|
|
|
super().__init__()
|
|
|
|
super().__init__()
|
|
|
@ -64,8 +54,9 @@ class Conquest(commands.Cog):
|
|
|
|
self.is_custom = False
|
|
|
|
self.is_custom = False
|
|
|
|
self.current_map = None
|
|
|
|
self.current_map = None
|
|
|
|
self.map_data = None
|
|
|
|
self.map_data = None
|
|
|
|
self.ext = None
|
|
|
|
|
|
|
|
self.ext_format = None
|
|
|
|
self.ext = "PNG"
|
|
|
|
|
|
|
|
self.ext_format = "PNG"
|
|
|
|
|
|
|
|
|
|
|
|
self.mm: Union[ConquestMap, None] = None
|
|
|
|
self.mm: Union[ConquestMap, None] = None
|
|
|
|
|
|
|
|
|
|
|
@ -100,8 +91,6 @@ class Conquest(commands.Cog):
|
|
|
|
print(e)
|
|
|
|
print(e)
|
|
|
|
await self.config.current_map.set(None)
|
|
|
|
await self.config.current_map.set(None)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
self.ext = self.map_data["extension"]
|
|
|
|
|
|
|
|
self.ext_format = "JPEG" if self.ext.upper() == "JPG" else self.ext.upper()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _get_current_map_path(self):
|
|
|
|
async def _get_current_map_path(self):
|
|
|
|
return self.current_map_folder / self.current_map
|
|
|
|
return self.current_map_folder / self.current_map
|
|
|
@ -136,7 +125,7 @@ class Conquest(commands.Cog):
|
|
|
|
im = Image.open(current_img_path)
|
|
|
|
im = Image.open(current_img_path)
|
|
|
|
async with ctx.typing():
|
|
|
|
async with ctx.typing():
|
|
|
|
out: Image.Image = await composite_regions(
|
|
|
|
out: Image.Image = await composite_regions(
|
|
|
|
im, regions, color, self._path_if_custom() / self.current_map
|
|
|
|
im, regions, color, self._path_if_custom() / self.current_map / "masks"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
out.save(current_img_path, self.ext_format)
|
|
|
|
out.save(current_img_path, self.ext_format)
|
|
|
|
await self._send_maybe_zoomed_map(ctx, current_img_path, f"map.{self.ext}")
|
|
|
|
await self._send_maybe_zoomed_map(ctx, current_img_path, f"map.{self.ext}")
|
|
|
@ -152,6 +141,19 @@ class Conquest(commands.Cog):
|
|
|
|
if ctx.invoked_subcommand is None:
|
|
|
|
if ctx.invoked_subcommand is None:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mapmaker.command(name="numbers")
|
|
|
|
|
|
|
|
async def _mapmaker_numbers(self, ctx: commands.Context):
|
|
|
|
|
|
|
|
"""Regenerates the number mask and puts it in the channel"""
|
|
|
|
|
|
|
|
if not self.mm:
|
|
|
|
|
|
|
|
await ctx.maybe_send_embed("No map currently being worked on")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async with ctx.typing():
|
|
|
|
|
|
|
|
await self.mm.create_number_mask()
|
|
|
|
|
|
|
|
im = await self.mm.get_blank_numbered_file()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.send(file=discord.File(im, filename="map.png"))
|
|
|
|
|
|
|
|
|
|
|
|
@mapmaker.command(name="close")
|
|
|
|
@mapmaker.command(name="close")
|
|
|
|
async def _mapmaker_close(self, ctx: commands.Context):
|
|
|
|
async def _mapmaker_close(self, ctx: commands.Context):
|
|
|
|
"""Close the currently open map."""
|
|
|
|
"""Close the currently open map."""
|
|
|
@ -255,7 +257,7 @@ class Conquest(commands.Cog):
|
|
|
|
files = await self.mm.get_sample()
|
|
|
|
files = await self.mm.get_sample()
|
|
|
|
|
|
|
|
|
|
|
|
for f in files:
|
|
|
|
for f in files:
|
|
|
|
await ctx.send(file=discord.File(f))
|
|
|
|
await ctx.send(file=discord.File(f, filename="map.png"))
|
|
|
|
|
|
|
|
|
|
|
|
@mapmaker.command(name="load")
|
|
|
|
@mapmaker.command(name="load")
|
|
|
|
async def _mapmaker_load(self, ctx: commands.Context, map_name: str):
|
|
|
|
async def _mapmaker_load(self, ctx: commands.Context, map_name: str):
|
|
|
@ -314,6 +316,10 @@ class Conquest(commands.Cog):
|
|
|
|
self, ctx: commands.Context, mask_list: Greedy[int], recommended=False
|
|
|
|
self, ctx: commands.Context, mask_list: Greedy[int], recommended=False
|
|
|
|
):
|
|
|
|
):
|
|
|
|
"""Generate masks for the map"""
|
|
|
|
"""Generate masks for the map"""
|
|
|
|
|
|
|
|
if not mask_list and not recommended:
|
|
|
|
|
|
|
|
await ctx.send_help()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if not self.mm:
|
|
|
|
if not self.mm:
|
|
|
|
await ctx.maybe_send_embed("No map currently being worked on")
|
|
|
|
await ctx.maybe_send_embed("No map currently being worked on")
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -339,6 +345,7 @@ class Conquest(commands.Cog):
|
|
|
|
await ctx.send("Not Implemented")
|
|
|
|
await ctx.send("Not Implemented")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async with ctx.typing():
|
|
|
|
result = await self.mm.combine_masks(mask_list)
|
|
|
|
result = await self.mm.combine_masks(mask_list)
|
|
|
|
if not result:
|
|
|
|
if not result:
|
|
|
|
await ctx.maybe_send_embed(
|
|
|
|
await ctx.maybe_send_embed(
|
|
|
@ -563,7 +570,7 @@ class Conquest(commands.Cog):
|
|
|
|
if self.current_map is None:
|
|
|
|
if self.current_map is None:
|
|
|
|
await ctx.maybe_send_embed("No map is currently set. See `[p]conquest set map`")
|
|
|
|
await ctx.maybe_send_embed("No map is currently set. See `[p]conquest set map`")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
async with ctx.typing():
|
|
|
|
numbers_path = self._path_if_custom() / self.current_map / f"numbers.{self.ext}"
|
|
|
|
numbers_path = self._path_if_custom() / self.current_map / f"numbers.{self.ext}"
|
|
|
|
if not numbers_path.exists():
|
|
|
|
if not numbers_path.exists():
|
|
|
|
await ctx.send(
|
|
|
|
await ctx.send(
|
|
|
|