Created basic tools for Shadowrun dice

main
silverwizard 3 years ago
commit 1ae050c3b2
  1. 3
      README.md
  2. BIN
      __pycache__/shadowdice.cpython-38.pyc
  3. 2
      aliases.csv
  4. 9
      help.html
  5. 29
      metadata.ini
  6. 5
      privileges.csv
  7. BIN
      resources/__pycache__/strings.cpython-38.pyc
  8. 10
      resources/strings.py
  9. 141
      shadowdice.py
  10. 23
      tests/test_randomizer_metadata.py

@ -0,0 +1,3 @@
A simple plugin for [JJMumbleBot](https://duckboss.github.io/JJMumbleBot/wiki/new/whats_new.html) which should do basic dice. See the !help shadowdice command for options.
Simply drop this file in the extensions folder for JJMumbleBot and it should just start working

@ -0,0 +1,2 @@
alias,command
predge,(preedge)

@ -0,0 +1,9 @@
All commands can be run by typing it in the chat or privately messaging JJMumbleBot.<br>
<b>!init</b>: Roll init dice <i>!init 4 11</i> will roll 4d6+11<br>
<b>!srun</b>: Roll a bunch of dice, count successes and ones <i>!srun 12</i> will roll a pool of 12 dice<br>
<b>!preedge</b>: Roll a pool with exploding 6s, counts successes, ones, and explosions <i>!preedge 12</i> will roll a poll of 12 dice<br>
<b>!assensing</b>: Prints the Shadowrun assensing table<br>
<b>!concealability</b>: Prints the Shadowrun concealability modifiers table<br>
<b>!perception_mods</b>: Prints the Shadowrun perception modifiers table<br>
<b>!delivery</b>: Prints the Shadowrun delivery times table<br>
<b>!environmental</b>: Prints the Shadowrun environmental modifiers table<br>

@ -0,0 +1,29 @@
[Plugin Information]
PluginVersion = 1.0.0
PluginName = Shadow Dice
PluginDescription = A plugin for rolling dice in Shadowrun 5e.
PluginLanguage = EN
PluginCommands: [
"init",
"srun",
"preedge",
"assensing",
"delivery",
"perception_mods",
"environmental",
"concealability"
]
[Plugin Settings]
; List commands that need the core thread to wait for completion.
; This may include processes that require multiple commands in succession.
; For example: [Youtube Plugin - !yt -> !p] process requires 2 commands in that order.
ThreadWaitForCommands: []
UseSingleThread = False
[Plugin Type]
ControllablePlugin = True
AudioPlugin = False
ImagePlugin = False
CorePlugin = False
ExtensionPlugin = True

@ -0,0 +1,5 @@
command,level
init,1
srun,1
preedge,1
assensing,1

@ -0,0 +1,10 @@
from JJMumbleBot.lib.utils.runtime_utils import get_command_token
###########################################################################
# RANDOMIZER PLUGIN CONFIG PARAMETER STRINGS
# COMMAND ERROR STRINGS
CMD_INVALID_CUSTOM_ROLL = [
"ERROR: Incorrect command formatting!",
f"Format: {get_command_token()}customroll 'number_of_dice' 'dice_faces'"
]

@ -0,0 +1,141 @@
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.plugins.extensions.randomizer.resources.strings import CMD_INVALID_CUSTOM_ROLL
from JJMumbleBot.settings import global_settings as gs
from JJMumbleBot.lib.resources.strings import *
import os
import random
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))
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_init(self, data):
all_data = data.message.strip().split()
try:
number_of_dice = int(all_data[1])
init_bonus = int(all_data[2])
ret_text = "<br><font color='red'>Init Roll:</font><br><font colour='blue'>"
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} </font><br><font color='yellow'> {result}</font>"
gs.gui_service.quick_gui(ret_text, text_type='header', box_align='left')
return
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_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><font colour='blue'>"
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)
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:
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_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><font colour='blue'>"
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)
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
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:
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_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')

@ -0,0 +1,23 @@
import configparser
from json import loads
from JJMumbleBot.lib.utils.dir_utils import get_extension_plugin_dir
from JJMumbleBot.lib.resources.strings import C_PLUGIN_INFO, P_PLUGIN_VERS, P_PLUGIN_CMDS, C_PLUGIN_SET
from JJMumbleBot.plugins.extensions.randomizer.randomizer import Plugin
class TestRandomizer:
def setup_method(self):
# Initialize configs.
self.cfg = configparser.ConfigParser()
self.cfg.read(f"{get_extension_plugin_dir()}/randomizer/metadata.ini")
def test_plugin_version(self):
assert self.cfg[C_PLUGIN_INFO][P_PLUGIN_VERS] == "1.0.0"
def test_commands_list_size(self):
commands_list = list(loads(self.cfg[C_PLUGIN_INFO][P_PLUGIN_CMDS]))
assert len(commands_list) == 3
def test_match_commands_to_methods(self):
method_list = [item for item in dir(Plugin) if callable(getattr(Plugin, item)) and item.startswith("cmd_")]
assert len(method_list) == len(list(loads(self.cfg[C_PLUGIN_INFO][P_PLUGIN_CMDS])))
Loading…
Cancel
Save