Skip to content

Commit

Permalink
sleepy updates
Browse files Browse the repository at this point in the history
- Remove traitor
- Ensure crow and half the wolves are ineligible to become dullahan
  targets
- Make nightmare slightly easier to pass
  • Loading branch information
skizzerz committed Jan 7, 2024
1 parent 90f5ef4 commit 8f37de1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
26 changes: 22 additions & 4 deletions src/gamemodes/sleepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SleepyMode(GameMode):
def __init__(self, arg=""):
super().__init__(arg)
self.ROLE_GUIDE = {
10: ["wolf", "werecrow", "traitor", "cultist", "seer", "prophet", "priest", "dullahan", "cursed villager", "blessed villager"],
10: ["wolf", "werecrow", "cultist", "seer", "prophet", "priest", "dullahan", "cursed villager", "blessed villager"],
12: ["wolf(2)", "vigilante"],
15: ["wolf(3)", "detective", "vengeful ghost"],
18: ["wolf(4)", "harlot", "monster"],
Expand Down Expand Up @@ -80,7 +80,14 @@ def teardown(self):
self.on_path.clear()

def dullahan_targets(self, evt: Event, var: GameState, dullahan, max_targets):
evt.data["targets"].update(var.roles["priest"])
evt.data["targets"].update(get_players(var, ("priest",)))
evt.data["exclude"].update(get_players(var, ("werecrow",)))
# also exclude half the wolves (counting crow, rounded down) to ensure dulla doesn't just completely murder wolfteam
wolves = set(get_players(var, ("wolf",)))
num_exclusions = int((len(wolves) + 1) / 2)
if num_exclusions > 0:
evt.data["exclude"].update(random.sample(list(wolves), num_exclusions))
wolves.difference_update(evt.data["exclude"])

def setup_nightmares(self, evt: Event, var: GameState):
pl = get_players(var)
Expand Down Expand Up @@ -124,8 +131,19 @@ def do_nightmare(self, var: GameState, target, night):
f1dir.remove("s")
f2dir.remove("s")
self.correct[target][i] = random.choice(corrdir)
self.fake1[target][i] = random.choice(f1dir)
self.fake2[target][i] = random.choice(f2dir)
# ensure fake1 and correct share the first choice but have different second choices
# and ensure fake2 has a different first choice from everything else
if i == 0:
self.fake1[target][i] = self.correct[target][i]
f2dir.remove(self.correct[target][i])
self.fake2[target][i] = random.choice(f2dir)
elif i == 1:
f1dir.remove(self.correct[target][i])
self.fake1[target][i] = random.choice(f1dir)
self.fake2[target][i] = random.choice(f2dir)
else:
self.fake1[target][i] = random.choice(f1dir)
self.fake2[target][i] = random.choice(f2dir)
self.prev_direction[target] = "n"
self.start_direction[target] = "n"
self.on_path[target] = set()
Expand Down
15 changes: 8 additions & 7 deletions src/roles/dullahan.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ def on_new_role(evt: Event, var: GameState, player: User, old_role: Optional[str
del TARGETS[player]

if player not in TARGETS and evt.data["role"] == "dullahan":
ps = get_players(var)
max_targets = math.ceil(8.1 * math.log(len(ps), 10) - 5)
pl = get_players(var)
max_targets = math.ceil(8.1 * math.log(len(pl), 10) - 5)
TARGETS[player] = UserSet()

dull_targets = Event("dullahan_targets", {"targets": TARGETS[player]}) # support sleepy
dull_targets = Event("dullahan_targets", {"targets": set(), "exclude": set()})
dull_targets.dispatch(var, player, max_targets)
TARGETS[player].update(evt.data["targets"] - evt.data["exclude"])

ps.remove(player)
while len(TARGETS[player]) < max_targets:
target = random.choice(ps)
ps.remove(target)
pl = list(set(pl) - evt.data["exclude"] - {player})
while pl and len(TARGETS[player]) < max_targets:
target = random.choice(pl)
pl.remove(target)
TARGETS[player].add(target)

@event_listener("swap_role_state")
Expand Down

0 comments on commit 8f37de1

Please sign in to comment.