diff --git a/__pycache__/shadowdice.cpython-38.pyc b/__pycache__/shadowdice.cpython-38.pyc index 7aec962..df675da 100644 Binary files a/__pycache__/shadowdice.cpython-38.pyc and b/__pycache__/shadowdice.cpython-38.pyc differ diff --git a/aliases.csv b/aliases.csv index e0041c8..23cd3e2 100644 --- a/aliases.csv +++ b/aliases.csv @@ -1,3 +1,6 @@ alias,command predge,(preedge) pass,(initpass) +listinits,(listinit) +removeinit,(delinit) +rollinits,(rollinit) diff --git a/help.html b/help.html index 9c71aa9..d8e2c0c 100644 --- a/help.html +++ b/help.html @@ -1,6 +1,8 @@ All commands can be run by typing it in the chat or privately messaging JJMumbleBot.
-!addinit: Roll init for a user !init 4 11 Malta will add Malta with 4d6+11
+!addinit: Add init for a user !addinit 4 11 Malta will add Malta with 4d6+11
+!delinit: Remove init for a user !delinit Malta will remove Malta from the list
!listinit: List all inits in the init DB
+!listinitpools: List all init pools in the init DB
!rollinit: Rolls the inits for all of the users, and outputs it
!initpass: Subtracts 10 from all inits, minimum 0
!interupt: Subtracts an amount from a single user's init, wont work if you try to subtract more init from the character than they have !interupt Malta 7 will subtract 7 init from Malta
diff --git a/metadata.ini b/metadata.ini index d22c8b1..6f5b108 100644 --- a/metadata.ini +++ b/metadata.ini @@ -6,7 +6,9 @@ PluginLanguage = EN PluginCommands: [ "rollinit", "addinit", + "delinit", "listinit", + "listinitpools", "initpass", "clearinit", "interupt", diff --git a/privileges.csv b/privileges.csv index 0c6d031..f567bfc 100644 --- a/privileges.csv +++ b/privileges.csv @@ -1,7 +1,16 @@ command,level rollinit,1 addinit,1 +delinit,1 listinit,1 +listinitpools,1 +initpass,1 +clearinit,1 +interupt,1 srun,1 preedge,1 assensing,1 +delivery,1 +perception_mods,1 +environmental,1 +concealability,1 diff --git a/shadowdice.py b/shadowdice.py index a0a7cc3..0e141d1 100644 --- a/shadowdice.py +++ b/shadowdice.py @@ -19,7 +19,7 @@ class Plugin(PluginBase): self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS)) init_db = sqlite3.connect('init.db') init = init_db.cursor() - init.execute("CREATE TABLE inits (dice int, bonus int, total int, name string)") + init.execute("CREATE TABLE inits (dice int, bonus int, total int, name string UNIQUE)") init_db.commit() init_db.close() self.is_running = True @@ -60,7 +60,7 @@ class Plugin(PluginBase): character_name = str(all_data[3]) init_db = sqlite3.connect('init.db') cur = init_db.cursor() - cur.execute("INSERT INTO inits values (?,?,?,?)", (number_of_dice, init_bonus, 0, character_name)) + cur.execute("INSERT INTO inits values (?,?,?,?) ON CONFLICT(name) DO UPDATE SET dice=" + str(number_of_dice) + ", bonus=" + str(init_bonus), (number_of_dice, init_bonus, 0, character_name)) init_db.commit() init_db.close() gs.gui_service.quick_gui("Added init for: " + character_name, text_type='header', box_align='left') @@ -88,6 +88,23 @@ class Plugin(PluginBase): text_type='header', box_align='left') return + def cmd_listinitpools(self,data): + try: + init_db = sqlite3.connect('init.db') + cur = init_db.cursor() + cur.execute("SELECT * from inits ORDER BY total DESC") + ret_text = "" + for row in cur: + ret_text += str(row[3]) + ": " + str(row[0]) + "d6+" + str(row[1]) + "
" + init_db.close() + gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left') + except IndexError: + log(ERROR, CMD_INVALID_CUSTOM_ROLL, + origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value) + gs.gui_service.quick_gui(CMD_INVALID_CUSTOM_ROLL, + text_type='header', box_align='left') + return + def cmd_initpass(self, data): try: init_db = sqlite3.connect('init.db') @@ -135,14 +152,33 @@ class Plugin(PluginBase): text_type='header', box_align='left') return + + def cmd_delinit(self, data): + all_data = data.message.strip().split() + try: + name = str(all_data[1]) + init_db = sqlite3.connect('init.db') + cur = init_db.cursor() + cur.execute("DELETE from inits WHERE name = :name", {"name": name}) + init_db.commit() + init_db.close() + gs.gui_service.quick_gui("Deleted init for: " + name + " (if they exist)", text_type='header', box_align='left') + except IndexError: + log(ERROR, CMD_INVALID_CUSTOM_ROLL, + origin=L_COMMAND, error_type=CMD_INVALID_ERR, print_mode=PrintMode.VERBOSE_PRINT.value) + gs.gui_service.quick_gui("Can only remove init from a name in the list of inits, try !listinit to confirm spellings", + text_type='header', box_align='left') + return + def cmd_clearinit(self, data): init_db = sqlite3.connect('init.db') init = init_db.cursor() init.execute("DROP TABLE inits") init_db.commit() - init.execute("CREATE TABLE inits (dice int, bonus int, total int, name string)") + init.execute("CREATE TABLE inits (dice int, bonus int, total int, name string UNIQUE)") init_db.commit() init_db.close() + gs.gui_service.quick_gui("Purged the Init DB", text_type='header', box_align='left') def cmd_rollinit(self, data): try: