From a36d887122626729deba007f3d424d86b37dfcb7 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 16 Apr 2020 15:40:31 +0200 Subject: [PATCH] add ability to disable forfeits --- MultiServer.py | 12 +++++++++--- host.yaml | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index 9656fe4a..ad2dbbb9 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -49,7 +49,7 @@ class Client: class Context: def __init__(self, host: str, port: int, password: str, location_check_points: int, hint_cost: int, - item_cheat: bool): + item_cheat: bool, forfeit_allowed): self.data_filename = None self.save_filename = None self.disable_save = False @@ -69,6 +69,7 @@ class Context: self.location_check_points = location_check_points self.hints_used = collections.defaultdict(int) self.hints_sent = collections.defaultdict(set) + self.forfeit_allowed = forfeit_allowed self.item_cheat = item_cheat self.running = True self.commandprocessor = ServerCommandProcessor(self) @@ -426,7 +427,11 @@ class ClientMessageProcessor(CommandProcessor): def _cmd_forfeit(self): """Surrender and send your remaining items out to their recipients""" - forfeit_player(self.ctx, self.client.team, self.client.slot) + if self.ctx.forfeit_allowed: + forfeit_player(self.ctx, self.client.team, self.client.slot) + else: + self.output( + "Sorry, client forfeiting has been disabled on this server. You can ask the server admin for a /forfeit") def _cmd_countdown(self, seconds: str = "10"): """Start a countdown in seconds""" @@ -749,6 +754,7 @@ def parse_args() -> argparse.Namespace: parser.add_argument('--hint_cost', default=defaults["hint_cost"], type=int) parser.add_argument('--disable_item_cheat', default=defaults["disable_item_cheat"], action='store_true') parser.add_argument('--port_forward', default=defaults["port_forward"], action='store_true') + parser.add_argument('--disable_client_forfeit', default=defaults["disable_client_forfeit"], action='store_true') args = parser.parse_args() return args @@ -760,7 +766,7 @@ async def main(args: argparse.Namespace): portforwardtask = asyncio.create_task(forward_port(args.port)) ctx = Context(args.host, args.port, args.password, args.location_check_points, args.hint_cost, - not args.disable_item_cheat) + not args.disable_item_cheat, not args.disable_client_forfeit) ctx.data_filename = args.multidata diff --git a/host.yaml b/host.yaml index ad3b4ef0..3d54f2d2 100644 --- a/host.yaml +++ b/host.yaml @@ -23,6 +23,8 @@ server_options: location_check_points: 1 #point cost to receive a hint via !hint for players hint_cost: 1000 #set to 0 if you want free hints + #disable client forfeit + disable_client_forfeit: false #options for MultiMystery.py multi_mystery_options: #teams, however, note that there is currently no way to supply names for teams 2+ through MultiMystery