From 774fec0e328821a57ed8348290a88046b769313a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 9 Nov 2021 00:40:58 +0100 Subject: [PATCH] Implement cheat command to update scores --- orochi/bot.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/orochi/bot.py b/orochi/bot.py index df0b185..788c78b 100644 --- a/orochi/bot.py +++ b/orochi/bot.py @@ -241,6 +241,10 @@ async def open(ctx: commands.Context): players = list(vote.players) other_vote = votes[1 - i] for j, player in enumerate(players): + if player.score <= 0: + # Player is dead + continue + other_player = players[1 - j] if len(players) == 2 else None view = VoteView(timeout=3600) channel_id = player.private_channel_id @@ -286,6 +290,9 @@ async def close(ctx: commands.Context): "Rendez-vous dans la salle principale pour découvrir les scores.") if player.score <= 0: await channel.send("Tiens ! Vous êtes morts :)") + elif player.score >= 9: + await channel.send("Vous avez plus de 9 points. Vous pouvez désormais passer la porte 9.\n" + "Mais ... Attendrez-vous vos camarades ?") await ctx.reply("Les votes ont bien été fermés.") game.save('game.save') @@ -361,6 +368,30 @@ async def setup(ctx: commands.Context, room: Room): await ctx.send(f"Attention : **{round_room.vote1.player1.name}** est déjà choisie.") +@bot.command(help="Falsification des votes") +@commands.has_permissions(administrator=True) +async def cheat(ctx: commands.Context, player_name: str, vote: Vote | None): + game: Game = Game.INSTANCE + if game.state != GameState.VOTING: + return await ctx.reply("Les votes ne sont pas ouverts.") + + for player in game.players.values(): + if player.name.lower() == player_name.lower(): + current_player = player + break + else: + return await ctx.reply("Le joueur n'existe pas.") + + current_round = game.rounds[-1] + for room in current_round.rooms: + for v in room.votes: + if current_player in v.players: + v.vote = vote + + game.save('game.save') + await ctx.reply(f"Le vote de **{current_player.name}** a bien été falsifié (nouveau vote : *{vote}**).") + + class VoteView(disnake.ui.View): @disnake.ui.button(label="S'allier", style=disnake.ButtonStyle.green) async def confirm(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):