You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fox-V3/werewolf/votegroups/wolfvote.py

118 lines
3.7 KiB

7 years ago
import random
from werewolf.votegroup import VoteGroup
7 years ago
7 years ago
class WolfVote(VoteGroup):
"""
Werewolf implementation of base VoteGroup class
"""
alignment = 2 # 1: Town, 2: Werewolf, 3: Neutral
7 years ago
channel_id = "werewolves"
kill_messages = [
7 years ago
"**{ID}** - {target} was mauled by wolves",
"**{ID}** - {target} was found torn to shreds"]
7 years ago
def __init__(self, game, channel):
7 years ago
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.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_day_start, 0),
(self._at_voted, 0),
7 years ago
(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)
]
7 years ago
# async def on_event(self, event, data):
7 years ago
# """
# See Game class for event guide
# """
#
# await action_list[event][0](data)
#
7 years ago
# async def _at_game_start(self, data=None):
7 years ago
# await self.channel.send(" ".join(player.mention for player in self.players))
#
7 years ago
# async def _at_day_start(self, data=None):
7 years ago
# pass
#
7 years ago
# async def _at_voted(self, data=None):
7 years ago
# pass
#
7 years ago
# async def _at_kill(self, data=None):
7 years ago
# if data["player"] in self.players:
# self.players.pop(data["player"])
#
7 years ago
# async def _at_hang(self, data=None):
7 years ago
# if data["player"] in self.players:
# self.players.pop(data["player"])
#
7 years ago
# async def _at_day_end(self, data=None):
7 years ago
# pass
7 years ago
async def _at_night_start(self, data=None):
if self.channel is None:
return
await self.game.generate_targets(self.channel)
7 years ago
await self.channel.send(" ".join(player.mention for player in self.players))
self.killer = random.choice(self.players)
7 years ago
7 years ago
await self.channel.send("{} has been selected as tonight's killer".format(self.killer.member.display_name))
7 years ago
async def _at_night_end(self, data=None):
if self.channel is None:
return
target_id = None
7 years ago
vote_list = list(self.vote_results.values())
if vote_list:
7 years ago
target_id = max(set(vote_list), key=vote_list.count)
7 years ago
print("Target id: {}\nKiller: {}".format(target_id, self.killer.member.display_name))
if target_id is not None and self.killer:
7 years ago
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))
7 years ago
else:
await self.channel.send("**No kill will be attempted tonight...**")
7 years ago
# async def _at_visit(self, data=None):
7 years ago
# pass
#
7 years ago
# async def register_players(self, *players):
7 years ago
# """
# Extend players by passed list
# """
# self.players.extend(players)
#
7 years ago
# async def remove_player(self, player):
7 years ago
# """
# Remove a player from player list
# """
# if player.id in self.players:
# self.players.remove(player)
7 years ago
7 years ago
async def vote(self, target, author, target_id):
7 years ago
"""
Receive vote from game
"""
7 years ago
self.vote_results[author.id] = target_id
7 years ago
7 years ago
await self.channel.send("{} has voted to kill {}".format(author.mention, target.member.display_name))