Skip to content

Commit

Permalink
Merge branch 'pactbreaker'
Browse files Browse the repository at this point in the history
  • Loading branch information
skizzerz committed Nov 8, 2023
2 parents bc37af7 + 50d5775 commit 37bd763
Show file tree
Hide file tree
Showing 11 changed files with 651 additions and 37 deletions.
79 changes: 78 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"masquerade": "masquerade",
"mudkip": "mudkip",
"noreveal": "noreveal",
"pactbreaker": "pactbreaker",
"random": "random",
"rapidfire": "rapidfire",
"roles": "roles",
Expand Down Expand Up @@ -230,6 +231,8 @@
"south": ["south", "s"],
"west": ["west", "w"],
"feed": ["feed"],
"forest": ["forest"],
"square": ["square"],

"leave opt force": ["-force", "--force"],

Expand Down Expand Up @@ -709,7 +712,7 @@
"leave_death": "{0:@} died due to falling off a cliff. The {1!role:bold} is lost to the ravine forever.",
"leave_death_no_reveal": "{0:@} died due to falling off a cliff.",
"leave_game_ingame_safeguard": "The game already started! If you still want to quit, use \"{=leave!command:!} {=leave opt force!command}\".",
"villagers_lynch": "The villagers must now vote for whom to kill. Use \"{=lynch!command:!} <nick>\" to cast your vote. {0} votes are required to kill.",
"villagers_vote": "The villagers must now vote for whom to kill. Use \"{=lynch!command:!} <nick>\" to cast your vote. {0} votes are required to kill.",
"random_clone": "Because you forgot to select someone to clone at night, you are now cloning {0:@}.",
"random_matchmaker": "Because you forgot to choose lovers at night, two lovers have been selected for you.",
"totem_retarget": "It seems that {0:@} now has the totem you gave out to {1:@} last night.",
Expand Down Expand Up @@ -1424,6 +1427,80 @@
"boreal_revealroles": "hunger level {0}",
"sustenance_totem": "The player who is given the sustenance totem will not starve naturally tonight. Alternatively, you may give this totem to the tribe instead of another player by using \"feed\".",
"hunger_totem": "The player who is given the hunger totem will become hungrier and may die of starvation. Alternatively, you may give this totem to the tribe instead of another player by using \"feed\".",
"pactbreaker_villagers_vote": "The villagers must now vote for whom to put into the stocks. Use \"{=lynch!command:!} <nick>\" to cast your vote or \"{=abstain!command:!}\" to keep the stocks empty tonight. {0} votes are required to put someone in the stocks.",
"pactbreaker_vigilante_win": "Game over! The village has eliminated the vampires and wolves, allowing them to live in peace moving forwards.",
"pactbreaker_wolf_win": "Game over! The village has dealt with the vampires and ousted the vigilante, allowing them to re-establish their protection pact with the wolves.",
"pactbreaker_vampire_win": "Game over! The vampires have overrun the village, making them the new masters of the town.",
"pactbreaker_no_visit": "You are locked in the stocks tonight and unable to visit other locations.",
"pactbreaker_wolf_notify": "You are {=wolf!role:article} {=wolf!role:bold}. It is your job to eliminate the {=vampire!role:plural} and {=vigilante!role:plural} to re-establish your pact with the village.\n{=pactbreaker_notify!message}",
"pactbreaker_vampire_notify": "You are {=vampire!role:article} {=vampire!role:bold}. It is your job to kill all the villagers.\n{=pactbreaker_notify!message}",
"pactbreaker_vigilante_notify": "You are {=vigilante!role:article} {=vigilante!role:bold}. It is your job to eliminate the {=wolf!role:plural} and {=vampire!role:plural} to end their threat over the village.\n{=pactbreaker_notify!message}",
"pactbreaker_villager_notify": "You are {=villager!role:article} {=villager!role:bold}. It is your job to either re-establish the pact with the {=wolf!role:plural} by killing the {=vigilante!role:plural} and {=vampire!role:plural} or to help the {=vigilante!role:plural} end the threat the {=wolf!role:plural} and {=vampire!role:plural} cause.\n{=pactbreaker_notify!message}",
"pactbreaker_notify": "You may visit another player's house by using \"{=visit!command} <nick>\"; you can also visit the {=forest!command:bold} or {=square!command:bold}. Visiting allows you to collect evidence about other players. Alternatively, you can stay home by using \"{=pass!command}\" to make it harder for other players to collect evidence about you.",
"pactbreaker_visiting_forest": "You have chosen to visit the forest tonight.",
"pactbreaker_visiting_square": "You have chosen to visit the village square tonight.",
"pactbreaker_visiting_house": "You have chosen to visit {0}'s house tonight.",
"pactbreaker_relay_visit_forest": "{0:@} is visiting the forest tonight.",
"pactbreaker_relay_visit_square": "{0:@} is visiting the village square tonight.",
"pactbreaker_relay_visit_house": "{0:@} is visiting {1}'s house tonight.",
"pactbreaker_forest_empty": "Your search of the forest last night did not turn up any useful evidence.",
"pactbreaker_square_empty": "Your search of the village square last night did not turn up any useful evidence.",
"pactbreaker_square_kill": "Knowing that {0:@} is {1!role:article} {1!role:bold}, you mercilessly kill them with your silver crossbow while they are vulnerable in the stocks.",
"pactbreaker_hunter_vampire": "Prowling the area last night, you come across {0:@} in the dim moonlight and launch an attack. However, they quickly rebuff you and escape, a sure sign that they are {=vampire!role:article} {=vampire!role:bold}.",
"pactbreaker_hunted_vampire": "While out last night, you are suddenly pounced upon by a large werewolf! You manage to escape, but are positive they now know of your vampirism as anyone else would have certainly died from the attack.",
"pactbreaker_hunter": "Prowling the area last night, you come across {0:@} in the dim moonlight and launch an attack. They are too surprised to run or fight back, and quickly die from the onslaught.",
"pactbreaker_hunter_square": "Prowling the area last night, you come across {0:@} in the stocks and launch an attack. They are unable to run or fight back, and quickly die from the onslaught.",
"pactbreaker_hunted": "While out last night, you are suddenly pounced upon by a large werewolf! It is the last thing you see...",
"pactbreaker_drain": "While out last night, you spot {0:@} alone and unaware of your presence. You quickly close in for a quick meal and vanish back into the shadows before they can clearly see who you are.",
"pactbreaker_drain_kill": "While out last night, you spot {0:@} alone and unaware of your presence. You quickly close in for a quick meal, draining them fully and killing them.",
"pactbreaker_drain_turn": "While out last night, you spot {0:@} alone and unaware of your presence. You quickly close in for a quick meal, draining them fully. Before they die, you give them a bit of your own blood, turning them into {=vampire!role:article} {=vampire!role}.",
"pactbreaker_drained": "While out last night, you are suddenly overtaken by a vampire! They drain your blood, and your vision blurs to the point where you cannot make out your assailant before they retreat. You feel lightheaded and think that another similar encounter may kill you.",
"pactbreaker_drained_dead": "While out last night, you are suddenly overtaken by a vampire! They drain the rest of your blood as your consciousness fades away...",
"pactbreaker_drained_vigilante": "While out last night, you are suddenly overtaken by a vampire again! They drain the rest of your blood as your consciousness fades away. Shortly after, you reawaken in your own home with an unnatural hunger. It seems you have become {=vampire!role:article} {=vampire!role:bold} yourself!",
"pactbreaker_stocks": "Examining {0:@} while they are in the stocks leads you to the conclusion that they are {1!role:article} {1!role:bold}!",
"pactbreaker_exposed": "You spot {0:@} while out last night and note the silver crossbow they appear to be carrying. It seems they are {=vigilante!role:article} {=vigilante!role:bold}!",
"pactbreaker_house_kill": "Knowing that {0:@} is {1!role:article} {1!role:bold}, you sneak into their house and fire a silver crossbow bolt at them before they have the chance to react.",
"pactbreaker_house_killed": "A sharp pain alerts you to an intruder in your house as you get struck by a well-placed crossbow bolt. You spin around to look, the triumphant face of the {=vigilante!role} being the last thing you see...",
"pactbreaker_house_vampire": "Knowing that {0:@} is {=vampire!role:article} {=vampire!role:bold}, you search their house for the charm allowing them to survive in the sunlight. You eventually find and destroy it, ensuring that they will become dust by dawn.",
"pactbreaker_house_evidence_1": "While searching through {0:@}'s house, you discover proof that they are {1!role:article} {1!role:bold}!",
"pactbreaker_house_evidence_2": "{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, you discover proof that they are {1!role:article} {1!role:bold}!",
"pactbreaker_house_empty_1": "Your search of {0:@}'s house last night did not turn up any useful evidence.",
"pactbreaker_house_empty_2": "{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. However, you were unable to discover any useful evidence through your observations.",
"pactbreaker_hobby_message": [
"In your free time, you enjoy knitting. Everyone else has a hobby too, which you can discover by visiting their house.",
"In your free time, you enjoy reading. Everyone else has a hobby too, which you can discover by visiting their house.",
"In your free time, you enjoy cooking. Everyone else has a hobby too, which you can discover by visiting their house.",
"In your free time, you enjoy camping. Everyone else has a hobby too, which you can discover by visiting their house.",
"In your free time, you enjoy woodworking. Everyone else has a hobby too, which you can discover by visiting their house.",
"In your free time, you enjoy painting. Everyone else has a hobby too, which you can discover by visiting their house."
],
"pactbreaker_hobby_evidence_1": [
"While searching through {0:@}'s house, you discover needles and balls of yarn. It appears they enjoy knitting!",
"While searching through {0:@}'s house, you discover multiple full bookshelves. It appears they enjoy reading!",
"While searching through {0:@}'s house, you discover a pantry full of exotic ingredients. It appears they enjoy cooking!",
"While searching through {0:@}'s house, you discover a large backpack and a tent. It appears they enjoy camping!",
"While searching through {0:@}'s house, you discover a workshop filled with lumber and tools. It appears they enjoy woodworking!",
"While searching through {0:@}'s house, you discover multiple canvases in various states of completion. It appears they enjoy painting!"
],
"pactbreaker_hobby_evidence_2": [
"{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, as you see them knitting!",
"{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, as you see them reading!",
"{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, as you see them cooking!",
"{0:@} seems to have stayed home tonight, so you remain hidden outside. You spot a tent in their backyard that appears to be airing out, so you assume that they enjoy camping!",
"{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, as you see them woodworking!",
"{0:@} seems to have stayed home tonight, so you remain hidden outside looking through an open window. Your patience pays off, as you see them painting!"
],
"pactbreaker_forest_evidence": [
"While investigating the forest, you discover a mitten caught in a bush. It appears that one of the {=wolf!role:plural} is into knitting!",
"While investigating the forest, you discover a book lost in a creek. It appears that one of the {=wolf!role:plural} enjoys reading!",
"While investigating the forest, you discover a broken jar of spices alongside a path. It appears that one of the {=wolf!role:plural} is into cooking!",
"While investigating the forest, you discover the remains of a campfire in a clearing. It appears that one of the {=wolf!role:plural} is into camping!",
"While investigating the forest, you discover a well-made birdhouse hanging from a tree. It appears that one of the {=wolf!role:plural} is into woodworking!",
"While investigating the forest, you discover splatters of paint among the foliage. It appears that one of the {=wolf!role:plural} is into painting!"
],
"pactbreaker_vote": [
"The village has decided to lock {0:@} into the stocks until tomorrow."
],
"roles_players": "There {=is,are:plural({0})} {0:bold} playing.",
"roles_gamemode": "Using the {0} game mode.",
"roles_need_gamemode": "Please specify a game mode by using \"{=roles!command:!} <mode>\".",
Expand Down
5 changes: 2 additions & 3 deletions src/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from datetime import datetime

