Compare commits

...

58 Commits

Author SHA1 Message Date
bobloy
1694dd2d34 Actually use the argument in convert 2021-09-07 12:30:43 -04:00
bobloy
3361885882 not custom, new max regions 2021-09-07 11:12:56 -04:00
bobloy
99e6fce695 Chunker, sort regions, recalculate takes a list of regions 2021-09-07 08:57:27 -04:00
bobloy
ac3d9b5a69 Add debug sort 2021-09-07 08:55:53 -04:00
bobloy
4e35a13577 Restoring lost regions, finish reduction of norway 2021-09-07 08:55:19 -04:00
bobloy
374c521e71 Convert takes optional masks parameter 2021-09-03 15:15:25 -04:00
bobloy
5ce95038f2 AsyncIters to stop heartbeat issues, standardize mask image mode, fix weight in recalculate region, add convert masks, 2021-09-03 14:35:09 -04:00
bobloy
439873de95 rename recalculatecenter to recalculate, add cleanup 2021-09-03 14:34:08 -04:00
bobloy
393cc6e523 Reduction of Norway 2021-09-03 14:25:06 -04:00
bobloy
aa84cd1a9e More ck2 updates 2021-09-01 16:51:35 -04:00
bobloy
ff7455495d Better region centering, randomized samples, fixed merge weights, recalculating center, no more data nesting data 2021-09-01 14:22:14 -04:00
bobloy
4108069671 Add recalculatecenter, mapmaker region 2021-09-01 14:21:37 -04:00
bobloy
ca4cf5408b WIP ck2 map 2021-09-01 10:43:56 -04:00
bobloy
cd49b07448 Add fonts 2021-08-31 14:41:36 -04:00
bobloy
6762d3cbde Add fonts 2021-08-31 14:41:15 -04:00
bobloy
8acca64264 Add fonts 2021-08-31 14:40:51 -04:00
bobloy
44b724fd71 More future maps 2021-08-31 14:40:40 -04:00
bobloy
ee1eaa1d90 Upgrade simple to png 2021-08-26 14:03:53 -04:00
bobloy
9cf466c78e Functioning map maker 2021-08-25 17:51:59 -04:00
bobloy
978d6f8627 rest converted, time to fix maps 2021-08-20 15:21:31 -04:00
bobloy
2315bd9fc3 The rest converted??? 2021-08-19 17:29:41 -04:00
bobloy
e02c7ba14b beginning of set map 2021-08-09 10:02:08 -04:00
bobloy
836911ee89 Merge branch 'master' into conquest_develop 2021-07-23 17:08:40 -04:00
bobloy
3e25c8a13f Saving and loading 2021-07-23 16:02:26 -04:00
bobloy
d987018664 More zoom WIP 2021-07-23 09:27:32 -04:00
bobloy
25e90c350f More progress on switched to ConquestGame class 2021-07-22 17:25:13 -04:00
bobloy
2d0c9e31b3 WIP self.current_map 2021-07-16 11:32:47 -04:00
bobloy
80db00890d Merge branch 'master' into conquest_develop
# Conflicts:
#	conquest/conquest.py
#	conquest/mapmaker.py
2021-07-16 09:28:44 -04:00
bobloy
4496903663 further WIP 2020-10-07 13:42:50 -04:00
bobloy
4457d51f07 More WIP conquest 2020-10-06 17:36:36 -04:00
bobloy
4cd033bf12 WIP conquest 2020-10-04 17:54:15 -04:00
bobloy
7626bb6a76 Merge branch 'master' into conquest_develop
# Conflicts:
#	conquest/conquest.py
2020-10-01 09:33:31 -04:00
bobloy
664aa63833 much to do 2020-08-27 17:13:00 -04:00
bobloy
500915b947 Game data is different 2020-08-22 13:26:17 -04:00
bobloy
36d6e5c9bf Merge branch 'master' into conquest_develop 2020-08-22 13:26:01 -04:00
bobloy
7574117d9a WIP ConquestGame and per guild saving 2020-08-19 15:57:02 -04:00
bobloy
f0d33f0354 Better mask combination 2020-08-18 21:21:48 -04:00
bobloy
e2e5477661 Better number positioning, better mask combining and generation 2020-08-18 17:02:58 -04:00
bobloy
8abeca3d1e Merge branch 'master' into conquest_develop 2020-08-18 11:07:56 -04:00
bobloy
aadd9a61a8 Merge branch 'master' into conquest_develop
# Conflicts:
#	conquest/info.json
2020-08-18 08:20:22 -04:00
bobloy
c3c40c594e More region classification 2020-08-17 16:41:56 -04:00
bobloy
b46a5920f7 Merge branch 'master' into conquest_develop 2020-08-17 11:15:04 -04:00
bobloy
52fc284f5a WIP Classification 2020-08-17 08:17:49 -04:00
bobloy
ef925b1621 Map maker is almost working 2020-08-13 17:33:09 -04:00
bobloy
719e8903fd Merge branch 'master' into conquest_develop 2020-08-13 13:05:15 -04:00
bobloy
07b90c30a0 Don't use os, more mapmaker 2020-08-13 09:48:16 -04:00
bobloy
a1b89c9f9d More map maper and notes on regioner 2020-08-12 17:37:38 -04:00
bobloy
f93986e65f Reorder methods 2020-08-12 15:28:36 -04:00
bobloy
11258d3e76 mapmapker back to conquest.py 2020-08-12 13:16:47 -04:00
bobloy
0b4e0310f9 Merge branch 'master' into conquest_develop 2020-08-12 11:18:39 -04:00
bobloy
5fff65c7d5 WIP mapmaker 2020-08-12 10:59:52 -04:00
bobloy
8012a20ddb Don't load current map if it doesn't exist 2020-08-12 10:58:51 -04:00
bobloy
3b156d8275 Split mapmaker 2020-08-12 10:03:07 -04:00
bobloy
ae200eb911 This isn't dad 2020-08-12 09:46:07 -04:00
bobloy
7161e8e28c Merge branch 'master' into conquest_develop 2020-08-12 09:44:17 -04:00
bobloy
03b42b04ef Merge branch 'master' into conquest_develop 2020-08-12 09:42:34 -04:00
bobloy
42aab1e801 More map maker WIP 2020-08-12 09:38:35 -04:00
bobloy
dc8d314713 Start of map maker, ambiguous file format (probably just jpg and png) 2020-08-11 17:23:42 -04:00
2782 changed files with 20271 additions and 327 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

