Missed the listener update

pull/147/head
bobloy 4 years ago
parent 84ed2728e7
commit 8ffc8cc707

@ -1,6 +1,9 @@
import logging import logging
import random import random
import discord
from werewolf.listener import wolflistener
from werewolf.votegroup import VoteGroup from werewolf.votegroup import VoteGroup
log = logging.getLogger("red.fox_v3.werewolf.votegroup.wolfvote") log = logging.getLogger("red.fox_v3.werewolf.votegroup.wolfvote")
@ -21,59 +24,13 @@ class WolfVote(VoteGroup):
def __init__(self, game, channel): def __init__(self, game, channel):
super().__init__(game, channel) super().__init__(game, channel)
# self.game = game
# self.channel = channel
# self.players = []
# self.vote_results = {}
# self.properties = {} # Extra data for other options
self.killer = None # Added killer self.killer = None # Added killer
self.action_list = [ @wolflistener("at_night_start", priority=2)
(self._at_game_start, 1), # (Action, Priority) async def _at_night_start(self):
(self._at_day_start, 0), await super()._at_night_start()
(self._at_voted, 0),
(self._at_kill, 1),
(self._at_hang, 1),
(self._at_day_end, 0),
(self._at_night_start, 2),
(self._at_night_end, 5), # Kill priority
(self._at_visit, 0),
]
# async def on_event(self, event, data):
# """
# See Game class for event guide
# """
#
# await action_list[event][0](data)
#
# async def _at_game_start(self, data=None):
# await self.channel.send(" ".join(player.mention for player in self.players))
#
# async def _at_day_start(self, data=None):
# pass
#
# async def _at_voted(self, data=None):
# pass
#
# async def _at_kill(self, data=None):
# if data["player"] in self.players:
# self.players.pop(data["player"])
#
# async def _at_hang(self, data=None):
# if data["player"] in self.players:
# self.players.pop(data["player"])
#
# async def _at_day_end(self, data=None):
# pass
async def _at_night_start(self, data=None):
if self.channel is None:
return
await self.game.generate_targets(self.channel)
mention_list = " ".join(player.mention for player in self.players) mention_list = " ".join(player.mention for player in self.players)
if mention_list != "": if mention_list != "":
await self.channel.send(mention_list) await self.channel.send(mention_list)
@ -83,7 +40,8 @@ class WolfVote(VoteGroup):
f"{self.killer.member.display_name} has been selected as tonight's killer" f"{self.killer.member.display_name} has been selected as tonight's killer"
) )
async def _at_night_end(self, data=None): @wolflistener("at_night_end", priority=5)
async def _at_night_end(self):
if self.channel is None: if self.channel is None:
return return
@ -102,29 +60,14 @@ class WolfVote(VoteGroup):
else: else:
await self.channel.send("**No kill will be attempted tonight...**") await self.channel.send("**No kill will be attempted tonight...**")
# async def _at_visit(self, data=None):
# pass
#
# async def register_players(self, *players):
# """
# Extend players by passed list
# """
# self.players.extend(players)
#
# async def remove_player(self, player):
# """
# Remove a player from player list
# """
# if player.id in self.players:
# self.players.remove(player)
async def vote(self, target, author, target_id): async def vote(self, target, author, target_id):
""" """
Receive vote from game Receive vote from game
""" """
self.vote_results[author.id] = target_id await super().vote(target, author, target_id)
await self.channel.send( await self.channel.send(
"{} has voted to kill {}".format(author.mention, target.member.display_name) "{} has voted to kill {}".format(author.mention, target.member.display_name),
allowed_mentions=discord.AllowedMentions(everyone=False, users=[author])
) )

Loading…
Cancel
Save