Exemplo n.º 1
0
def executioner(user_id,victim_id):
    """This function allows the Executioner / huntress to choose a victim that will die in their place, may they get lynched during the day.
    The function assumes the player is a huntress and has provided a living participant, so make sure to have filtered this out already.
    The function returns a Mailbox.

    Keyword arguments:
    user_id -> the huntress/executioner's id
    victim_id -> the target's id"""

    user_channel = int(db_get(user_id,'channel'))
    user_undead = int(db_get(user_id,'undead'))
    role = db_get(user_id,'role')
    answer = Mailbox()

    if user_id == victim_id:
        return Mailbox().respond("I'm sorry, <@{}>. You cannot choose to kill yourself instead of yourself.".format(user_id))
    if user_undead == 1:
        return Mailbox().msg("I am sorry! Once you're undead, your target is set!",user_channel)

    user_found = False
    for action in db.get_standoff(user_id):
        if (action[2] == 'Huntress' or action[2] == 'Executioner') and role == action[2]:
            db.delete_standoff(action[0])
            if int(action[1]) != victim_id:
                user_found = True
                answer.msg("You no longer have <@{}> as your target.".format(int(action[1])),user_channel)

    db.add_standoff(victim_id,role,user_id)
    answer.msg("You have successfully chosen <@{}> as your ",user_channel)
    if user_found:
        answer.msg_add("new ")
    answer.msg_add("target!")

    return answer
Exemplo n.º 2
0
def seek(user_id,victim_id,role):
    """This fuction allows the crowd seeker to inspect players.
    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 will be checked 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 seek 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 seek players!",user_id,True)
    if victim_abducted == 1:
        return Mailbox().msg("You appear to be unable to find <@{}> among the crowds! Where could they be?".format(victim_id),user_channel,True)
    if victim_frozen == 1:
        return Mailbox().msg("<@{}> was isolated from the crowd, and has gotten too cold to seek. Please try someone else!".format(victim_id),user_channel,True)

    db_set(user_id,'uses',uses - 1)
    answer = Mailbox()

    if role == victim_role:
        answer.msg("{} - <@{}> has the role of the **{}**!".format(db_get(victim_id,'emoji'),victim_id,role),user_channel)
        answer.log("The **Crowd Seeker** <@{}> has seen <@{}> as the **{}**!".format(user_id,victim_id,role))
    else:
        answer.msg("{} - <@{}> does **NOT** have the role of the **{}**.".format(db_get(victim_id,'emoji'),victim_id,role),user_channel)
        answer.log("The **Crowd Seeker** <@{}> guessed incorrectly that <@{}> would be the **{}**.".format(user_id,victim_id,role))

    if uses - 1 > 0:
        answer.msg("You can seek **{}** more time".format(uses-1),user_channel,True)
        if uses - 1 > 1:
            answer.msg_add("s")
        answer.msg_add("!")
    else:
        answer.msg("That\'s it for today! You cannot seek any more players.",user_channel,True)

    return answer
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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!")