Compare commits

..

58 Commits

Author SHA1 Message Date
bobloy 1694dd2d34 Actually use the argument in convert
3 years ago
bobloy 3361885882 not custom, new max regions
3 years ago
bobloy 99e6fce695 Chunker, sort regions, recalculate takes a list of regions
3 years ago
bobloy ac3d9b5a69 Add debug sort
3 years ago
bobloy 4e35a13577 Restoring lost regions, finish reduction of norway
3 years ago
bobloy 374c521e71 Convert takes optional masks parameter
3 years ago
bobloy 5ce95038f2 AsyncIters to stop heartbeat issues, standardize mask image mode, fix weight in recalculate region, add convert masks,
3 years ago
bobloy 439873de95 rename recalculatecenter to recalculate, add cleanup
3 years ago
bobloy 393cc6e523 Reduction of Norway
3 years ago
bobloy aa84cd1a9e More ck2 updates
3 years ago
bobloy ff7455495d Better region centering, randomized samples, fixed merge weights, recalculating center, no more data nesting data
3 years ago
bobloy 4108069671 Add recalculatecenter, mapmaker region
3 years ago
bobloy ca4cf5408b WIP ck2 map
3 years ago
bobloy cd49b07448 Add fonts
3 years ago
bobloy 6762d3cbde Add fonts
3 years ago
bobloy 8acca64264 Add fonts
3 years ago
bobloy 44b724fd71 More future maps
3 years ago
bobloy ee1eaa1d90 Upgrade simple to png
3 years ago
bobloy 9cf466c78e Functioning map maker
3 years ago
bobloy 978d6f8627 rest converted, time to fix maps
3 years ago
bobloy 2315bd9fc3 The rest converted???
3 years ago
bobloy e02c7ba14b beginning of set map
4 years ago
bobloy 836911ee89 Merge branch 'master' into conquest_develop
4 years ago
bobloy 3e25c8a13f Saving and loading
4 years ago
bobloy d987018664 More zoom WIP
4 years ago
bobloy 25e90c350f More progress on switched to ConquestGame class
4 years ago
bobloy 2d0c9e31b3 WIP self.current_map
4 years ago
bobloy 80db00890d Merge branch 'master' into conquest_develop
4 years ago
bobloy 4496903663 further WIP
4 years ago
bobloy 4457d51f07 More WIP conquest
4 years ago
bobloy 4cd033bf12 WIP conquest
4 years ago
bobloy 7626bb6a76 Merge branch 'master' into conquest_develop
4 years ago
bobloy 664aa63833 much to do
4 years ago
bobloy 500915b947 Game data is different
4 years ago
bobloy 36d6e5c9bf Merge branch 'master' into conquest_develop
4 years ago
bobloy 7574117d9a WIP ConquestGame and per guild saving
4 years ago
bobloy f0d33f0354 Better mask combination
4 years ago
bobloy e2e5477661 Better number positioning, better mask combining and generation
4 years ago
bobloy 8abeca3d1e Merge branch 'master' into conquest_develop
4 years ago
bobloy aadd9a61a8 Merge branch 'master' into conquest_develop
4 years ago
bobloy c3c40c594e More region classification
5 years ago
bobloy b46a5920f7 Merge branch 'master' into conquest_develop
5 years ago
bobloy 52fc284f5a WIP Classification
5 years ago
bobloy ef925b1621 Map maker is almost working
5 years ago
bobloy 719e8903fd Merge branch 'master' into conquest_develop
5 years ago
bobloy 07b90c30a0 Don't use os, more mapmaker
5 years ago
bobloy a1b89c9f9d More map maper and notes on regioner
5 years ago
bobloy f93986e65f Reorder methods
5 years ago
bobloy 11258d3e76 mapmapker back to conquest.py
5 years ago
bobloy 0b4e0310f9 Merge branch 'master' into conquest_develop
5 years ago
bobloy 5fff65c7d5 WIP mapmaker
5 years ago
bobloy 8012a20ddb Don't load current map if it doesn't exist
5 years ago
bobloy 3b156d8275 Split mapmaker
5 years ago
bobloy ae200eb911 This isn't dad
5 years ago
bobloy 7161e8e28c Merge branch 'master' into conquest_develop
5 years ago
bobloy 03b42b04ef Merge branch 'master' into conquest_develop
5 years ago
bobloy 42aab1e801 More map maker WIP
5 years ago
bobloy dc8d314713 Start of map maker, ambiguous file format (probably just jpg and png)
5 years ago

@ -3,7 +3,6 @@ import logging
import re
import discord
from discord.ext.commands import RoleConverter, Greedy, CommandError, ArgumentParsingError
from discord.ext.commands.view import StringView
from redbot.core import Config, checks, commands
from redbot.core.bot import Red
@ -14,38 +13,15 @@ log = logging.getLogger("red.fox_v3.ccrole")
async def _get_roles_from_content(ctx, content):
# greedy = Greedy[RoleConverter]
view = StringView(content)
rc = RoleConverter()
# "Borrowed" from discord.ext.commands.Command._transform_greedy_pos
result = []
while not view.eof:
# for use with a manual undo
previous = view.index
view.skip_ws()
try:
argument = view.get_quoted_word()
value = await rc.convert(ctx, argument)
except (CommandError, ArgumentParsingError):
view.index = previous
break
else:
result.append(value)
return [r.id for r in result]
# Old method
# content_list = content.split(",")
# try:
# role_list = [
# discord.utils.get(ctx.guild.roles, name=role.strip(" ")).id for role in content_list
# ]
# except (discord.HTTPException, AttributeError): # None.id is attribute error
# return None
# else:
# return role_list
content_list = content.split(",")
try:
role_list = [
discord.utils.get(ctx.guild.roles, name=role.strip(" ")).id for role in content_list
]
except (discord.HTTPException, AttributeError): # None.id is attribute error
return None
else:
return role_list
class CCRole(commands.Cog):
@ -108,7 +84,7 @@ class CCRole(commands.Cog):
# Roles to add
await ctx.send(
"What roles should it add?\n"
"What roles should it add? (Must be **comma separated**)\n"
"Say `None` to skip adding roles"
)
@ -130,7 +106,7 @@ class CCRole(commands.Cog):
# Roles to remove
await ctx.send(
"What roles should it remove?\n"
"What roles should it remove? (Must be comma separated)\n"
"Say `None` to skip removing roles"
)
try:
@ -148,7 +124,7 @@ class CCRole(commands.Cog):
# Roles to use
await ctx.send(
"What roles are allowed to use this command?\n"
"What roles are allowed to use this command? (Must be comma separated)\n"
"Say `None` to allow all roles"
)

@ -7,7 +7,7 @@
"hidden": false,
"install_msg": "Thank you for installing Chatter! Please make sure you check the install instructions at https://github.com/bobloy/Fox-V3/blob/master/chatter/README.md\nAfter that, get started ith `[p]load chatter` and `[p]help Chatter`",
"requirements": [
"git+git://github.com/bobloy/ChatterBot@fox#egg=ChatterBot>=1.1.0.dev4",
"git+git://github.com/bobloy/ChatterBot@fox#egg=ChatterBot",
"kaggle",
"https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.1.0/en_core_web_sm-3.1.0.tar.gz#egg=en_core_web_sm",
"https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.1.0/en_core_web_md-3.1.0.tar.gz#egg=en_core_web_md"

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

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

File diff suppressed because it is too large Load Diff

@ -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

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

Loading…
Cancel
Save