From 10cc998cc82328fcc57631c53e8ab0a529a87375 Mon Sep 17 00:00:00 2001 From: bobloy Date: Sun, 15 Apr 2018 22:56:08 -0400 Subject: [PATCH] visiting and killing --- werewolf/game.py | 18 ++++++++++++------ werewolf/votegroups/wolfvote.py | 5 +++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/werewolf/game.py b/werewolf/game.py index 54696c1..e16607b 100644 --- a/werewolf/game.py +++ b/werewolf/game.py @@ -401,16 +401,18 @@ class Game: await player.choose(ctx, data) - + + async def _visit(self, target, source): + await target.role.visit(source) + await self._at_visit(target, source) + async def visit(self, target_id, source): """ Night visit target_id Returns a target for role information (i.e. Seer) """ target = await self.get_night_target(target_id, source) - await target.role.visit(source) - await self._at_visit(target, source) - + await self._visit(target, source) return target @@ -496,7 +498,7 @@ class Game: await self.dead_perms(player.member) # Add a punishment system for quitting games later - async def kill(self, target_id, source=None, method: str=None): + async def kill(self, target_id, source=None, method: str=None, novisit=False): """ Attempt to kill a target Source allows admin override @@ -514,7 +516,11 @@ class Game: if source.blocked: # Do nothing if blocked, blocker handles text return - + + if not novisit: + # Arsonist wouldn't visit before killing + await self._visit(target, source) # Visit before killing + if not target.protected: target.alive = False await target.kill(source) diff --git a/werewolf/votegroups/wolfvote.py b/werewolf/votegroups/wolfvote.py index f5d2b35..49431b3 100644 --- a/werewolf/votegroups/wolfvote.py +++ b/werewolf/votegroups/wolfvote.py @@ -80,14 +80,15 @@ class WolfVote(VoteGroup): if self.channel is None: return - target = None + target_id = None vote_list = list(self.vote_results.values()) if vote_list: target_id = max(set(vote_list), key=vote_list.count) - if target and self.killer: + if target_id and self.killer: await self.game.kill(target_id, self.killer, random.choice(self.kill_messages)) + await self.channel.send("**{} has left to complete the kill...**".format(self.killer.member.display_name)) else: await self.channel.send("**No kill will be attempted tonight...**")