Add command to allow or forbid a specific player from using the !forfeit command despite server restrictions on the command.

Allows for allowing a player to forfeit if they are under a time restriction where they have to leave the game, without allowing the command globally.
This commit is contained in:
CaitSith2 2020-09-02 02:23:31 -07:00
parent 096fc988c4
commit e77cd7c38a
1 changed files with 30 additions and 0 deletions

View File

@ -69,6 +69,7 @@ class Context(Node):
self.saving = False
self.player_names = {}
self.rom_names = {}
self.allow_forfeits = {}
self.remote_items = set()
self.locations = {}
self.host = host
@ -689,6 +690,9 @@ class ClientMessageProcessor(CommonCommandProcessor):
def _cmd_forfeit(self) -> bool:
"""Surrender and send your remaining items out to their recipients"""
if self.ctx.allow_forfeits.get((self.client.team, self.client.slot), False):
forfeit_player(self.ctx, self.client.team, self.client.slot)
return True
if "enabled" in self.ctx.forfeit_mode:
forfeit_player(self.ctx, self.client.team, self.client.slot)
return True
@ -1077,6 +1081,32 @@ class ServerCommandProcessor(CommonCommandProcessor):
self.output(f"Could not find player {player_name} to forfeit")
return False
@mark_raw
def _cmd_allow_forfeit(self, player_name: str) -> bool:
"""Allow the specified player to use the !forfeit command"""
seeked_player = player_name.lower()
for (team, slot), name in self.ctx.player_names.items():
if name.lower() == seeked_player:
self.ctx.allow_forfeits[(team, slot)] = True
self.output(f"Player {player_name} is now allowed to use the !forfeit command at any time.")
return True
self.output(f"Could not find player {player_name} to allow the !forfeit command for.")
return False
@mark_raw
def _cmd_forbid_forfeit(self, player_name: str) -> bool:
""""Disallow the specified player from using the !forfeit command"""
seeked_player = player_name.lower()
for (team, slot), name in self.ctx.player_names.items():
if name.lower() == seeked_player:
self.ctx.allow_forfeits[(team, slot)] = False
self.output(f"Player {player_name} has to follow the server restrictions on use of the !forfeit command.")
return True
self.output(f"Could not find player {player_name} to forbid the !forfeit command for.")
return False
def _cmd_send(self, player_name: str, *item_name: str) -> bool:
"""Sends an item to the specified player"""
seeked_player, usable, response = get_intended_text(player_name, self.ctx.player_names.values())