def kill_queue_test(): db.add_kill(12738912739821,"Barber") db.add_kill(12347892374923,"White Werewolf","7289347983274") assert db.get_kill() == [1,u'12738912739821',u'Barber',u''] assert db.get_kill() == [2,u'12347892374923',u'White Werewolf',u'7289347983274'] assert db.get_kill() == None reset.reset(True) return True
def night(): """Start the second part of the day. The function assumes all polls have been evaluated, and that looking after attacks can begin. The function returns a Mailbox.""" threat = db.get_kill() answer = Mailbox().log("**Results from daily deaths:**") if dy.get_stage() == "Night": return Mailbox().respond("Sure, man. Whatever.") while threat != None: answer = roles.attack(threat[1],threat[2],threat[3],answer) threat = db.get_kill() for player in db.player_list(True): # Give potential night uses user_role = db_get(player,'role') for i in range(len(roles.night_users)): if user_role in roles.night_users[i]: # Give one-time users their one-time power if i == 0: if dy.day_number() == 0: db_set(player,'uses',1) break if user_role in ['White Werewolf'] and dy.day_number() % 2 == 0: i = 1 db_set(player,'uses',i) answer.msg(power.power(user_role),db_get(player,'channel')) break answer.story(evening.evening(db.get_deadies())) db.delete_deadies() # Add polls for player in db.player_list(): if db_get(player,'role') in pos.wolf_pack: for channel_id in db.get_secret_channels('Werewolf'): answer.new_poll(channel_id,'wolf',db.random_wolf(),story_text('wolf')) break for player in db.player_list(): if db_get(player,'role') == 'Cult Leader': for channel_id in db.get_secret_channels('Cult_Leader'): answer.new_poll(channel_id,'cult',db.random_cult(),story_text('cult')) break for channel_id in db.get_secret_channels('Swamp'): answer.new_poll(channel_id,'thing','',story_text('thing')) answer.log("```Night {}```".format(dy.day_number())) dy.set_stage("Night") return answer
def day(): """Start the second part of the day. The function assumes all polls have been evaluated, and that looking after attacks can begin. The function returns a Mailbox.""" threat = db.get_kill() answer = Mailbox().log("**Results from night attacks:**") if dy.get_stage() == "Day": return Mailbox().respond("Sure, man. Whatever.") while threat != None: answer = roles.attack(threat[1], threat[2], threat[3], answer) threat = db.get_kill() for player in db.player_list(True): # Give potential day uses user_role = db_get(player, 'role') for i in range(len(roles.day_users)): if user_role in roles.day_users[i]: # Give one-time users their one-time power if i == 0: if dy.day_number() == 0: db_set(player, 'uses', 1) break db_set(player, 'uses', i) answer.msg(power.power(user_role), db_get(player, 'channel')) break answer.story(morning.story_time(db.get_deadies())) db.delete_deadies() db.delete_hookers() # Add polls if dy.day_number() != 0: answer.new_poll(dy.voting_booth(), 'lynch', '', story_text('lynch')) if dy.get_mayor() == 0: answer.new_poll(dy.voting_booth(), 'Mayor', '', story_text('Mayor')) elif dy.get_reporter() == 0: answer.new_poll(dy.voting_booth(), 'Reporter', '', story_text('Reporter')) dy.next_day() dy.set_stage('Day') answer.log("```Day {}```".format(dy.day_number())) return answer