Make wolf chk_nightdone less hacky

This commit is contained in:
skizzerz 2018-06-26 00:06:30 -05:00
parent 4f5d3f1371
commit c79fbb03c1

View File

@ -309,26 +309,25 @@ def on_exchange(evt, var, actor, target, actor_role, target_role):
@event_listener("chk_nightdone", priority=3) @event_listener("chk_nightdone", priority=3)
def on_chk_nightdone(evt, var): def on_chk_nightdone(evt, var):
if not var.DISEASED_WOLVES: nevt = Event("wolf_numkills", {"numkills": 1})
evt.data["actedcount"] += len(KILLS) nevt.dispatch(var)
evt.data["nightroles"].extend(get_players(CAN_KILL)) num_kills = nevt.data["numkills"]
wofls = [x for x in get_players(CAN_KILL) if x.nick not in var.SILENCED]
if var.DISEASED_WOLVES or num_kills == 0 or len(wofls) == 0:
return
@event_listener("chk_nightdone", priority=20) evt.data["nightroles"].extend(wofls)
def on_chk_nightdone2(evt, var): evt.data["actedcount"] += len(KILLS)
if not evt.prevent_default: evt.data["nightroles"].append(users.FakeUser.from_nick("@WolvesAgree@"))
nevt = Event("wolf_numkills", {"numkills": 1}) # check if wolves are actually agreeing or not;
nevt.dispatch(var) # only count agreement_user if they are
num_kills = nevt.data["numkills"] # (this is *slighty* less hacky than deducting 1 from actedcount as we did previously)
wofls = [x for x in get_players(CAN_KILL) if x.nick not in var.SILENCED] kills = set()
if num_kills == 0 or len(wofls) == 0: for ls in KILLS.values():
return kills.update(ls)
# flatten KILLS # check if wolves are actually agreeing
kills = set() if len(kills) == num_kills:
for ls in KILLS.values(): evt.data["actedcount"] += 1
kills.update(ls)
# check if wolves are actually agreeing
if len(kills) != num_kills:
evt.data["actedcount"] -= 1
@event_listener("transition_night_end", priority=2) @event_listener("transition_night_end", priority=2)
def on_transition_night_end(evt, var): def on_transition_night_end(evt, var):