From 69318abf6c67bf2188b2d158b8b12193918fcd3c Mon Sep 17 00:00:00 2001 From: silverwizard Date: Sat, 19 Jun 2021 21:20:10 -0400 Subject: [PATCH] Added some more tools to manage inits, and updated aliases list --- __pycache__/shadowdice.cpython-38.pyc | Bin 15953 -> 17187 bytes aliases.csv | 3 ++ help.html | 4 ++- metadata.ini | 2 ++ privileges.csv | 9 ++++++ shadowdice.py | 42 ++++++++++++++++++++++++-- 6 files changed, 56 insertions(+), 4 deletions(-) diff --git a/__pycache__/shadowdice.cpython-38.pyc b/__pycache__/shadowdice.cpython-38.pyc index 7aec962cafe028fc4e422aead58ff15d3a2901f6..df675da14e1786185aa48e730ce3aa35a6597751 100644 GIT binary patch delta 1799 zcmaKrU2GIp6vyYx&hF06&Te3n$^G3s z_nvd-o^$^92j}J`h>k`gnuJgB`uE4Qp*ztH0H2EOaD4?^&DLC$#*%C;Yr{TuSyH62 z^stm!=l%>$056J%a!=40&F*<+bkN=En^uzZxQ_z`sRnaWO`elx7QX5O=~b!Jtw=n2 zO0(_*TA^JXkMTIK=Lw!HqzY-KU-d6}^Z24?JGvf{m^3UM^q7fc9{`^9flTlrEFDqZ zEk0CRw-`fNqkky7Yu}#!k@nKWl$kLGhK$ku1AQZd#_-^X!SXq?tExU@950tDc9(lc zy#&ziZqp6|+!EKqhvi!VaVDA+vOb##;Kr2Ter)z#MAZ?OwY9KK+}2v7m<&Htnpa4vysi){#971(Hc$u_RIXE!7Caw|HJbH;vkv0F ztwV$^!We;)Q1!8n4b~3&Jd6+zBgu`{5&C?M@a(^M4oCCx+!Q-n%-cL)%Jb9Za?w64 zHtT8V5WhxOK%n<$8l07$@(e;#zb)6y0y4p94&aa;!U$qj@IW*k7%aw5@7a zj&o}w$E{7Ya=>#VoIr@Uo(knl+_WmE`33QNe0=t?tbT?z%Vc+i`y818C3eQgm71T) zb1;L-s|8S&e#c)6G9N=#=D|~+Qd3EFxbCTtYX#IF^EY^sMqO}!4RO|OwtP>b8#%JuIpa*tZ-L%?6 z=tX2gA`@DvTQAYXUcx@{ZT<7<+c>mi2+2Dn9Tb~emuQj~W#(>5g(0;dMe-XVj1o+d zO>cxRT_^2AY>H+|gfiib=xH2o;WVre&JtcHBni`mbK*|pffs1!`H)@7w4f-o+|SFe)mz&*cO$canj)l0ZcxPqW7 zC_39zIRWmjwwF|90&0CX2*4Qc6M5KS7+5~HzR8mMQRU`vF;j@5ZS@(kEy9Mle*@rGrMKB zW`A_ez(f3k2s|i3U8@HL1<|Qf3Q -!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: