def disguise(user_id, victim_id, role): """This fuction is taking the tanner's action of disguising people. The function assumes the player is a participant and has the correct role, so make sure to have filtered this out already. The function returns a Mailbox. user_id -> the player who casts the spell victim_id -> the player upon whom the spell is cast role -> the role the player should be disguised as""" uses = int(db_get(user_id, 'uses')) if uses < 1: return Mailbox().respond( "I am sorry! You currently don't have the ability to disguise anyone!", True) user_channel = int(db_get(user_id, 'channel')) user_role = db_get(user_id, 'role') user_undead = int(db_get(user_id, 'undead')) victim_role = db_get(victim_id, 'role') victim_frozen = int(db_get(victim_id, 'frozen')) victim_abducted = int(db_get(victim_id, 'abducted')) if user_undead == 1: return Mailbox().dm( "I am sorry! You are undead, meaning you can no longer disguise people!", user_id, True) if victim_abducted == 1: return Mailbox().msg( "After having finished your great disguise, it seems like you couldn\'t find your target! Where have they gone off to?", user_channel, True) if victim_frozen == 1: return Mailbox().msg( "I am sorry, but <@{}> is too cold for that! You\'ll need a lot more than warm suit to get \'em warmed up." .format(victim_id), user_channel, True) db_set(user_id, 'uses', uses - 1) db_set(victim_id, 'fakerole', role) answer = Mailbox().msg( "You have successfully disguised <@{}> as the **{}**!".format( victim_id, role), user_channel) if uses - 1 > 0: answer.msg("You can disguise **{}** more players!".format(uses - 1), user_channel, True) else: answer.msg( "That\'s it for today! You can\'t disguise any more players.", user_channel, True) answer.log( "**{}** <@{}> has disguised <@{}>, the **{}**, as the **{}**!".format( user_role, user_id, victim_id, victim_role, role)) if victim_role == role: answer.log_add( "\n...does that sound stupid? *Of course!* But how are they supposed to know?" ) return answer
def freeze_all(user_id): """This function allows the ice king to potentially freeze all their guessed players. The function assumes the ice king is a participant, so make sure to have filtered this out already. The function returns a Mailbox. Keyword arguments: user_id -> the ice king's id""" uses = int(db_get(user_id,'uses')) if uses < 1: return Mailbox().respond("I am sorry! You currently don't have the ability to submit a freezing list!",True) db_set(user_id,'uses',uses - 1) user_channel = int(db_get(user_id,'channel')) user_undead = int(db_get(user_id,'undead')) correct = 0 incorrect = 0 for frozone in db.get_freezers(user_id): if not db.isParticipant(frozone[0]) or int(db_get(frozone[0],'abducted')) == 1: db.delete_freezer(user_id,frozone[0]) elif frozone[1] != db_get(frozone[0],'role'): incorrect += 1 else: correct += 1 if user_undead == 1: answer = Mailbox().msg("You have submitted a list that contains {} players. The result was **unsuccessful**. ".format(correct+incorrect),user_channel) answer.msg_add("This means that at least one role was incorrect!") answer.log("The **Undead** <@{}> has pretended to submit a freeze list.".format(user_id)) answer.dm("Hey, you're **Undead**, so this list would've failed anyway - but this helps a little to keep up your cover! 😉",user_id) return answer if incorrect > 0: answer = Mailbox().msg("You have submitted a list that contains {} players. The result was **unsuccessful**. ".format(correct+incorrect),user_channel) answer.msg_add("This means that at least one role was incorrect!") answer.log("The **Ice King** <@{}> has submitted an **unsuccessful** freeze list. ".format(user_id)) answer.log_add("The list contained {} guesses, of which {} were correct.".format(incorrect+correct,correct)) return answer # This will execute if all users on the list are correct. answer = Mailbox().msg("You have submitted a list that contains {} players. The result was **successful**!\n".format(correct),user_channel) if correct > 4: answer.msg_add("Congratulations! You guessed them all correctly! ").msg_react('🎉') answer.msg_add("Your guessed users will now be frozen.") for supersuit in db.get_freezers(user_id): db_set(supersuit[0],'frozen',1) db.delete_freezer(user_id,supersuit[0]) for channel_id in db.freeze(user_id): answer.edit_cc(channel_id,supersuit[0],2) # TODO: Give players access to frozen realm. return answer
def see(user_id,victim_id): """This function allows the user to see a given player of their choice. The function assumes the player is a participant and has the correct role, so make sure to have filtered this out already. The function returns a Mailbox. user_id -> the player who casts the spell victim_id -> the player who is being searched""" uses = int(db_get(user_id,'uses')) if uses < 1: return Mailbox().respond("I am sorry! You currently don't have the ability to see this player!",True) victim_emoji = db_get(victim_id,"emoji") victim_fakerole = db_get(victim_id,"fakerole") victim_role = db_get(victim_id,"role") victim_frozen = int(db_get(victim_id,'frozen')) victim_abducted = int(db_get(user_id,'abducted')) user_channel = int(db_get(user_id,"channel")) user_undead = int(db_get(user_id,'undead')) user_role = db_get(user_id,"role") if user_undead == 1: return Mailbox().dm("You are undead! This means that you can no longer inspect players. I\'m sorry!",user_id) if victim_abducted == 1: return Mailbox().msg("You tried to see <@{}>... but you couldn\'t find them! Almost as if they had disappeared in thin air!\nWhat happened?",user_channel,True) if victim_frozen == 1: return Mailbox().msg("You have tried to inspect <@{}>, but it turns out you couldn\'t reach them through the ice! Luckily, you had the opportunity to try again.",user_channel,True) db_set(user_id,'uses',uses - 1) # Follow this procedure if the user has been enchanted. # It ensures there is a 40% chance they get their guess wrong. if int(db_get(user_id,"enchanted")) == 1 and random.random() < 0.6: answer = Mailbox().msg("*NOTE: You are enchanted, your result has a 40% chance of showing as the Flute player*\n{} - <@{}> has the role of the `Flute Player`!".format(victim_emoji,victim_id),user_channel) answer.log("<@{0}> has attempted to see the role of <@{1}>. However, being enchanted made <@{1}> show as the **Flute Player!**".format(user_id,victim_id)) # Easter egg if victim_role == "Flute Player": answer.log("<@{}> has seen the role of <@{}> (**Flute Player**) due to their enchantment effects. But hey! They don't need to know they actually *are* a **Flute Player**!. 😉".format(user_id, victim_id)) return answer # TODO: Add undead thing. elif int(db_get(user_id,"enchanted")) == 1: answer = Mailbox().msg("*NOTE: You are enchanted, your result has a 40% chance of showing as the Flute player*\n{} - <@{}> has the role of the `{}`!".format(victim_emoji,victim_id,victim_fakerole),user_channel) else: answer = Mailbox().msg("{} - <@{}> has the role of the `{}`!".format(victim_emoji,victim_id,victim_fakerole),user_channel) if victim_fakerole != victim_role: answer.log("<@{}>, the town's **{}**, has attempted to see <@{}>, the **{}**. ".format(user_id,user_role,victim_id,victim_role)) return answer.log_add("However, they were disguised and appeared to be the **{}**!".format(victim_fakerole)) return answer.log("<@{}>, a **{}**, has seen the role of <@{}>, who had the role of the **{}**!".format(user_id,user_role,victim_id,victim_role))
def dog_follow(user_id,role): """This function allows the dog to choose a role to become. The function assumes the player is a cupid and has provided a role, so make sure to have filtered this out already. The role does not need to be Innocent, Cursed Civilian or Werewolf yet. The function returns a Mailbox. user_id -> the dog who chooses a role role -> the role they'd like to be""" uses = int(db_get(user_id,'uses')) if uses < 1: return Mailbox().respond("I am sorry! You currently cannot choose a role to become!",True) user_channel = int(db_get(user_id,'channel')) if role not in ['Innocent', 'Cursed Civilian', 'Werewolf']: return Mailbox().msg("I'm sorry, <{}>. Being a dog lets you choose a role, but it doesn't mean you can become ANYTHING.".format(user_id),user_channel,True) db_set(user_id,'uses',uses - 1) answer = Mailbox().msg("You have chosen to become the **{}**!".format(role),user_channel) answer.log("The **Dog** <@{}> has chosen to become a") if role == 'Innocent': answer.log_add('n **Innocent**!').dm("You have chosen to become an **Innocent**. Protect the town, kill all those wolves!",user_id) if role == 'Cursed Civilian': answer.log_add(' **Cursed Civilian**!').dm("You have chosen to become a **Cursed Civilian**! You will be part of the town... for now.",user_id) if role == 'Werewolf': answer.log_add(' **Werewolf**!').dm("You have chosen to become a **Werewolf**! You will now join the wolf pack!",user_channel) # TODO: Add dog to wolf channel db_set(user_id,'role',role) return answer
def see(user_id,victim_id): """This function allows the user to see a given player of their choice. The function assumes the player is a participant and has the correct role, so make sure to have filtered this out already. The function returns a Mailbox. user_id -> the player who casts the spell victim_id -> the player who is being searched""" uses = int(db_get(user_id,'uses')) if uses < 1: return Mailbox().respond("I am sorry! You currently don't have the ability to see this player!",True) db_set(user_id,'uses',uses - 1) victim_emoji = db_get(victim_id,"emoji") victim_fakerole = db_get(victim_id,"fakerole") victim_role = db_get(victim_id,"role") user_channel = int(db_get(user_id,"channel")) user_role = db_get(victim_id,"role") # Follow this procedure if the user has been enchanted. if int(db_get(user_id,"echanted")) == 1 and random.random() < 0.6: answer = Mailbox().msg("{} - <@{}> has the role of the `Flute Player`!".format(victim_emoji,victim_id),user_channel) answer.log("<@{0}> has attempted to see the role of <@{1}>. However, their enchantment effect worked, showing <@{1}> as the **Flute Player!**".format(user_id,victim_id)) # Easter egg if victim_role == "Flute Player": answer.log("I mean, <@{}> *is* a **Flute Player**, so it wouldn't really matter. But hey! They don't need to know. 😉") return answer answer = Mailbox().msg("{} - <@{}> has the role of the `{}`!".format(victim_emoji,victim_id,victim_fakerole),user_channel) if victim_fakerole != victim_role: answer.log("<@{}>, the town's **{}**, has attempted to see <@{}>, the **{}**. ".format(user_id,user_role,victim_id,victim_role)) return answer.log_add("However, they were disguised and appeared to be the **{}**!".format(victim_fakerole)) return answer.log("<@{}>, a **{}**, has seen the role of <@{}>, who had the role of the **{}**!".format(user_id,user_role,victim_id,victim_role))
def power(self, me, victim): if me.undead == True: return Mailbox().respond( "You're undead! You can't use your powers!", me.channel) if me.uses > 0 and me.frozen == False: if me.id == victim.id: return Mailbox().respond( "Whether suicide is an option or not is for you to find out. However, it is not in this game. Try again, please.", me.channel) for player in Game_Control().participants: if player.id == victim.id and player.role.name not in [ "Spectator", "Dead" ]: mail = Mailbox().log( "The **Barber** <@{}> has chosen to assassinate". format(me.id)) if player.souls > 0: mail.log_add( " <@{}>, a soulless **{}** who happened to have a soul protecting them." .format(player.id, player.role.name)) mail.respond( "Though you thought you had cut up your target nicely enough, it seems they have somehow survived! Too bad...", me.channel) return mail if player.role.name == "Immortal": mail.log_add( " <@{}>. This failed, as the **Immortal** does not die to a mere **Barber**." .format(player.id)) mail.respond( "Though you thought you had cut up your target nicely enough, it seems they have somehow survived! Too bad...", me.channel) return mail mail.log_add(" <@{}>, the town's favourite **{}**.") mail.story(barber_kill_story(me.id, player.id)) mail.spam(">kill <@{}> {} 1".format( player.id, player.emoji)) return mail return Mailbox().respond( "Hmmm, it seems like I wasn't able to find the person you were looking for, sorry.", me.channel) return Mailbox().respond( "Sorry, bud! Now is not the time to use your powers!", me.channel)
def use_item(item_code, message): user_id = message.author.id if not inventory.has_item(user_id, item_code): return Mailbox().dm( "I'm sorry. You do not have the correct item in your inventory!", user_id, True) # Invisibility cloak if item_code == 100: if not db.isParticipant(user_id): return Mailbox().dm( "You are not a participant! You cannot protect yourself if you're not playing.", user_id, True) db.db_set(user_id, 'sleepingover', 1) inventory.give_item(user_id, 100, -1) return Mailbox().dm( "You are protected for the night. No-one should be able to find you...", user_id ).log( "<@{}> has used an invisibility cloak to protect themselves for the night!" .format(user_id)) # Bucket of water if item_code == 101: if not db.isParticipant(user_id): return Mailbox().dm( "You are not a participant! You cannot unpowder yourself if you're not playing.", user_id) inventory.give_item(user_id, 101, -1) answer = Mailbox().dm( "The bucket of water refreshed your senses. If you were powdered, this effect has been undone!", user_id) if int(db.db_get(user_id, 'powdered')) == 1: answer.log( "<@{}> has used a bucket of water. They are no longer powdered!" .format(user_id)) else: answer.log( "<@{}> has used a bucket of water - they weren't powdered, however." .format(user_id)) db.db_set(user_id, 'powdered', 0) return answer # Royal sword if item_code == 102: # TODO return todo(user_id) # Disguise if item_code == 103: if not db.isParticipant(user_id): return Mailbox().dm( "You are not a participant! You cannot disguise anyone if you're not playing.", user_id, True) role = check.roles(message, 1) if not role: return Mailbox().dm( "**INVALID SYNTAX:** No role provided! Please provide a role!", user_id, True) victim_id = check.users(message, 1, True, True) if not victim_id: victim_id = [user_id] victim_id = victim_id[0] user_role = db.db_get(user_id, 'role') victim_role = db.db_get(victim_id, 'role') victim_frozen = int(db.db_get(victim_id, 'frozen')) victim_abducted = int(db.db_get(victim_id, 'abducted')) if victim_abducted == 1: return Mailbox().dm( "After having finished your great disguise, it seems like you couldn\'t find your target! Where have they gone off to?", user_id, True) if victim_frozen == 1: return Mailbox().dm( "I am sorry, but <@{}> is too cold for that! You\'ll need a lot more than warm suit to get \'em warmed up." .format(victim_id), user_id, True) db.db_set(victim_id, 'fakerole', role) inventory.give_item(user_id, 103, -1) answer = Mailbox().dm( "You have successfully disguised <@{}> as the **{}**!".format( victim_id, role), user_id) answer.log( "With a disguise from their inventory, **{}** <@{}> has disguised <@{}>, the **{}**, as the **{}**!" .format(user_role, user_id, victim_id, victim_role, role)) if victim_role == role: answer.log_add( "\n...does that sound stupid? *Of course!* But how are they supposed to know?" ) return answer # Name tag if item_code == 104: # TODO return todo(user_id) # Med kit if item_code == 105: pass # Dagger if item_code == 106: if not db.isParticipant(user_id): return Mailbox().dm( "You are not a participant! You cannot attack anyone if you're not playing.", user_id, True) if user_id == victim_id: return Mailbox().respond( "I am sorry, but you cannot attempt suicide!\nNot because it's not an option, no, just because we want to see you SUFFER!", True) if int(db.db_get(victim_id, 'abducted')) == 1: return Mailbox().respond( "You attempted to attack <@{}>... but they don't seem to be around in town! That is strange." .format(victim_id), True) if int(db.db_get(victim_id, 'frozen')) == 1: return Mailbox().respond( "You wanted to pay a visit to <@{}>... but it seems they were frozen! Try again, please." .format(victim_id), True) inventory.give_item(user_id, 106, -1) db.add_kill(victim_id, 'Assassin', user_id) answer = Mailbox().dm( "You have successfully used a **Dagger** to assasinate <@{}>. They will die when the time shifts!", user_id, True) return answer.log( "<@{}> has used a **Dagger** to assassinate <@{}>.".format( user_id, victim_id))