summaryrefslogtreecommitdiff
path: root/cogs/adv_inc/LevelUp.py
diff options
context:
space:
mode:
authorlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
committerlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
commit52801b4de1d63cd01191acf7fcee137977140ec0 (patch)
tree08271a1f1e3e8060486b6651c67c9934867c648e /cogs/adv_inc/LevelUp.py
parent8df873808c86805624851356f5dea76ec621de23 (diff)
Project initHEADmain
Diffstat (limited to 'cogs/adv_inc/LevelUp.py')
-rw-r--r--cogs/adv_inc/LevelUp.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/cogs/adv_inc/LevelUp.py b/cogs/adv_inc/LevelUp.py
new file mode 100644
index 0000000..b6b73b6
--- /dev/null
+++ b/cogs/adv_inc/LevelUp.py
@@ -0,0 +1,41 @@
+import pymysql
+import sys
+import os
+import importlib
+import utils
+
+from cogs.adv_inc import PlayerStats
+
+importlib.reload(PlayerStats)
+
+
+async def level_up_attributes(params):
+ # In the event no valid value is given, assume the points to assign will be 1
+ try:
+ params['cmd2'] = int(params['cmd2'])
+ except ValueError:
+ params['cmd2'] = 1
+
+ # Get players attribute points
+ player_attribute_points = await utils.sql_postgres("SELECT adventurersinc.get_player_attribute_points(%s);", (params["nick"],), True)
+
+ # Prevent over-allocation
+ if int(params['cmd2']) > player_attribute_points[0][0]['attribute_points']:
+ return "You cannot apply more points than you have."
+
+ # Attribute allocation
+ else:
+ if params['cmd1'].lower() == 's':
+ await utils.sql_postgres("CALL adventurersinc.set_player_attribute_strength(%s, %s)", (params['cmd2'], params["nick"],), False)
+ elif params['cmd1'].lower() == 'd':
+ await utils.sql_postgres("CALL adventurersinc.set_player_attribute_dexterity(%s, %s)", (params['cmd2'], params["nick"],), False)
+ elif params['cmd1'].lower() == 'c':
+ await utils.sql_postgres("CALL adventurersinc.set_player_attribute_constitution(%s, %s)", (params['cmd2'], params["nick"],), False)
+ elif params['cmd1'].lower() == 'i':
+ await utils.sql_postgres("CALL adventurersinc.set_player_attribute_intelligence(%s, %s)", (params['cmd2'], params["nick"],), False)
+
+ player_stats = await PlayerStats.refresh_stats(params)
+
+ # await utils.sql_postgres("CALL adventurersinc.set_player_attribute_intelligence(%s, %s)", (int_attribute_points, params["nick"],), False)
+ # c.execute("UPDATE Players SET HP = %s WHERE Nick='%s';", (player_stats['MaxHP'], params["Nick"]));db.commit();
+ return f"Attribute Points: {player_stats['attribute_points']} (S)tr:{player_stats['strength']} (D)ex:{player_stats['dexterity']} (C)on:{player_stats['constitution']} (I)nt:{player_stats['intelligence']}"