def on_transition_day_begin(evt, var): # Select random totem recipients if shamans didn't act pl = get_players() for shaman in get_all_players(("shaman", )): if is_silent(var, shaman): continue ps = pl[:] for given in itertools.chain.from_iterable(LASTGIVEN[shaman].values()): if given in ps: ps.remove(given) for given in itertools.chain.from_iterable(SHAMANS[shaman].values()): if given in ps: ps.remove(given) for totem, count in TOTEMS[shaman].items(): mustgive = count - len(SHAMANS[shaman][totem]) for i in range(mustgive): if ps: target = random.choice(ps) ps.remove(target) dispatcher = MessageDispatcher(shaman, shaman) given = give_totem(var, dispatcher, target, totem, key="shaman_success_random_known", role="shaman") if given: SHAMANS[shaman][totem].append(given[0])
def on_transition_day_begin(evt, var): # Select random totem recipients if shamans didn't act pl = get_players() for shaman in get_players(("wolf shaman", )): if shaman not in SHAMANS and not is_silent(var, shaman): ps = pl[:] if shaman in LASTGIVEN: if LASTGIVEN[shaman] in ps: ps.remove(LASTGIVEN[shaman]) if ps: target = random.choice(ps) dispatcher = MessageDispatcher(shaman, shaman) SHAMANS[shaman] = give_totem( var, dispatcher, target, prefix=messages["random_totem_prefix"], role="wolf shaman", msg=" of {0}".format(TOTEMS[shaman])) relay_wolfchat_command(shaman.client, shaman.nick, messages["shaman_wolfchat"].format( shaman, target), ("wolf shaman", ), is_wolf_command=True) else: LASTGIVEN[shaman] = None elif shaman not in SHAMANS: LASTGIVEN[shaman] = None
def on_transition_day_begin(evt, var): # Select random totem recipients if shamans didn't act pl = get_players() for shaman in get_players(("wolf shaman", )): if is_silent(var, shaman): continue ps = pl[:] for given in itertools.chain.from_iterable(LASTGIVEN[shaman].values()): if given in ps: ps.remove(given) for given in itertools.chain.from_iterable(SHAMANS[shaman].values()): if given in ps: ps.remove(given) for totem, count in TOTEMS[shaman].items(): mustgive = count - len(SHAMANS[shaman][totem]) for i in range(mustgive): if ps: target = random.choice(ps) ps.remove(target) dispatcher = MessageDispatcher(shaman, shaman) given = give_totem(var, dispatcher, target, prefix=messages["random_totem_prefix"], role="wolf shaman", msg=" of {0}".format(totem)) if given: relay_wolfchat_command( shaman.client, shaman.nick, messages["shaman_wolfchat"].format(shaman, target), ("wolf shaman", ), is_wolf_command=True) SHAMANS[shaman][totem].append(given[0])
def on_transition_day_begin(evt, var): # select a random target for VG if they didn't kill wolves = get_players(Wolfteam) villagers = get_players(All - Wolfteam) for ghost, target in GHOSTS.items(): if target[0] == "!" or is_silent(var, ghost): continue if ghost not in KILLS: choice = None if target == "wolf": choice = wolves.copy() elif target == "villager": choice = villagers.copy() if choice: KILLS[ghost] = random.choice(choice)
def on_transition_day(evt, var): # Select a random target for assassin that isn't already going to die if they didn't target pl = get_players() for ass in get_all_players(("assassin",)): if ass not in TARGETED and not is_silent(var, ass): ps = pl[:] ps.remove(ass) for victim in set(evt.data["victims"]): if victim in ps: ps.remove(victim) if ps: target = random.choice(ps) TARGETED[ass] = target ass.send(messages["assassin_random"].format(target)) PREV_ACTED.update(TARGETED.keys())
def on_transition_day_begin(evt, var): # Select random totem recipients if shamans didn't act pl = get_players() for shaman in get_players(("shaman",)): if shaman not in SHAMANS and not is_silent(var, shaman): ps = pl[:] if shaman in LASTGIVEN: if LASTGIVEN[shaman] in ps: ps.remove(LASTGIVEN[shaman]) if ps: target = random.choice(ps) dispatcher = MessageDispatcher(shaman, shaman) SHAMANS[shaman] = give_totem(var, dispatcher, target, prefix=messages["random_totem_prefix"], role="shaman", msg=" of {0}".format(TOTEMS[shaman])) else: LASTGIVEN[shaman] = None elif shaman not in SHAMANS: LASTGIVEN[shaman] = None
def on_chk_nightdone(evt, var): nevt = Event("wolf_numkills", {"numkills": 1, "message": ""}) nevt.dispatch(var) num_kills = nevt.data["numkills"] wofls = [x for x in get_players(Wolf & Killer) if not is_silent(var, x)] if not num_kills or not wofls: return fake = users.FakeUser.from_nick("@WolvesAgree@") evt.data["nightroles"].extend(wofls) evt.data["acted"].extend(KILLS) evt.data["nightroles"].append(fake) kills = set() for ls in KILLS.values(): kills.update(ls) # check if wolves are actually agreeing if len(kills) == num_kills: evt.data["acted"].append(fake)
def on_chk_nightdone(evt, var): nevt = Event("wolf_numkills", {"numkills": 1, "message": ""}) nevt.dispatch(var) num_kills = nevt.data["numkills"] wofls = [x for x in get_players(Wolf & Killer) if not is_silent(var, x)] if not num_kills or not wofls: return evt.data["nightroles"].extend(wofls) evt.data["actedcount"] += len(KILLS) evt.data["nightroles"].append(users.FakeUser.from_nick("@WolvesAgree@")) # check if wolves are actually agreeing or not; # only add to count if they actually agree # (this is *slighty* less hacky than deducting 1 from actedcount as we did previously) kills = set() for ls in KILLS.values(): kills.update(ls) # check if wolves are actually agreeing if len(kills) == num_kills: evt.data["actedcount"] += 1
def on_transition_day_begin(evt, var): # Select random totem recipients if shamans didn't act pl = get_players() for shaman in get_players(("crazed shaman", )): if shaman not in SHAMANS and not is_silent(var, shaman): ps = pl[:] if shaman in LASTGIVEN: if LASTGIVEN[shaman] in ps: ps.remove(LASTGIVEN[shaman]) if ps: target = random.choice(ps) dispatcher = MessageDispatcher(shaman, shaman) SHAMANS[shaman] = give_totem( var, dispatcher, target, prefix=messages["random_totem_prefix"], role="crazed shaman", msg="") else: LASTGIVEN[shaman] = None elif shaman not in SHAMANS: LASTGIVEN[shaman] = None