You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
shadowdice/shadowdice.py

277 lines
19 KiB

from JJMumbleBot.lib.plugin_template import PluginBase
from JJMumbleBot.lib.utils.plugin_utils import PluginUtilityService
from JJMumbleBot.lib.utils.logging_utils import log
from JJMumbleBot.lib.utils.print_utils import PrintMode
from JJMumbleBot.settings import global_settings as gs
from JJMumbleBot.lib.resources.strings import *
import os
import random
import sqlite3
class Plugin(PluginBase):
def __init__(self):
super().__init__()
from json import loads
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 IF NOT EXISTS inits (dice int, bonus int, total int, name string UNIQUE)")
init_db.commit()
init_db.close()
self.is_running = True
log(
INFO,
f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized.",
origin=L_STARTUP,
print_mode=PrintMode.REG_PRINT.value
)
def quit(self):
self.is_running = False
log(
INFO,
f"Exiting {self.plugin_name} plugin...",
origin=L_SHUTDOWN,
print_mode=PrintMode.REG_PRINT.value
)
def stop(self):
if self.is_running:
self.quit()
def start(self):
if not self.is_running:
self.__init__()
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])
character_name = str(all_data[3])
init_db = sqlite3.connect('init.db')
cur = init_db.cursor()
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')
except IndexError:
gs.gui_service.quick_gui("Format: !addinit #dice #bonus $name",
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]) + "<br>"
init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError:
gs.gui_service.quick_gui("Format: !listinit",
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]) + "<br>"
init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError:
gs.gui_service.quick_gui("Format: !listinitpools",
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) + "<br>"
init_db.commit()
init_db.close()
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
except IndexError:
gs.gui_service.quick_gui("Format: !initpass",
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:
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_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:
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 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:
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 = "<br><font color='red'>Init For " + str(row[3]) + ":</font><br>"
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} </font><br><font color='yellow'> {result}</font>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
init_db.commit()
init_db.close()
return
except IndexError:
gs.gui_service.quick_gui("Format: !rollinit",
text_type='header', box_align='left')
return
def cmd_srun(self, data):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
ret_text = "<br><font color='red'>Die Pool:</font><br>"
successes = 0
ones = 0
for i in range(number_of_dice):
random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
this_die = random.randint(1,6)
if i == 0:
ret_text += f"{this_die}"
else:
ret_text += f", {this_die}"
if this_die > 4:
successes = successes + 1
if this_die == 1:
ones = ones + 1
ret_text += f"<br>Successes: {successes} , Ones: {ones}"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
except IndexError:
gs.gui_service.quick_gui("Format: !srun #",
text_type='header', box_align='left')
return
def cmd_preedge(self, data):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
ret_text = "<br><font color='red'>Die Pool:</font><br>"
successes = 0
ones = 0
explosions = 0
i = 0
while i < number_of_dice:
random.seed(int.from_bytes(os.urandom(8), byteorder="big"))
this_die = random.randint(1,6)
if i == 0:
ret_text += f"{this_die}"
else:
ret_text += f", {this_die}"
if this_die > 4:
successes = successes + 1
if this_die == 1:
ones = ones + 1
if this_die == 6:
i = i-1
explosions = explosions + 1
if i < 1:
ret_text +=f", "
i = i + 1
ret_text += f"<br>Successes: {successes} , Ones: {ones} , Explosions: {explosions}"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
except IndexError:
gs.gui_service.quick_gui("Format: !preedge #",
text_type='header', box_align='left')
return
def cmd_assensing(self, data):
ret_text = "<table border=\"1\" style=\"text-align:center;background:black;color:white;\"><caption style=\"color:gold;\">ASSENSING TABLE</caption><tbody><tr><th style=\"background:black;color:gold;\">HITS</th><th style=\"background:black;color:gold;\">INFORMATION GAINED</th></tr><tr><td>0</td><td>None</td></tr><tr><td>1</td><td>The general state of the subject’s health (healthy, injured, ill, etc.). The subject’s general emotional state or impression (happy, sad, angry, etc.). Whether the subject is mundane or Awakened. </td></tr><tr><td>2</td><td>The presence and location of cyberware implants. The class of a magical subject (fire elemental, manipulation spell, power focus, curse ritual, and so on). If you have seen the subject’s aura before, you may recognize it, regardless of physical disguises or alterations</td></tr><tr><td>3</td><td>The presence and location of alphaware cyber implants. Whether the subject’s Essence and Magic are higher, lower, or equal to your own. Whether the subject’s Force is higher, lower, or equal to your Magic. A general diagnosis for any maladies (diseases or toxins) the subject suffers. Any astral signatures present on the subject. </td></tr><tr><td>4</td><td>The presence and location of bioware implants and betaware cyber implants. The exact Essence, Magic, and Force of the subject. The general cause of any astral signature (combat spell, alchemical combat spell, air spirit, and so on). </td></tr><tr><td>5+</td><td>The presence and location of deltaware implants, gene treatments, and nanotech. An accurate diagnosis of any disease or toxins which afflict the subject. The fact that a subject is a technomancer. </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_delivery(self, data):
ret_text = "<table border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:gold;\">DELIVERY TIMES TABLE </caption> <tbody><tr> <th style=\"background:black;color:gold;\">GEAR COST </th> <th style=\"background:black;color:gold;\">DELIVERY TIME </th></tr> <tr> <td>Up to 100¥</td> <td>6 hours </td></tr> <tr> <td>101¥ to 1,000¥</td> <td>1 day </td></tr> <tr> <td>1,000¥ to 10,000¥</td> <td>2 days </td></tr> <tr> <td>10,001 to 100,000¥</td> <td>1 week </td></tr> <tr> <td>More than 100,000¥</td> <td>1 month </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_concealability(self, data):
ret_text = "<table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;\"> <caption style=\"color:gold;\">CONCEALABILITY MODIFIERS </caption> <caption style=\"color:black;\">*Applies to observer </caption> <tbody><tr> <th style=\"background:black;color:gold;\">MODIFIER*</th> <th style=\"background:black;color:gold;\">EXAMPLE ITEMS </th></tr> <tr> <td style=\"background:black;color:white;\">–6 </td> <td style=\"background:black;color:white;text-align:left;\">RFID tag, bug slap patch, microdrone, contact lenses </td></tr> <tr> <td style=\"background:black;color:white;\">–4 </td> <td style=\"background:black;color:white;text-align:left;\">Hold-out pistol, monowhip, ammo clip, credstick, chips/softs, sequencer/passkey, autopicker, lockpick set, commlink, glasses </td></tr> <tr> <td style=\"background:black;color:white;\">–2 </td> <td style=\"background:black;color:white;text-align:left;\">Light pistol, knife, sap, minidrone, microgrenade, flash-pak, jammer, cyberdeck, rigger command console </td></tr> <tr> <td style=\"background:black;color:white;\">0 </td> <td style=\"background:black;color:white;text-align:left;\">Heavy pistol, machine pistol with folding stock collapsed, grenade, goggles, ammo belt/drum, club, extendable baton (collapsed) </td></tr> <tr> <td style=\"background:black;color:white;\">+2 </td> <td style=\"background:black;color:white;text-align:left;\">SMG, machine pistol with folding stock extended, medkit, small drone, extendable baton (extended), stun baton </td></tr> <tr> <td style=\"background:black;color:white;\">+4 </td> <td style=\"background:black;color:white;text-align:left;\">Sword, sawed-off shotgun, bullpup assault rifle </td></tr> <tr> <td style=\"background:black;color:white;\">+6 </td> <td style=\"background:black;color:white;text-align:left;\">Katana, monosword, shotgun, assault rifle, sport rifle, crossbow </td></tr> <tr> <td style=\"background:black;color:white;\">+8 </td> <td style=\"background:black;color:white;text-align:left;\">Sniper rifle, bow, grenade launcher, medium drone </td></tr> <tr> <td style=\"background:black;color:white;\">+10/Forget about it </td> <td style=\"background:black;color:white;text-align:left;\">Machine gun, rocket launcher, missile launcher, staff, claymore, metahuman body </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_perception_mods(self, data):
ret_text = "<table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:gold;\">PERCEPTION TEST MODIFIERS </caption> <tbody><tr> <th style=\"background:black;color:gold;\">SITUATION </th> <th style=\"background:black;color:gold;\">DICE POOL MODIFIER </th></tr> <tr> <td>Perceiver is distracted</td> <td>-2 </td></tr> <tr> <td>Perciever is specifically looking/listening for it</td> <td>+3 </td></tr> <tr> <td>Object/sound not in immediate vicinity</td> <td>-2 </td></tr> <tr> <td>Object/sound far away</td> <td>-3 </td></tr> <tr> <td>Object/sound stands out in some way</td> <td>+2 </td></tr> <tr> <td>Interfering sight/odor/sound</td> <td>-2 </td></tr> <tr> <td>Perceiver has active enhancements</td> <td>+ Rating </td></tr> <tr> <td>Visibility and Light</td> <td>Environmental Factors (Above) </td></tr></tbody></table> <table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:black;\">PERCEPTION THRESHOLDS </caption> <tbody><tr> <th style=\"background:black;color:gold;\">ITEM/EVENT IS: </th> <th style=\"background:black;color:gold;\">THRESHOLD </th> <th style=\"background:black;color:gold;\">EXAMPLES </th></tr> <tr> <td>Obvious</td> <td>1</td> <td>Neon sign, running crowd, yelling, gunfire </td></tr> <tr> <td>Normal</td> <td>2</td> <td>Street sign, pedestrian, conversation, silenced gunfire </td></tr> <tr> <td>Obscured/Small/Muffled</td> <td>3</td> <td>Item dropped under table, contact lens, whispering </td></tr> <tr> <td>Hidden/Micro/Silent</td> <td>4</td> <td>Secret door, needle in haystack, subvocal speech </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_environmental(self, data):
ret_text = "<table class=\"wikitable\" border=\"1\" style=\"text-align:center;background:black;color:white;\"> <caption style=\"color:gold;\">ENVIRONMENTAL </caption> <tbody><tr> <th style=\"background:black;color:gold;\">VISIBILITY </th> <th style=\"background:black;color:gold;\">LIGHT / GLARE </th> <th style=\"background:black;color:gold;\">WIND </th> <th style=\"background:black;color:gold;\">RANGE </th> <th style=\"background:black;color:gold;\">MODIFIER </th></tr> <tr> <td>Clear</td> <td>Full Light / No Glare</td> <td>None / Light Breeze</td> <td>Short</td> <td>0 </td></tr> <tr> <td>Light Rain / Fog / Smoke</td> <td>Partial Light / Weak Glare</td> <td>Light Winds / Light Breeze</td> <td>Medium</td> <td>-1 </td></tr> <tr> <td>Moderate Rain / Fog / Smoke</td> <td>Dim Light / Moderate Glare</td> <td>Moderate Winds / Light Breeze</td> <td>Long</td> <td>-3 </td></tr> <tr> <td>Heavy Rain / Fog / Smoke</td> <td>Total Darkness/ Blinding Glare</td> <td>Strong Winds / Light Breeze</td> <td>Extreme</td> <td>-6 </td></tr> <tr> <td>Combination of two or more conditions at the -6 level row</td> <td></td> <td></td> <td></td> <td>-10 </td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')
def cmd_hosts(self, data):
ret_text = "<table border=\"1\" style=\"text-align:center;background:black;color:white;\"><caption style=\"color:gold;\">SAMPLE HOST RATINGS</caption><tbody><tr><th style=\"background:black;color:gold;\">EXAMPLES</th><th style=\"background:black;color:gold;\">RATING</th></tr><tr><td>Personal sites, pirate archives, public education</td><td>1-2</td></tr><tr><td>Low-end commercial, private business, public libraries, small policlubs</td><td>3-4</td></tr><tr><td>Social media, small colleges and universities, local police, international policlubs</td><td>5-6</td></tr><tr><td>Matrix games, local corporate hosts, large universities, low-level government</td><td>7-8</td></tr><tr><td>Affluent groups, regional corporate hosts, major government, secure sites</td><td>9-10</td></tr><tr><td>Megacorporate headquarters, military command, clandestine head office</td><td>11-12</td></tr></tbody></table>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='center')