def cupid_kiss(user_id,victim_id,voluntarily = True): """This function makes the cupid fall in love with a partner. The function assumes the player is a cupid and has the correct role, so make sure to have filtered this out already. The function returns a Mailbox. user_id -> the cupid who casts the spell victim_id -> the player who's falling in love with the cupid""" uses = int(db_get(user_id,'uses')) if uses < 1: return Mailbox().respond("I am sorry! You currently cannot choose someone to fall in love with!",True) user_channel = int(db_get(user_id,'channel')) victim_role = db_get(victim_id,'role') victim_frozen = int(db_get(victim_id,'frozen')) victim_abducted = int(db_get(victim_id,'abducted')) victim_undead = int(db_get(victim_id,'undead')) # If involuntary, make the cupid choose again. if voluntarily == False and (victim_id == user_id or victim_abducted == 1 or victim_frozen == 1): return False if victim_id == user_id: return Mailbox().respond("So you wanna fall in love with yourself, huh? Too bad, your partner really has to be someone ELSE.") if victim_abducted == 1: return Mailbox().msg("You wanted to throw an arrow at your target... but you cannot find them! It's almost as if they had disappeared from this town!",user_channel,True) if victim_frozen == 1: return Mailbox().msg("Your love arrows just do not seem to be able to reach your chosen lover! They are frozen! Please try someone else.",user_channel,True) db_set(user_id,'uses',uses - 1) answer = Mailbox().edit_cc(user_channel,victim_id,1).msg("Welcome, <@{}>!".format(victim_id),user_channel) answer.log("The **Cupid** <@{}> has chosen to fall in love with <@{}>.".format(user_id,victim_id)) answer.dm("Hello there, <@{}>! The **Cupid** <@{}> has chosen to fall in love with you!\n".format(victim_id,user_id),victim_id) answer.dm_add("For the rest of the game, you two will remain partners. Be open and honest, as you cannot win if the other dies!\n") answer.dm_add("Good luck!") if victim_undead == 1: answer.msg_add("<@{}>, while pretending to be a **{}**, is secretly an **Undead**!".format(victim_id,victim_role)) else: answer.msg_add("<@{}>, the town's favourite **{}**, has decided to trust <@{}>.".format(victim_id,victim_role,user_id)) return answer.msg_add("\nTogether, they will survive this town!")
def start_game(): """This function is triggered at the start of the game. If successful, the function returns a Mailbox. If unsuccessful, the function still returns a Mailbox, but will also confirm the error in the console.""" # Make sure there isn't already a game going on! if dy.get_stage() != "NA": print("ERROR: According to " + dy.dynamic_config + ", there's already a game going on!") return Mailbox().respond( "I'm sorry! A game cannot be started while there's another one going on already!" ) # Choose the roles out of the given role-pool role_pool = [] for choice in view_roles(): for i in range(choice.amount): role_pool.append(choice.role) if len(db.player_list()) > len(role_pool): print( "The game cannot be started while there are less roles available than that there are participants signed up." ) return Mailbox().respond("Not enough roles to distribute available!", True) # If there are enough roles available, make a selection, evaluate the selection, and, if accepted, distribute the roles. if not pos.valid_distribution(role_pool, True): return Mailbox().respond( "I am sorry, but I cannot use an invalid distribution to start the game!", True) answer = Mailbox(True) attempts = 0 while attempts < 1000: attempts += 1 chosen_roles = random.sample(role_pool, len(db.player_list())) if pos.valid_distribution(chosen_roles, True) == True: answer.create_cc("Graveyard", 0, [], [], True) answer.create_cc("Market", 0, [], [], True) answer.create_cc("Reporter", 0, [], [], True) # Assign the roles to all users. user_list = db.player_list() for i in range(len(user_list)): user_id = user_list[i] user_role = chosen_roles[i] db_set(user_id, 'role', user_role) db_set(user_id, 'fakerole', user_role) db_set(user_id, 'channel', config.game_log) answer.log( "{} - <@{}> has received the role of the `{}`!".format( db_get(user_id, 'emoji'), user_id, user_role)) answer.dm( "This message is giving you your role for season `{}` of the *Werewolves* game.\n\n" .format(config.season), user_id) answer.dm_add('Your role is `{}`.\n\n'.format(user_role)) answer.dm_add( "**You are not allowed to share a screenshot of this message!** " ) answer.dm_add( "You can claim whatever you want about your role, but you may under **NO** " ) answer.dm_add( "circumstances show this message in any way to any other participants.\n" ) answer.dm_add( "We hope you are happy with the role you gained, and we hope you'll enjoy the game as much as we do.\n\n" ) answer.dm_add("Good luck... 🌕") if user_role in pos.personal_secrets: answer.create_sc(user_id, user_role) if user_role in pos.shared_secrets: answer.add_to_sc(user_id, user_role) if user_role == "Cult Member": answer.add_to_sc(user_id, "Cult Leader") if user_role in pos.wolf_pack: answer.add_to_sc(user_id, "Werewolf") if user_role == "Bloody Butcher": answer.add_to_sc(user_id, "Butcher") if user_role == "Devil": answer.add_to_sc(user_id, "Demon") if user_role == "Vampire": answer.add_to_sc(user_id, "Undead") if user_role == "Witch": db_set(user_id, 'uses', 3) answer.story( 'The current distribution is {}'.format(chosen_roles)) # TODO answer.story( 'I know, I know. That looks ugly as hell. We\'re trying to make it look good!' ) if "Flute Player" in chosen_roles: answer.create_cc("Flute_Victims", 0, [], [], True) # If the four horsemen are part of the game, assign numbers to all players. if "Horseman" in chosen_roles: nothorse_table = [ user_id for user_id in db.player_list() if db_get(user_id, 'role') != 'Horseman' ] horse_table = [ user_id for user_id in db.player_list() if db_get(user_id, 'role') == 'Horseman' ] nothorse_table.shuffle() horse_table.shuffle() for i in range(4): db_set(horse_table[i], 'horseman', i + 1) for i in range(16): db_set(nothorse_table[i], 'horseman', (i % 4) + 1) # Reset the day timer dy.reset_day() dy.set_stage('Night') return answer.respond( "Very well! The game will start tomorrow morning.") answer.respond("Timeout reached! Your distribution is too crazy!", True) return answer
def process(message, isGameMaster=False, isAdmin=False, isPeasant=False): user_id = message.author.id message_channel = message.channel.id help_msg = "**List of commands:**\n" args = message.content.split(' ') # ============================================================= # # BOT COMMANDS # # ============================================================= if isPeasant == True: pass # ============================================================= # # ADMINISTRATOR # # ============================================================= if isAdmin == True: help_msg += "\n __Admin commands:__\n" elif is_command(message, ['delete_category','start']): return [Mailbox().respond(PERMISSION_MSG.format("Administrator"), True)] # ============================================================= # # GAME MASTERS # # ============================================================= if isGameMaster == True: help_msg += "\n__Game Master commands:__\n" if is_command(message, ['userinv','userinventory']): target = check.users(message) if not target: return [Mailbox().respond("**INVALID SYNTAX:**\nNo target provided!",True)] answer = Mailbox().spam("**__<@{}>'S BALANCE__**".format(target[0])) for item in items.jget("items"): if has_item(target[0],item["code"]): answer.spam_add('\n{}x - **'.format(has_item(target[0],item["code"],False)) + item["name"] + '**') return [answer] if is_command(message, ['userinv','userinventory'], True): return todo() help_msg += "`" + prefix + "userinv` - View a user's inventory.\n" elif is_command(message, []): return [Mailbox().respond(PERMISSION_MSG.format("Game Master"), True)] # ============================================================= # # PARTICIPANTS # # ============================================================= if isParticipant(user_id): help_msg += "\n__Participant commands:__\n" user_undead = int(db_get(user_id,'undead')) elif is_command(message, []): return [Mailbox().respond(PERMISSION_MSG.format("Participant"), True)] # ============================================================= # # EVERYONE # # ============================================================= help_msg += '\n\n' '''buy''' if is_command(message, ['buy']): number = check.numbers(message) if not number: return [Mailbox().dm("No amount provided! Please provide me with a number!",True)] answer = [Mailbox().dm(shop.buy(user_id,number[0],message.author.name),user_id)] if is_command(message, ['buy'], True): msg = "**Usage:** Buy an item from the shop.\n\n`" + prefix + "buy <n>`\n\n" msg += "**Example:** `" + prefix + "buy 1`" return [Mailbox().respond(msg,True)] help_msg += "`" + prefix + "buy` - Buy item from the shop.\n" '''inventory''' if is_command(message, ['inv','inventory','bal','balance']): answer = Mailbox().dm("**__YOUR CURRENT BALANCE__**",user_id) for item in items.jget("items"): if has_item(user_id,item["code"]): answer.dm_add('\n{}x - **'.format(has_item(user_id,item["code"],False)) + item["name"] + '**') return [answer] if is_command(message, ['inv','inventory','bal','balance'], True): return todo() help_msg += "`" + prefix + "inventory` - View your inventory.\n" '''sell''' if is_command(message, ['sell']): number = check.numbers(message) if not number: return [Mailbox().dm("No amount provided! Please provide me with a number!",True)] answer = [Mailbox().dm(shop.sell(user_id,number[0],message.author.name),user_id)] if is_command(message, ['sell'], True): msg = "**Usage:** Sell an item from the shop.\n\n`" + prefix + "sell <n>`\n\n" msg += "**Example:** `" + prefix + "sell 1`" return [Mailbox().respond(msg,True)] help_msg += "`" + prefix + "sell` - Buy item from the shop.\n" '''shop''' if is_command(message, ['shop']): answer = Mailbox() for msg in shop.get_market_message(): answer.respond(msg,True) return answer if is_command(message, ['shop']): msg = "**Usage:** View the Devil Bot's shop.\n\n`" + prefix + "shop`" return [Mailbox().respond(msg,True)] help_msg += "`" + prefix + "shop` - View the Devil's shop." help_msg += "\n\n__Item specific commands:__" '''attack''' if is_command(message, ['attack', 'dagger', 'kill']): pass # TODO '''disguise''' if is_command(message,['disguise','dis']): return [use_item(103,message)] if is_command(message,['disguise','dis'],True): msg = "**Usage:** Disguise a participant.\n\n`" + prefix + "disguise @Randium#6521 Innocent`\n\n" msg += "This command can only be used by participants. You can disguise yourself." return [Mailbox().respond(msg,True)] help_msg += "`" + prefix + "disguise` - Disguise a participant.\n" '''hide''' if is_command(message,['hide']): return [use_item(100,message)] if is_command(message,['disguise','dis'],True): msg = "**Usage:** Disguise a participant.\n\n`" + prefix + "disguise @Randium#6521 Innocent`\n\n" msg += "This command can only be used by participants. You can disguise yourself." return [Mailbox().respond(msg,True)] help_msg += "`" + prefix + "hide` - Become invisible for the night.\n" # -------------------------------------------------------------- # HELP # -------------------------------------------------------------- help_msg += "\n\n*If you have any more questions, feel free to ask any of the Game Masters!*" '''help''' if is_command(message,['help']) and is_command(message,['help'],True) == False: return [Mailbox().respond(help_msg,True)] if is_command(message,['help'],True): answer = Mailbox().respond("Hey there! `" + prefix + "help` will give you a list of commands that you can use.") answer.respond_add("\nIf you have any questions, feel free to ask any of the Game Masters!") return [answer] if message.content.startswith(prefix): return [Mailbox().respond("Sorry bud, couldn't find what you were looking for.", True)] return []
def process(message, isGameMaster=False, isAdmin=False, isPeasant=False): user_id = message.author.id message_channel = message.channel.id help_msg = "**List of commands:**\n" args = message.content.split(' ') # ============================================================= # # BOT COMMANDS # # ============================================================= if isPeasant == True: pass # ============================================================= # # ADMINISTRATOR # # ============================================================= if isAdmin == True: help_msg += "\n __Admin commands:__\n" elif is_command(message, ['delete_category', 'start']): return [ Mailbox().respond(PERMISSION_MSG.format("Administrator"), True) ] # ============================================================= # # GAME MASTERS # # ============================================================= if isGameMaster == True: help_msg += "\n__Game Master commands:__\n" elif is_command(message, []): return [Mailbox().respond(PERMISSION_MSG.format("Game Master"), True)] # ============================================================= # # PARTICIPANTS # # ============================================================= if isParticipant(user_id): help_msg += "\n__Participant commands:__\n" user_undead = int(db_get(user_id, 'undead')) elif is_command(message, []): return [Mailbox().respond(PERMISSION_MSG.format("Participant"), True)] # ============================================================= # # EVERYONE # # ============================================================= help_msg += '\n\n' if is_command(message, ['inv', 'inventory', 'bal', 'balance']): answer = Mailbox().dm("**__YOUR CURRENT BALANCE__**", user_id) for item in items.jget("items"): if has_item(user_id, item["code"]): answer.dm_add('\n' + item["name"] + ' - *(' + has_item(user_id, item["code"], False) + ')*') return [answer] if is_command(message, ['inv', 'inventory', 'bal', 'balance'], True): return todo() help_msg += "`" + prefix + "inventory` - View your inventory.\n" # -------------------------------------------------------------- # HELP # -------------------------------------------------------------- help_msg += "\n\n*If you have any more questions, feel free to ask any of the Game Masters!*" '''help''' if is_command(message, ['help']) and is_command(message, ['help'], True) == False: return [Mailbox().respond(help_msg, True)] if is_command(message, ['help'], True): answer = Mailbox().respond( "Hey there! `" + prefix + "help` will give you a list of commands that you can use.") answer.respond_add( "\nIf you have any questions, feel free to ask any of the Game Masters!" ) return [answer] if message.content.startswith(prefix): return [ Mailbox().respond( "Sorry bud, couldn't find what you were looking for.", True) ] return []