Beispiel #1
0
def controlCenterAction(action):
    logAction()
    questId = request.args['questId']
    discordId = session.get("discordId")
    quest = db.getQuest(questId)
    player = db.getPlayer(discordId)
    if action == "claimRole":
        roleId = request.args['roleId']
        result, message = quest.setRole(player, roleId)
        if result:
            role = Roles[roleId]
            player.leadership -= role['cost']
    elif action == "releaveRole":
        roleId = quest.getPlayerRole(player)
        result, message = quest.setRole(player, None)
        if result:
            role = Roles[roleId]
            player.leadership += role['cost']
    elif action == "useActive":
        activeId = request.args['activeId']
        result, message = quest.activateRolePower(player, activeId)
        if result:
            active = Roles[quest.getPlayerRole(player)]['actives'][activeId]
            player.leadership -= active['cost']
            # if activeId == "striketrue" and player.discordId == 153199290641022977:
            #     db.pushTask("WHISPER")
    else:
        return "Unknown action", 400
    if result:
        db.setQuest(quest)
        db.setPlayer(player)
        return message, 200
    else:
        return message, 400
Beispiel #2
0
def questPlayerAction(action):
    logAction()
    questId = request.args['questId']
    discordId = session.get("discordId")
    quest = db.getQuest(questId)
    player = db.getPlayer(discordId)
    if action == "claimCommander":
        result, message = quest.setCommander(player)
        if result:
            player.leadership -= quest.leadershipReq
    elif action == "releaveCommander":
        result, message = quest.setCommander(None)
        if result:
            player.leadership += quest.leadershipReq
    elif action == "joinQuest":
        # Recredit the leadership if they are currently a commander
        if player.discordId == quest.commander:
            player.leadership += quest.leadershipReq
        result, message = quest.addPlayer(player)
    elif action == "leaveQuest":
        result, message = quest.removePlayer(player)
    else:
        return "Unknown action", 400
    if result:
        db.setQuest(quest)
        db.setPlayer(player)
        return message, 200
    else:
        return message, 400
Beispiel #3
0
def updatePlayerStats():
    logAction()
    formData = request.form.to_dict()
    discordId = formData.pop("discordId")
    player = db.getPlayer(discordId)
    if player == None:
        return "Player not found", 404
    player.deserialise(formData)
    db.setPlayer(player)
    return redirect("/playeradmin", code=302)
Beispiel #4
0
def spendCompanyPoints():
    logAction()
    influence = int(request.form['influence'])
    leadership = int(request.form['leadership'])
    discordId = session.get("discordId")
    player = db.getPlayer(discordId)
    result, message = player.spendPoints(influence, leadership)
    db.setPlayer(player)
    if result:
        return redirect(request.referrer or "/")
    else:
        return message, 400
Beispiel #5
0
def updateSelfStats():
    logAction()
    formData = request.form.to_dict()
    discordId = session.get("discordId")
    player = db.getPlayer(discordId)
    if "influence" in formData:
        assert int(formData['influence']) >= 0
        player.influence = formData['influence']
    if "leadership" in formData:
        assert int(formData['leadership']) >= 0
        player.leadership = formData['leadership']
    db.setPlayer(player)
    return redirect(request.referrer or "/")