View File

@ -1,7 +1,6 @@
from redbot.core import data_manager from redbot.core import data_manager
from .conquest import Conquest from .conquest import Conquest
from .mapmaker import MapMaker
async def setup(bot): async def setup(bot):
@ -10,6 +9,3 @@ async def setup(bot):
await cog.load_data() await cog.load_data()
bot.add_cog(cog) bot.add_cog(cog)
cog2 = MapMaker(bot)
bot.add_cog(cog2)

File diff suppressed because it is too large Load Diff

186
conquest/conquestgame.py Normal file
View File

@ -0,0 +1,186 @@
import asyncio
import json
import logging
import pathlib
from shutil import copyfile
from types import SimpleNamespace
from typing import Optional, Union
import discord
from PIL import Image, ImageOps
from redbot.core import commands
from conquest.regioner import ConquestMap, composite_regions
log = logging.getLogger("red.fox_v3.conquest.conquestgame")
class ConquestGame:
ext = "PNG"
ext_format = "PNG"
default_zoom_json = {"enabled": False, "x": -1, "y": -1, "zoom": 1.0}
def __init__(self, map_path: pathlib.Path, game_name: str, custom_map_path: pathlib.Path):
self.source_map = ConquestMap(map_path)
self.source_map.load_data()
self.game_name = game_name
self.current_map_folder = custom_map_path
self.settings_json = self.current_map_folder / "settings.json"
self.current_filename = f"current.{self.ext}"
self.current_map = self.current_map_folder / self.current_filename
self.zoomed_current_filename = f"current_zoomed.{self.ext}"
self.zoomed_current_map = self.current_map_folder / self.zoomed_current_filename
self.numbered_current_filename = f"current_numbered.{self.ext}"
self.numbered_current_map = self.current_map_folder / self.numbered_current_filename
self.zoomed_numbered_current_filename = f"current_zoomed_numbered.{self.ext}"
self.zoomed_numbered_current_map = (
self.current_map_folder / self.zoomed_numbered_current_filename
)
self.region_max = self.source_map.region_max
# self.zoom_is_out_of_date = {'current': True, 'blank': True}
async def save_region(self, region):
if not self.custom:
return False
pass # TODO: region data saving
async def start_game(self):
if not self.current_map_folder.exists():
self.current_map_folder.mkdir()
copyfile(self.source_map.blank_path(), self.current_map)
async def resume_game(self, ctx: commands.Context, reset: bool):
if not reset and self.current_map.exists():
await ctx.maybe_send_embed(
"This map is already in progress, resuming from last game\n"
"Use `[p]conquest set map [mapname] True` to start a new game"
)
else:
await self.start_game()
async def _process_take_regions(self, color, regions):
im = Image.open(self.current_map)
out: Optional[Image.Image] = await composite_regions(
im,
regions,
color,
self.source_map.masks_path(),
)
out.save(self.current_map, self.ext_format) # Overwrite current map with new map
# self.zoom_is_out_of_date.current = True
async def create_numbered_map(self):
if (
not self.source_map.numbers_path().exists()
): # No numbers map, can't add numbers to current
return self.source_map.numbered_path()
current_map = Image.open(self.current_map)
numbers = Image.open(self.source_map.numbers_path()).convert("L")
inverted_map = ImageOps.invert(current_map)
loop = asyncio.get_running_loop()
current_numbered_img = await loop.run_in_executor(
None, Image.composite, current_map, inverted_map, numbers
)
current_numbered_img.save(self.numbered_current_map, self.ext_format)
return self.numbered_current_map
async def create_zoomed_map(
self,
x,
y,
zoom,
source_map: Union[Image.Image, pathlib.Path],
target_path: pathlib.Path,
**kwargs,
):
"""Pass out_of_date when created a zoomed map based on something other than the settings json"""
# if out_of_date:
# self.zoom_is_out_of_date.current = True
# if current_map is None:
# current_map = Image.open(self.current_map_folder)
# target_map = self.zoomed_current_map
if not isinstance(source_map, Image.Image):
source_map = Image.open(source_map)
w, h = source_map.size
zoom2 = zoom * 2
zoomed_map = source_map.crop((x - w / zoom2, y - h / zoom2, x + w / zoom2, y + h / zoom2))
# zoomed_map = zoomed_map.resize((w, h), Image.LANCZOS)
zoomed_map.save(target_path, self.ext_format)
return True
async def get_maybe_zoomed_map(self, version):
zoom_data = {"enabled": False}
if self.settings_json.exists():
with self.settings_json.open() as zoom_json:
zoom_data = json.load(zoom_json)
if version == "numbered":
map_path = self.create_numbered_map()
zoomed_path = self.zoomed_numbered_current_map
else: # version == "current"
map_path = self.current_map
zoomed_path = self.zoomed_current_map
if zoom_data["enabled"]: # Send zoomed map instead of current map
# if self.zoom_is_out_of_date:
await self.create_zoomed_map(**zoom_data, source_map=map_path, target_map=zoomed_path)
map_path = zoomed_path
# self.zoom_is_out_of_date = False
return discord.File(fp=map_path) # lol file names
async def reset_zoom(self):
if not self.settings_json.exists():
return False
with self.settings_json.open("w+") as zoom_json:
json.dump({"enabled": False}, zoom_json, sort_keys=True, indent=4)
# self.zoom_is_out_of_date = True
return True
async def set_zoom(self, x, y, zoom):
zoom_data = self.default_zoom_json.copy()
zoom_data["enabled"] = True
zoom_data["x"] = x
zoom_data["y"] = y
zoom_data["zoom"] = zoom
# self.zoom_is_out_of_date = True
with self.settings_json.open("w+") as zoom_json:
json.dump(zoom_data, zoom_json, sort_keys=True, indent=4)
async def save_as(self, save_name):
copyfile(self.current_map, self.current_map_folder / f"{save_name}.{self.ext}")
async def load_from(self, save_name):
saved_map = self.current_map_folder / f"{save_name}.{self.ext}"
if not saved_map.exists():
return False
copyfile(saved_map, self.current_map) # Overwrite current map with saved map
return True

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 KiB

After

Width:  |  Height:  |  Size: 374 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Some files were not shown because too many files have changed in this diff Show More