import MySQLdb import sys sys.path.insert(0, '/home/bouncer/sassbot/modules/artifact2-0/') import PlayerStats def LevelUpAttributes(phenny, parameters, strCmd1, strCmd2): db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB']) c = db.cursor(MySQLdb.cursors.DictCursor) #In the event no valid value is given, assume the points to assign will be 1 try: strCmd2 = int(strCmd2) except ValueError: strCmd2 = 1 #Get players attribute points c.execute("SELECT `AttributePoints` FROM `Players` WHERE `Nick`=%s;", (parameters["Nick"])) sqlAttibutes = c.fetchone() #Prevent over-allocation if int(strCmd2) > sqlAttibutes['AttributePoints']: return "You cannot apply more points than you have." #Attribute allocation else: if strCmd1.lower() == 's': c.execute("UPDATE `Players` SET `Strength`=`Strength`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit(); elif strCmd1.lower() == 'd': c.execute("UPDATE `Players` SET `Dexterity`=`Dexterity`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit(); elif strCmd1.lower() == 'c': c.execute("UPDATE `Players` SET `Constitution`=`Constitution`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit(); elif strCmd1.lower() == 'i': c.execute("UPDATE `Players` SET `Intelligence`=`Intelligence`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit(); playerStats = PlayerStats.RefreshStats(phenny, parameters) c.execute("UPDATE `Players` SET `HP`=%s WHERE `Nick`=%s;", (playerStats['MaxHP'], parameters["Nick"]));db.commit(); return "\0399Attribute Points: " + str(playerStats['AttributePoints']) + " (S)tr:" + str(playerStats['Strength']) + " (D)ex:" + str(playerStats['Dexterity']) + " (C)on:" + str(playerStats['Constitution']) + " (I)nt:" + str(playerStats['Intelligence'])