from src import users
from src.utilities import singular
from src.messages import messages, LocalRole
from src.cats import role_order

Expand Down Expand Up @@ -436,8 +435,8 @@ def get_game_stats(mode, size):
elif row[0] == "everyone":
winner = messages["db_gstats_everyone"]
else:
# FIXME: kill off singular() and convert the db to just store the role key directly instead of a plural
winner = LocalRole(singular(row[0])).singular.title()
# FIXME: convert the db to just store the role key directly instead of a plural
winner = LocalRole.from_en(row[0]).singular.title()

bits.append(messages["db_gstats_win"].format(winner, row[1], row[1]/total_games))
bits.append(messages["db_gstats_total"].format(total_games))
Expand Down
25 changes: 18 additions & 7 deletions src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ def get_participants(var: Optional[GameState | PregameState]) -> list[User]:
evt.dispatch(var)
return evt.data["players"]

def get_target(wrapper: MessageDispatcher, message: str, *, allow_self: bool = False, allow_bot: bool = False, not_self_message: str = "no_target_self") -> Optional[User]:
def get_target(wrapper: MessageDispatcher,
message: str,
*,
allow_self: bool = False,
allow_bot: bool = False,
not_self_message: str = "no_target_self",
scope: Optional[Iterable[User]] = None) -> Optional[User]:
"""Autocomplete a target for an in-game command.
:param MessageDispatcher wrapper: Message context
:param str message: Text to complete against
:param bool allow_self: Whether to allow the current player as the target
:param bool allow_bot: Whether to allow the bot as the target
:param str not_self_message: If allow_self is False, the message key to output if we matched ourselves
:param wrapper: Message context
:param message: Text to complete against
:param allow_self: Whether to allow the current player as the target
:param allow_bot: Whether to allow the bot as the target
:param not_self_message: If allow_self is False, the message key to output if we matched ourselves
:param scope: Scope to search through, modified per allow_self and allow_bot. If None, searches all alive players.
:returns: The matched target, or None if no matches
:rtype: Optional[User]
"""
Expand All @@ -91,7 +98,11 @@ def get_target(wrapper: MessageDispatcher, message: str, *, allow_self: bool = F
wrapper.pm(messages["not_enough_parameters"])
return

players = get_players(wrapper.game_state)
if scope is None:
players = get_players(wrapper.game_state)
else:
players = list(scope)

if not allow_self and wrapper.source in players:
players.remove(wrapper.source)

Expand Down
Loading

0 comments on commit 37bd763

Please sign in to comment.