Backend QoL adjustments for cub

Eliminate stupid get_final_role event and instead simply don't add cubs
to var.FINAL_ROLES when they grow up into wolf. That var is only ever
used for end-game stats readouts, so there is no mechanical impact in
omitting adding something there.

Add new event to experimental stats to allow roles like cub and clone to
reflect role swaps when players die. Cubs growing up now shows up in
experimental stats.
This commit is contained in:
skizzerz 2017-02-08 10:40:18 -06:00
parent 0a18f8e70e
commit dd76f79603
2 changed files with 22 additions and 8 deletions

View File

@ -404,13 +404,26 @@ def on_chk_win(evt, cli, var, rolemap, lpl, lwolves, lrealwolves):
rolemap["wolf cub"].remove(wc)
did_something = True
if var.PHASE in var.GAME_PHASES:
var.FINAL_ROLES[wc] = "wolf"
# don't set cub's FINAL_ROLE to wolf, since we want them listed in endgame
# stats as cub still.
pm(cli, wc, messages["cub_grow_up"])
debuglog(wc, "(wolf cub) GROW UP")
if did_something:
evt.prevent_default = True
evt.stop_processing = True
@event_listener("reconfigure_stats")
def on_reconfigure_stats(evt, cli, var, stats):
# TODO: split into cub
if "wolf cub" not in stats or stats["wolf cub"] == 0:
return
for role in var.WOLF_ROLES - {"wolf cub"}:
if role in stats and stats[role] > 0:
break
else:
stats["wolf"] = stats["wolf cub"]
stats["wolf cub"] = 0
@event_listener("succubus_visit")
def on_succubus_visit(evt, cli, var, nick, victim):
if var.ROLES["succubus"].intersection(KILLS.get(victim, ())):

View File

@ -1980,7 +1980,6 @@ def stop_game(cli, winner="", abort=False, additional_winners=None, log=True):
origroles = {} #nick based list of original roles
rolelist = copy.deepcopy(var.ORIGINAL_ROLES)
event = Event("get_final_role", {"role": None})
for role, playerlist in var.ORIGINAL_ROLES.items():
if role in var.TEMPLATE_RESTRICTIONS.keys():
continue
@ -1988,13 +1987,11 @@ def stop_game(cli, winner="", abort=False, additional_winners=None, log=True):
player = p #with (dced) still in
if p.startswith("(dced)"):
p = p[6:]
event.data["role"] = var.FINAL_ROLES.get(p, role)
event.dispatch(cli, var, p, role)
# TODO: make cub use the event instead of hardcoding it here
if role != event.data["role"] and (event.data["role"] != "wolf" or role != "wolf cub"):
final = var.FINAL_ROLES.get(p, role)
if role != final:
origroles[p] = role
rolelist[role].remove(player)
rolelist[event.data["role"]].add(p)
rolelist[final].add(p)
prev = False
for role in role_order():
if len(rolelist[role]) == 0:
@ -2673,12 +2670,16 @@ def del_player(cli, nick, forced_death=False, devoice=True, end_game=True, death
# For every possible role this person is, try to deduct 1 from that role's count in our stat sets
# if a stat set doesn't contain the role, then that would lead to an impossible condition and therefore
# that set is not added to newstats to indicate that set is no longer possible
# The reconfigure_stats event can be used to shift things around (for example, it is used to reflect wolf cub growing up)
event = Event("reconfigure_stats", {})
for p in possible:
for rs in var.ROLE_STATS:
d = dict(rs)
if p in d and d[p] >= 1:
d[p] -= 1
newstats.add(frozenset(d.items()))
event.dispatch(cli, var, d)
if min(d.values()) >= 0:
newstats.add(frozenset(d.items()))
var.ROLE_STATS = frozenset(newstats)
if devoice and (var.PHASE != "night" or not var.DEVOICE_DURING_NIGHT):