diff --git a/__pycache__/shadowdice.cpython-38.pyc b/__pycache__/shadowdice.cpython-38.pyc
index 2b9659b..7aec962 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 18daf09..e0041c8 100644
--- a/aliases.csv
+++ b/aliases.csv
@@ -1,2 +1,3 @@
alias,command
predge,(preedge)
+pass,(initpass)
diff --git a/help.html b/help.html
index 19f638d..9c71aa9 100644
--- a/help.html
+++ b/help.html
@@ -1,5 +1,10 @@
All commands can be run by typing it in the chat or privately messaging JJMumbleBot.
-!init: Roll init dice !init 4 11 will roll 4d6+11
+!addinit: Roll init for a user !init 4 11 Malta will add Malta with 4d6+11
+!listinit: List all inits 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
+!clearinit: Deletes all of the initiatives
!srun: Roll a bunch of dice, count successes and ones !srun 12 will roll a pool of 12 dice
!preedge: Roll a pool with exploding 6s, counts successes, ones, and explosions !preedge 12 will roll a poll of 12 dice
!assensing: Prints the Shadowrun assensing table
diff --git a/metadata.ini b/metadata.ini
index 9c7d0ce..d22c8b1 100644
--- a/metadata.ini
+++ b/metadata.ini
@@ -4,7 +4,12 @@ PluginName = Shadow Dice
PluginDescription = A plugin for rolling dice in Shadowrun 5e.
PluginLanguage = EN
PluginCommands: [
- "init",
+ "rollinit",
+ "addinit",
+ "listinit",
+ "initpass",
+ "clearinit",
+ "interupt",
"srun",
"preedge",
"assensing",
diff --git a/privileges.csv b/privileges.csv
index f2deeff..0c6d031 100644
--- a/privileges.csv
+++ b/privileges.csv
@@ -1,5 +1,7 @@
command,level
-init,1
+rollinit,1
+addinit,1
+listinit,1
srun,1
preedge,1
assensing,1
diff --git a/shadowdice.py b/shadowdice.py
index 8c9c7ec..a0a7cc3 100644
--- a/shadowdice.py
+++ b/shadowdice.py
@@ -7,6 +7,7 @@ from JJMumbleBot.settings import global_settings as gs
from JJMumbleBot.lib.resources.strings import *
import os
import random
+import sqlite3
class Plugin(PluginBase):
@@ -16,6 +17,11 @@ class Plugin(PluginBase):
self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
self.metadata = PluginUtilityService.process_metadata(f'plugins/extensions/{self.plugin_name}')
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_db.commit()
+ init_db.close()
self.is_running = True
log(
INFO,
@@ -25,6 +31,11 @@ class Plugin(PluginBase):
)
def quit(self):
+ init_db = sqlite3.connect('init.db')
+ init = init_db.cursor()
+ init.execute("DROP TABLE inits")
+ init_db.commit()
+ init_db.close()
self.is_running = False
log(
INFO,
@@ -41,21 +52,122 @@ class Plugin(PluginBase):
if not self.is_running:
self.__init__()
- def cmd_init(self, data):
+ def cmd_addinit(self,data):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
init_bonus = int(all_data[2])
- ret_text = "
Init Roll:
"
- result = 0
- for i in range(number_of_dice):
- random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
- this_die = random.randint(1,6)
- result = result + this_die
- ret_text += f"{this_die} + "
- result = result + init_bonus
- ret_text += f" {init_bonus}
{result}"
+ 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))
+ init_db.commit()
+ init_db.close()
+ gs.gui_service.quick_gui("Added init for: " + character_name, 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_listinit(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[2]) + "
"
+ 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')
+ cur = init_db.cursor()
+ cur.execute("SELECT * from inits ORDER BY total DESC")
+ init = init_db.cursor()
+ ret_text = ""
+ for row in cur:
+ new_init = int(row[2])-10
+ if(new_init <= 0):
+ new_init = 0
+ init.execute("UPDATE inits SET total = :result WHERE name = :name", {"result": new_init, "name": row[3]})
+ ret_text += str(row[3]) + ": " + str(new_init) + "
"
+ init_db.commit()
+ 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_interupt(self, data):
+ all_data = data.message.strip().split()
+ try:
+ name = str(all_data[1])
+ subtract = int(all_data[2])
+ init_db = sqlite3.connect('init.db')
+ cur = init_db.cursor()
+ cur.execute("SELECT * from inits WHERE name = :name", {"name": name})
+ for row in cur:
+ new_init = int(row[2])-subtract
+ if(new_init < 0):
+ gs.gui_service.quick_gui("Cannot take action, not enought init", text_type='header', box_align='left')
+ else:
+ cur.execute("UPDATE inits SET total = :result WHERE name = :name", {"result": new_init, "name": name})
+ gs.gui_service.quick_gui(name + ": " + str(new_init), text_type='header', box_align='left')
+ init_db.commit()
+ init_db.close()
+ 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 subtract 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_db.commit()
+ init_db.close()
+
+ def cmd_rollinit(self, data):
+ try:
+ init_db = sqlite3.connect('init.db')
+ cur = init_db.cursor()
+ init = init_db.cursor()
+ cur.execute("SELECT * from inits")
+ ret_text = ""
+ for row in cur.fetchall():
+ ret_text += str(row)
+ number_of_dice = int(row[0])
+ init_bonus = int(row[1])
+ ret_text = "
Init For " + str(row[3]) + ":
"
+ result = 0
+ for i in range(number_of_dice):
+ random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
+ this_die = random.randint(1,6)
+ result = result + this_die
+ ret_text += f"{this_die} + "
+ result = result + init_bonus
+ init.execute("UPDATE inits SET total = :result WHERE name = :name", {"result": result, "name": row[3]})
+ ret_text += f" {init_bonus}
{result}"
+ gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
+ init_db.commit()
+ init_db.close()
return
except IndexError:
log(ERROR, CMD_INVALID_CUSTOM_ROLL,
@@ -68,7 +180,7 @@ class Plugin(PluginBase):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
- ret_text = "
Die Pool:
"
+ ret_text = "
Die Pool:
"
successes = 0
ones = 0
for i in range(number_of_dice):
@@ -93,7 +205,7 @@ class Plugin(PluginBase):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
- ret_text = "
Die Pool:
"
+ ret_text = "
Die Pool:
"
successes = 0
ones = 0
explosions = 0