Example #1
0
def alertNewAbility(conn, userID, abilityKey, galaxy):
    # Add alert with custom message about new ability user has unlocked
    message = "Congratuations!  You have unlocked a new ability on Galaxy Harvester in {1} galaxy.  You can now {0}.  Thanks for your contributions, and keep the the good work!".format(
        ghShared.ABILITY_DESCR[abilityKey], ghNames.getGalaxyName(galaxy))
    alertLink = "/user.py?uid={0}".format(userID)
    alertcursor = conn.cursor()
    alertcursor.execute(
        "INSERT INTO tAlerts (userID, alertType, alertTime, alertMessage, alertLink, alertStatus) VALUES ('{0}', 1, NOW(), '{1}', '{2}', 0);"
        .format(userID, message, alertLink))
    alertcursor.close()
            checkCursor2 = conn.cursor()
            checkCursor2.execute(
                "SELECT spawnID FROM tResources WHERE spawnName=%s AND galaxy=%s",
                (finalName, newGalaxyId))
            checkRow2 = checkCursor2.fetchone()
            if checkRow2 == None:
                fixCursor.execute(
                    "UPDATE tResources SET galaxy=%s WHERE spawnID=%s;",
                    (newGalaxyId, spawnID))
                if fixCursor.rowcount > 0:
                    updated = "galaxy"
                    dbShared.logEvent(
                        "INSERT INTO tResourceEvents (galaxy, spawnID, userID, eventTime, eventType, eventDetail) VALUES ("
                        + str(finalGalaxy) + "," + str(spawnID) + ",'" +
                        currentUser + "',NOW(),'g','" + checkRow[2] + " to " +
                        ghNames.getGalaxyName(newGalaxyId) + "');", 'g',
                        currentUser, finalGalaxy, spawnID)
                    finalGalaxy = newGalaxyId
            else:
                result = "Error: The galaxy you are updating to already has a spawn with that name entered."
            checkCursor2.close()
        else:
            updated = "nothing"

        fixCursor.close()

        if updated != "nothing":
            newLink = ": <a href='{0}resource.py/{1}/{2}'>Go to Updated Resource</a>".format(
                ghShared.BASE_SCRIPT_URL, finalGalaxy, finalName)
    else:
        result = "Error: SpawnID not found"