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/role.py

180 lines
5.1 KiB

4 years ago
import inspect
4 years ago
import logging
from werewolf.listener import WolfListener, wolflistener
4 years ago
4 years ago
log = logging.getLogger("red.fox_v3.werewolf.role")
class Role(WolfListener):
"""
Base Role class for werewolf game
4 years ago
7 years ago
Category enrollment guide as follows (category property):
Town:
1: Random, 2: Investigative, 3: Protective, 4: Government,
5: Killing, 6: Power (Special night action)
4 years ago
7 years ago
Werewolf:
11: Random, 12: Deception, 15: Killing, 16: Support
4 years ago
7 years ago
Neutral:
21: Benign, 22: Evil, 23: Killing
4 years ago
7 years ago
Example category:
category = [1, 5, 6] Could be Veteran
category = [1, 5] Could be Bodyguard
category = [11, 16] Could be Werewolf Silencer
4 years ago
Action priority guide as follows (on_event function):
_at_night_start
7 years ago
0. No Action
1. Detain actions (Jailer/Kidnapper)
7 years ago
2. Group discussions and choose targets
4 years ago
_at_night_end
0. No Action
1. Self actions (Veteran)
2. Target switching and role blocks (bus driver, witch, escort)
3. Protection / Preempt actions (bodyguard/framer)
4. Non-disruptive actions (seer/silencer)
7 years ago
5. Disruptive actions (Killing)
6. Role altering actions (Cult / Mason / Shifter)
7 years ago
"""
7 years ago
7 years ago
rand_choice = False # Determines if it can be picked as a random role (False for unusually disruptive roles)
7 years ago
category = [0] # List of enrolled categories (listed above)
alignment = 0 # 1: Town, 2: Werewolf, 3: Neutral
channel_id = "" # Empty for no private channel
unique = False # Only one of this role per game
7 years ago
game_start_message = (
7 years ago
"Your role is **Default**\n"
"You win by testing the game\n"
7 years ago
"Lynch players during the day with `[p]ww vote <ID>`"
7 years ago
)
7 years ago
description = (
"This is the basic role\n"
7 years ago
"All roles are based on this Class\n"
7 years ago
"Has no special significance"
)
icon_url = None # Adding a URL here will enable a thumbnail of the role
def __init__(self, game):
super().__init__(game)
self.game = game
self.player = None
self.blocked = False
self.properties = {} # Extra data for other roles (i.e. arsonist)
7 years ago
4 years ago
# self.action_list = [
# (self._at_game_start, 1), # (Action, Priority)
# (self._at_day_start, 0),
# (self._at_voted, 0),
# (self._at_kill, 0),
# (self._at_hang, 0),
# (self._at_day_end, 0),
# (self._at_night_start, 0),
# (self._at_night_end, 0),
# (self._at_visit, 0),
# ]
7 years ago
7 years ago
def __repr__(self):
return self.__class__.__name__
4 years ago
# async def on_event(self, event, data):
# """
# See Game class for event guide
# """
#
# await self.action_list[event][0](data)
async def assign_player(self, player):
"""
Give this role a player
7 years ago
Can be used after the game has started (Cult, Mason, other role swap)
"""
7 years ago
player.role = self
self.player = player
7 years ago
async def get_alignment(self, source=None):
"""
Interaction for powerful access of alignment
(Village, Werewolf, Other)
Unlikely to be able to deceive this
"""
return self.alignment
7 years ago
async def see_alignment(self, source=None):
"""
Interaction for investigative roles attempting
to see alignment (Village, Werewolf Other)
"""
return "Other"
7 years ago
async def get_role(self, source=None):
7 years ago
"""
Interaction for powerful access of role
Unlikely to be able to deceive this
"""
7 years ago
return "Role"
7 years ago
async def see_role(self, source=None):
7 years ago
"""
Interaction for investigative roles.
More common to be able to deceive this action
7 years ago
"""
7 years ago
return "Default"
7 years ago
4 years ago
@wolflistener("at_game_start")
7 years ago
async def _at_game_start(self, data=None):
if self.channel_id:
await self.game.register_channel(self.channel_id, self)
7 years ago
await self.player.send_dm(self.game_start_message) # Maybe embeds eventually
4 years ago
# async def _at_day_start(self, data=None):
# pass
#
# async def _at_voted(self, data=None):
# pass
#
# async def _at_kill(self, data=None):
# pass
#
# async def _at_hang(self, data=None):
# pass
#
# async def _at_day_end(self, data=None):
# pass
#
# async def _at_night_start(self, data=None):
# pass
#
# async def _at_night_end(self, data=None):
# pass
#
# async def _at_visit(self, data=None):
# pass
7 years ago
async def kill(self, source):
"""
Called when someone is trying to kill you!
Can you do anything about it?
7 years ago
self.player.alive is now set to False, set to True to stay alive
"""
pass
7 years ago
async def visit(self, source):
"""
Called whenever a night action targets you
Source is the player who visited you
"""
pass
async def choose(self, ctx, data):
7 years ago
"""Handle night actions"""
7 years ago
pass