Esempio n. 1
0
def matchup(shiptype, factionid, teamsize):
    global players
    players = getWinners(teamsize * 2)
    global shipType
    shipType = shiptype
    for user in players:
        userShip = getShip(shiptype, factionid)
        message = "@{}".format(getUserName(user)) + " you fly a {}".format(userShip)
        dmChannel = slack_client.api_call("im.open", user=user)
        slack_client.api_call("chat.postMessage", channel=dmChannel["channel"]["id"], text=message, as_user=True)

    if teamsize == 1:
        messageQueue.append("{}".format(getUserName(players[0])) + " will battle against {}".format(getUserName(players[1])))
    else:
        messageQueue.append("The teams are as follows: ")
        teamMessage = ""
        for player in range(0, teamsize):
            teamMessage += getUserName(players[player]) + " "
        teamMessage += "VS. "
        for player in range(teamsize, teamsize * 2):
            teamMessage += getUserName(players[player]) + " "

        messageQueue.append(teamMessage)

    processMessageQueue()
Esempio n. 2
0
def matchup(shiptype, factionid, teamsize):
    players = getWinners(teamsize * 2)
    for user in players:
        userShip = getShip(shiptype, factionid)
        messageQueue.append("/w {}".format(user) + " you fly a {}".format(userShip))
    if teamsize == 1:
        messageQueue.append("{}".format(players[0]) + " will battle against {}".format(players[1]))
    else:
        messageQueue.append("The teams are as follows: ")
        teamMessage = ""
        for player in range(0, teamsize):
            teamMessage += players[player] + " "
        teamMessage += "VS. "
        for player in range(teamsize, teamsize * 2):
            teamMessage += players[player] + " "

        messageQueue.append(teamMessage)

    processMessageQueue()
Esempio n. 3
0
def handle_command(command, channel, user):
    """
        Receives commands directed at the bot and determines if they
        are valid commands. If so, then acts on the commands. If not,
        returns back what it needs for clarification.
    """
    response = ""
    if command.startswith("!enter"):
        uName = getUserName(user)
        if addUser(user):
            sendMessage("@{} entered".format(uName))
    elif command.startswith("!reset"):
        resetUsers()
        sendMessage("User List reset, please type `!enter` if you'd like to participate")

    elif command.startswith("!forfeit"):
        deleteUser(user)
        sendMessage("{}".format(getUserName(user)) + " has decided to forfeit!")

    elif command.startswith("!matchup"):
        if userCount() < 2:
            sendMessage("Not enough users for 1v1.")
            printUserList()
        else:
            shipTypeID = getShipTypeID(command)
            shipFactionID = getFactionID(command)
            if shipTypeID == 0:
                shipTypeID = getRandomType()
            matchup(shipTypeID, shipFactionID, 1)

    elif command.startswith("!team"):
        size = int(re.search(r"\d", command).group(0))
        if userCount() < size * 2:
            sendMessage("Not enough users for {}".format(size) + "v{}".format(size))
            printUserList()
        else:
            shipTypeID = getShipTypeID(command)
            shipFactionID = getFactionID(command)
            if shipTypeID == 0:
                shipTypeID = getRandomType()
            matchup(shipTypeID, shipFactionID, size)

    elif command.startswith("!mulligan"):
        if user in players:
            message = "@{}".format(getUserName(user)) + " you fly a {}".format(getShip(shipType, getFactionID(command)))
            dmChannel = slack_client.api_call("im.open", user=user)
            slack_client.api_call("chat.postMessage", channel=dmChannel["channel"]["id"], text=message, as_user=True)
            sendMessage("{}".format(getUserName(user)) + " chose to mulligan!")
            players.remove(user)

    elif command.startswith("!list"):
        printUserList()

    elif command.startswith("!help"):
        helpMessage = "Welcome to the tourney bot! To enter into the drawing please type `!enter`\n" \
                      "To get a 1v1 match type `!matchup` or `!team 1`\n" \
                      "`!team x` where x is the team size.\n" \
                      "`!team 3` will create a 3v3 match\n" \
                      "You may also specify Faction and/or Ship Type.\n" \
                      "For example: `!matchup amarr cruiser` will do a 1v1 with Amarr Cruisers\n" \
                      "You can also have it random the faction or the ship type.\n" \
                      "Current supported ship types are: frigate, destroyer, cruiser" \
                      "You can `!mulligan` ONCE to re-randomize your ship."
        sendMessage(helpMessage)