summaryrefslogtreecommitdiff
path: root/sassbot/modules/artifact2-0/LevelUp.py
diff options
context:
space:
mode:
authorJason Le Long <jasonnlelong@gmail.com>2018-03-24 22:35:35 +0000
committerJason Le Long <jasonnlelong@gmail.com>2018-03-24 22:35:35 +0000
commit1d19309cd59dbac7e6c0505b3c1944d2b081788f (patch)
tree6c330e52fd46727183559c7773c7af8721bb3a67 /sassbot/modules/artifact2-0/LevelUp.py
parent002c61f74a3f24afbca34ca38e85eea854150677 (diff)
First build V2
Diffstat (limited to 'sassbot/modules/artifact2-0/LevelUp.py')
-rw-r--r--sassbot/modules/artifact2-0/LevelUp.py38
1 files changed, 38 insertions, 0 deletions
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