diff --git a/werewolf/night_powers.py b/werewolf/night_powers.py index ca35e8b..215e8eb 100644 --- a/werewolf/night_powers.py +++ b/werewolf/night_powers.py @@ -3,3 +3,21 @@ from werewolf.role import Role def night_immune(role: Role): role.player.alive = True + + +async def pick_target(role: Role, ctx, data): + if not role.player.alive: # FixMe: Game handles this? + await role.player.send_dm("You're already dead!") + return None + + target_id = int(data) + try: + target = role.game.players[target_id] + except IndexError: + target = None + + if target is None: + await ctx.send("Not a valid ID") + return None + + return target_id, target diff --git a/werewolf/roles/seer.py b/werewolf/roles/seer.py index f4bdcbd..63b62a2 100644 --- a/werewolf/roles/seer.py +++ b/werewolf/roles/seer.py @@ -1,3 +1,4 @@ +from werewolf.night_powers import pick_target from werewolf.role import Role @@ -83,19 +84,7 @@ class Seer(Role): async def choose(self, ctx, data): """Handle night actions""" - if not self.player.alive: # FixMe: Game handles this? - await self.player.send_dm("You're already dead!") - return - - target_id = int(data) - try: - target = self.game.players[target_id] - except IndexError: - target = None - - if target is None: - await ctx.send("Not a valid ID") - return + await super().choose(ctx, data) - self.see_target = target_id + self.see_target, target = await pick_target(self, ctx, data) await ctx.send("**You will attempt to see the role of {} tonight...**".format(target.member.display_name))