From 1d19309cd59dbac7e6c0505b3c1944d2b081788f Mon Sep 17 00:00:00 2001 From: Jason Le Long Date: Sat, 24 Mar 2018 22:35:35 +0000 Subject: First build V2 --- sassbot/modules/artifact2-0/LevelUp.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sassbot/modules/artifact2-0/LevelUp.py (limited to 'sassbot/modules/artifact2-0/LevelUp.py') diff --git a/sassbot/modules/artifact2-0/LevelUp.py b/sassbot/modules/artifact2-0/LevelUp.py new file mode 100644 index 0000000..74e0acf --- /dev/null +++ b/sassbot/modules/artifact2-0/LevelUp.py @@ -0,0 +1,38 @@ +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']) \ No newline at end of file -- cgit v1.2.3