Skip to content

Commit

Permalink
Hotfix 5: Booked bases fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yakMM committed Apr 5, 2021
1 parent 15792c6 commit 480c26c
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 20 deletions.
Binary file modified accounts_sheet_template.xlsx
Binary file not shown.
1 change: 1 addition & 0 deletions bot/cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async def clear(self, ctx):
if ctx.channel.id in cfg.channels["matches"]:
match = Match.get(ctx.channel.id)
await match.command.clear(ctx)
return
await disp.WRONG_CHANNEL_2.send(ctx, ctx.command.name, f"<#{ctx.channel.id}>")

@commands.command()
Expand Down
22 changes: 13 additions & 9 deletions bot/config_template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ accounts = # id of the account google sheet
jaeger_cal = # id of the jaeger calendar google sheet

[Map_Images]
acan = # Link to a base image
chac = # Link to a base image
ghanan = # Link to a base image
pale = # Link to a base image
peris = # Link to a base image
rashnu = # Link to a base image
kessel = # Link to a base image
nettlemire = # Link to a base image
bridgewater = # Link to a base image
acan = # Link to base image
ghanan = # Link to base image
chac = # Link to base image
pale = # Link to base image
peris = # Link to base image
rashnu = # Link to base image
xeno = # Link to base image
ns_material = # Link to base image
ceres = # Link to base image
kessel = # Link to base image
nettlemire = # Link to base image
bridgewater = # Link to base image
rime = # Link to base image
6 changes: 4 additions & 2 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ async def on_ready():
except ValueError:
pass
modules.database.set_field("restart_data", 0, {"last_lobby": list()})
await disp.LB_QUEUE.send(ContextWrapper.channel(cfg.channels["lobby"]),
names_in_lobby=modules.lobby.get_all_names_in_lobby())
names = modules.lobby.get_all_names_in_lobby()
if names:
await disp.LB_QUEUE.send(ContextWrapper.channel(cfg.channels["lobby"]),
names_in_lobby=modules.lobby.get_all_names_in_lobby())
modules.loader.unlock_all(client)
log.info('Client is ready!')
await disp.RDY.send(ContextWrapper.channel(cfg.channels["spam"]), cfg.VERSION)
Expand Down
10 changes: 5 additions & 5 deletions bot/match/classes/base_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(self, match, base_pool=False):
self.__validator = CaptainValidator(self.__match)
self.add_callbacks(self.__validator)
self.__nav = BaseNavigator(self, match.channel)
_pog_selected_bases[self.__match.id] = None
self._get_booked_from_calendar.start()

@loop(count=1)
Expand All @@ -65,12 +64,13 @@ async def _get_booked_from_calendar(self):
async def clean(self):
await self.__validator.clean()
await self.__nav.reaction_handler.destroy()
_pog_selected_bases[self.__match.id] = None
if self.__match.id in _pog_selected_bases:
del _pog_selected_bases[self.__match.id]

def __is_used(self, base):
for key in _pog_selected_bases.keys():
if key != self.__match.id:
if base is _pog_selected_bases[key]:
if base.id == _pog_selected_bases[key]:
return True
return False

Expand Down Expand Up @@ -108,7 +108,7 @@ def add_callbacks(self, validator):
async def do_confirm(ctx, base):
self.__reset_selection()
self.__selected = base
_pog_selected_bases[self.__match.id] = base
_pog_selected_bases[self.__match.id] = base.id
self.__match.data.base = base
await self.__nav.reaction_handler.destroy()
await disp.BASE_ON_SELECT.send(ctx, base.name, base=base, is_booked=self.is_booked)
Expand Down Expand Up @@ -184,7 +184,7 @@ async def __select_base(self, ctx, picker, base):
other_captain = self.__match.teams[picker.team.id - 1].captain
msg = await disp.BASE_OK_CONFIRM.send(ctx, base.name, other_captain.mention)
await self.__validator.wait_valid(picker, msg, base=base)
if self.is_booked:
if self.is_base_booked(base):
await disp.BASE_BOOKED.send(ctx, other_captain.mention, base.name)

def __reset_selection(self):
Expand Down
9 changes: 5 additions & 4 deletions bot/match/classes/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __init__(self, match: Match, data: MatchData, channel: int):
self.base_selector = None
self.progress_index = 0
self.result_msg = None
self.clean_channel.start()
self.clean_channel.start(display=False)
self.check_offline = True
self.check_validated = True
self.players_with_account = list()
Expand Down Expand Up @@ -254,12 +254,13 @@ async def clean(self):
self.check_offline = True
self.check_validated = True
await self.set_status(MatchStatus.IS_FREE)
self.clean_channel.start()
self.clean_channel.start(display=True)
self.progress_index = 0

@loop(count=1)
async def clean_channel(self):
await disp.MATCH_CHANNEL_OVER.send(self.channel)
async def clean_channel(self, display):
if display:
await disp.MATCH_CHANNEL_OVER.send(self.channel)
await roles.modify_match_channel(self.match.channel, view=False)

@property
Expand Down
Binary file removed media/acan.png
Binary file not shown.
Binary file removed media/bridgewater.png
Binary file not shown.
Binary file removed media/chac.png
Binary file not shown.
Binary file removed media/ghanan.png
Binary file not shown.
Binary file removed media/kessel.png
Binary file not shown.
Binary file removed media/nettlemire.png
Binary file not shown.
Binary file removed media/pale.png
Binary file not shown.
Binary file removed media/peris.png
Binary file not shown.
Binary file removed media/rashnu.png
Binary file not shown.
Binary file removed media/xeno.png
Binary file not shown.

0 comments on commit 480c26c

Please sign in to comment.