From d06954b1a3a529e657fbe95231f093bfe99f3d34 Mon Sep 17 00:00:00 2001 From: Elnath Date: Sun, 13 Jun 2021 20:20:49 +0200 Subject: [PATCH] Implemented player killing --- GameFiles/Game.py | 10 ++++++++++ SecretBot.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/GameFiles/Game.py b/GameFiles/Game.py index 6b09ce7..219868a 100644 --- a/GameFiles/Game.py +++ b/GameFiles/Game.py @@ -461,3 +461,13 @@ class Game: " ".join([Policy.FASCIST.square_emoji()] * enacted_count[Policy.FASCIST] + [":black_small_square:"] * (6 - enacted_count[Policy.FASCIST])), ] await self.get_announcements_channel().send("\n".join(message_content), allowed_mentions = discord.AllowedMentions(roles = True)) + + @game_started + @save_on_success + async def kill_player(self, player: discord.Member): + if player.id not in self.get_players_id(): + raise ValueError(f"Trying to kill a player ({player.name}) which is not in the game") + self.config["players"].remove(player.id) + await player.remove_roles(self.get_player_role()) + await self.get_announcements_channel().send(f":skull: <@{player.id}> has been killed! :skull:", allowed_mentions = discord.AllowedMentions(users = True)) + await self.get_player_channel(player).send("u ded lol") diff --git a/SecretBot.py b/SecretBot.py index 9049ef6..340e412 100755 --- a/SecretBot.py +++ b/SecretBot.py @@ -289,6 +289,20 @@ class SecretBot(commands.Cog): ] await ctx.reply("\n".join(message_content)) + @commands.command("Kill", help = "Kill a player and remove them from the game") + async def kill_player_with_confirmation(self, ctx: commands.Context, player: discord.Member): + game = await self.get_running_game_or_error_message(ctx) + await self.check_is_administrator_or_gm(ctx) + if player.id in game.get_players_id(): + await self.confirm_action(f"Do you really want to kill <@{player.id}>? This will completely remove them from the game", ctx.channel, self.kill_player(ctx, player), ctx.message) + else: + await ctx.reply(f":x: <@{player.id}> is not in the game", allowed_mentions = discord.AllowedMentions.none()) + + async def kill_player(self, ctx: commands.Context, player: discord.Member): + game = await self.get_running_game_or_error_message(ctx) + await game.kill_player(player) + await ctx.reply(":dagger: The order has been executed.") + if __name__ == '__main__': argparser = argparse.ArgumentParser(description = "Secret Hitler helper bot", formatter_class = argparse.ArgumentDefaultsHelpFormatter)