commit
36843ddd61
@ -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 |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,224 @@ |
|||||||
|
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_bw(self, data): |
||||||
|
all_data = data.message.strip().split() |
||||||
|
try: |
||||||
|
shade = all_data[1][0] |
||||||
|
if shade == "B" or shade == "b": |
||||||
|
size = 4 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
elif shade == "G" or shade == "g": |
||||||
|
size = 3 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
elif shade == "W" or shade == "w": |
||||||
|
size = 2 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
else: |
||||||
|
number_of_dice = int(all_data[1]) |
||||||
|
size = 4 |
||||||
|
astrodice = 0 |
||||||
|
if len(all_data) > 2: |
||||||
|
if all_data[2] == "a" or all_data[2] == "A": |
||||||
|
astrodice = 1 |
||||||
|
elif all_data[2] == "aa" or all_data[2] == "AA": |
||||||
|
astrodice = 2 |
||||||
|
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 >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 1: |
||||||
|
ones = ones + 1 |
||||||
|
if astrodice > 0: |
||||||
|
ret_text += f"<br>Astrology:<br>" |
||||||
|
astrosplosions = 0; |
||||||
|
for i in range(astrodice): |
||||||
|
this_die = random.randint(1,6) |
||||||
|
if i == 0: |
||||||
|
ret_text += f"{this_die}" |
||||||
|
else: |
||||||
|
ret_text += f", {this_die}" |
||||||
|
if this_die >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 6: |
||||||
|
astrosplosions = astrosplosions + 1 |
||||||
|
if this_die == 1: |
||||||
|
new_die = random.randint(1,6) |
||||||
|
ret_text += f", <font color=\"red\">{new_die}</font>" |
||||||
|
if new_die < size: |
||||||
|
successes = successes - 1 |
||||||
|
i = 0 |
||||||
|
while i < astrosplosions: |
||||||
|
if i == 0: |
||||||
|
ret_text += f", {this_die}, " |
||||||
|
else: |
||||||
|
ret_text += f", {this_die}" |
||||||
|
if this_die >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 1: |
||||||
|
ones = ones + 1 |
||||||
|
if this_die == 6: |
||||||
|
astrosplosions += 1 |
||||||
|
i = i + 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_bwo(self, data): |
||||||
|
all_data = data.message.strip().split() |
||||||
|
try: |
||||||
|
shade = all_data[1][0] |
||||||
|
if shade == "B" or shade == "b": |
||||||
|
size = 4 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
elif shade == "G" or shade == "g": |
||||||
|
size = 3 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
elif shade == "W" or shade == "w": |
||||||
|
size = 2 |
||||||
|
number_of_dice = int(all_data[1][1:]) |
||||||
|
else: |
||||||
|
number_of_dice = int(all_data[1]) |
||||||
|
size = 4 |
||||||
|
astrodice = 0 |
||||||
|
if len(all_data) > 2: |
||||||
|
if all_data[2] == "a" or all_data[2] == "A": |
||||||
|
astrodice = 1 |
||||||
|
elif all_data[2] == "aa" or all_data[2] == "AA": |
||||||
|
astrodice = 2 |
||||||
|
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 >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 1: |
||||||
|
ones = ones + 1 |
||||||
|
if this_die == 6: |
||||||
|
number_of_dice += 1 |
||||||
|
explosions = explosions + 1 |
||||||
|
i = i + 1 |
||||||
|
if astrodice > 0: |
||||||
|
ret_text += f"<br>Astrology:<br>" |
||||||
|
astrosplosions = 0; |
||||||
|
for i in range(astrodice): |
||||||
|
this_die = random.randint(1,6) |
||||||
|
if i == 0: |
||||||
|
ret_text += f"{this_die}" |
||||||
|
else: |
||||||
|
ret_text += f", {this_die}" |
||||||
|
if this_die >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 6: |
||||||
|
astrosplosions = astrosplosions + 1 |
||||||
|
if this_die == 1: |
||||||
|
new_die = random.randint(1,6) |
||||||
|
ret_text += f", <font color=\"red\">{new_die}</font>" |
||||||
|
if new_die < size: |
||||||
|
successes = successes - 1 |
||||||
|
i = 0 |
||||||
|
while i < astrosplosions: |
||||||
|
if i == 0: |
||||||
|
ret_text += f", {this_die}, " |
||||||
|
else: |
||||||
|
ret_text += f", {this_die}" |
||||||
|
if this_die >= size: |
||||||
|
successes = successes + 1 |
||||||
|
if this_die == 1: |
||||||
|
ones = ones + 1 |
||||||
|
if this_die == 6: |
||||||
|
astrosplosions += 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_advancement(self, data): |
||||||
|
gs.gui_service.quick_gui("<table style=\"border:1px solid white\"><tr> <th></th> <th>Routine</th> <th>Difficult</th> <th>Challenging </th></tr> <tr> <td>1D</td> <td>Ob1 *</td> <td>Ob 1*</td> <td>Ob 2+ </td></tr> <tr> <td>2D</td> <td>Ob1</td> <td>Ob 2</td> <td>Ob 3+ </td></tr> <tr> <td>3D</td> <td>Ob1-2</td> <td>Ob 3</td> <td>Ob 4+ </td></tr> <tr> <td>4D</td> <td>Ob1-2</td> <td>Ob 3-4</td> <td>Ob 5+ </td></tr> <tr> <td>5D</td> <td>Ob1-3</td> <td>Ob 4-5</td> <td>Ob 6+ </td></tr> <tr> <td>6D</td> <td>Ob1-4</td> <td>Ob 5-6</td> <td>Ob 7+ </td></tr> <tr> <td>7D</td> <td>Ob1-4</td> <td>Ob 5-7</td> <td>Ob 8+ </td></tr> <tr> <td>8D</td> <td>Ob1-5</td> <td>Ob 6-8</td> <td>Ob 9+ </td></tr><tr><td>9D</td> <td>Ob1-6</td> <td>Ob 7-9</td> <td>Ob 10+ </td></tr> <tr> <td>10D</td> <td>Ob1-7</td> <td>Ob 8-10</td> <td>Ob 11+ </td></tr> <tr> <td>11D</td> <td>Ob1-8</td> <td>Ob 9-11</td> <td>Ob 12+ </td></tr> <tr> <td>12D</td> <td>Ob1-9</td> <td>Ob 10-12</td> <td>Ob 13+ </td></tr> <tr> <td>13D</td> <td>Ob1-10</td> <td>Ob 11-13</td> <td>Ob 14+ </td></tr> <tr> <td>14D</td> <td>Ob1-11</td> <td>Ob 12-14</td> <td>Ob 15+ </td></tr> <tr> <td>15D</td> <td>Ob1-12</td> <td>Ob 13-15</td> <td>Ob 16+ </td></tr> <tr> <td>16D</td> <td>Ob1-13</td> <td>Ob 14-16</td> <td>Ob 17+ </td></tr> <tr> <td>17D</td> <td>Ob1-14</td> <td>Ob 15-17</td> <td>Ob 18+ </td></tr> <tr> <td>18D</td> <td>Ob1-15</td> <td>Ob 16-18</td> <td>Ob 19+ </td></tr> </table>", text_type='header', box_align='left') |
||||||
|
return |
||||||
|
|
||||||
|
def cmd_prayers(self, data): |
||||||
|
gs.gui_service.quick_gui("<table><tr><th>Ob</th><th>Effect</th></tr><tr><td>2</td><td>Boon: Open end any one ability for the rest of the scene.</td></tr><tr><td>3</td><td>Blessing: Add +1D to one health, steel, stat, or skill test (duration Intent)</td></tr><tr><td>3</td><td>Curse: Add +1 Ob to a single Ability for a single target, for a scene.</td></tr><tr><td>4</td><td>Aid: Add +1D plus an additional +1D per margain of success (maximum +3D) to any stat, skill, health, or steel test. You may cast this at the beginning of the scene and save it until needed, but must pick the stat/skill/whatever at casting time.</td></tr><tr><td>4-6</td><td>Hinderance: Immobalize a foe for a number of Fight actions equal to half your Faith. Base Ob is 4 and +1 per additional Foe.</td></tr><tr><td>5</td><td>Guidance: You can find the correct path. Literally or metaphorically.</td></tr><tr><td>5</td><td>Minor Miracle: When it is dark, we pray for light. When sorcerers chant, we pray their spells be broken. When the Blade is snapped, we pray that it be made whole. When blood ebbs from the wound, we pray that it be closed.</td></tr><tr><td>5</td><td>Purification: With the touch of a hand, drive out rot and lesser Evil Spirirts (Strength/Will B5 or lower).</td></tr><tr><td>6</td><td>Consecration: A lengthy prayer. Bar Spirits and Daemons whose Will is less than the user\'s Faith.</td></tr><tr><td>7</td><td>Inspiration: Reveal what the priest wishes to know to them. Also often what they did not intend to learn.</td></tr><tr><td>8</td><td>Intercession: Bring the devotee from danger. Or bring the danger from the devotee.</td></tr><tr><td>10</td><td>Miracle: When all hope is lost, when the cataclysm has come, we pray for the divine to manifest and save us. This is the big one - the column of scouring fire, the parting of the seas, the raging storm that destroys the fleet.</td></tr></table>", text_type='header', box_align='left') |
||||||
|
return |
||||||
|
|
||||||
|
def cmd_secondsight(self, data): |
||||||
|
gs.gui_service.quick_gui("<table><tr><td>Ob 1</td><td>high power magic (major miracles, Mjolnir, the Burning Wheel, Ob 10 spells, Strength 10 spirits, etc.)</td></tr><tr><td>Ob 5</td><td>moderately-powered magic (minor miracles, Ob 5 spells, a risen corpse, the Belt of Flying, Dragon Slaying Sword, Spirit Weapons, Strength 5-spirits)</td></tr><tr><td>Ob 8</td><td>low power magic (Red Spectacles, Bless/Curse, Ob 2 spells, Strength 2 spirits etc.)</td></tr></table>", text_type='header', box_align='left') |
||||||
|
return |
||||||
|
|
||||||
|
def cmd_touchofages(self, data): |
||||||
|
gs.gui_service.quick_gui("<table><tr><td>Ob 1</td><td>Type/name of object</td></tr><tr><td>Ob 2</td><td>Age of object</td></tr><tr><td>Ob 3</td><td>Length of the time the object has been in its current location</td></tr><tr><td>Ob 4</td><td>Recent events surrounding the object that left physical evidence</td></tr><tr><td>Ob 5</td><td>Recent events that left no physical mark</td></tr><tr><td>Ob 6</td><td>Past events that left their mark</td></tr><tr><td>Ob 7</td><td>Past events that left no mark</td></tr></table>", text_type='header', box_align='left') |
||||||
|
return |
||||||
|
|
||||||
|
def cmd_aurareading(self, data): |
||||||
|
gs.gui_service.quick_gui("<table><tr><td>Detecting if the subject is alive, dead, from this plane or another</td><td>Ob 1</td></tr><tr><td>Reading an aura trait</td><td>Ob 1</td></tr><tr><td>Reading mood</td><td>Ob 2</td></tr><tr><td>Seeing a character trait</td><td>Ob 3</td></tr><tr><td>Seeing a die or call-on trait</td><td>Ob 4</td></tr><tr><td>Sensing a person's intent</td><td>Ob 4</td></tr><tr><td>Seeing an Instinct</td><td>Ob 6</td></tr><tr><td>Seeing a Belief</td><td>Ob 7</td></tr><tr><td>Seeing a character's past</td><td>Ob 8</td></tr><tr><td>Seeing a character's future</td><td>Ob 9</td></tr><tr><td>Reading an object to see if it is magical or mundane</td><td>Ob 1</td></tr><tr><td>Reading a school of magic</td><td>Ob 2</td></tr><tr><td>Deciphering a facet of a spell or enchantment</td><td>Ob 3</td></tr><tr><td>Naming a spell as it is being cast</td><td>Ob 6</td></tr><tr><td>Detecting the presence and nature of a spirit</td><td>Ob 10 - strength</td></tr></table>", text_type='header', box_align='left') |
||||||
|
return |
||||||
|
|
||||||
|
def cmd_sessionend(self, data): |
||||||
|
gs.gui_service.quick_gui("<table> <tbody><tr> <th>Name</th> <th>Earns/Type</th> <th>Description </th></tr> <tr> <td>Belief</td> <td>1 <i>Fate</i></td> <td>Driving the game forward with a Belief </td></tr> <tr> <td>Instinct</td> <td>1 <i>Fate</i></td> <td>Playing an Instinct makes the character's life difficult </td></tr> <tr> <td>Trait</td> <td>1 <i>Fate</i></td> <td>Invoking a trait that sends the story in an unforeseen direction </td></tr> <tr> <td>Humour</td> <td>1 <i>Fate</i></td> <td>For an in-character game-stopper </td></tr> <tr> <td>Right Skill, Right Time</td> <td>1 <i>Fate</i></td> <td>For having a skill to make the story go </td></tr> <tr> <td>Embodiment</td> <td>1 <i>Persona</i></td> <td>For really good or distinctive roleplaying </td></tr> <tr> <td>Moldbreaker</td> <td>1 <i>Persona</i></td> <td>For going beyond the bounds of the character </td></tr> <tr> <td>Workhorse</td> <td>1 <i>Persona</i></td> <td>For doing all the work of the scenario </td></tr> <tr> <td>MVP</td> <td>1 <i>Persona</i></td> <td>For being the crucial element of success </td></tr> <tr> <td>Personal Goals</td> <td>1 <i>Persona</i></td> <td>Revenge, triumph, seduction, victory </td></tr> <tr> <td>Greater Goals</td> <td>1 <i>Deeds</i></td> <td>Accomplishing goals bigger than you! </td></tr> <tr> <td>Beyond the Call</td> <td>1 <i>Deeds</i></td> <td>Helping, no matter the cost </td></tr></tbody></table>", text_type='header', box_align='left') |
@ -0,0 +1,9 @@ |
|||||||
|
All commands can be run by typing it in the chat or privately messaging JJMumbleBot.<br> |
||||||
|
<b>!bw</b>: Roll a bunch of dice, count successes and ones <i>!bw B5</i> will roll a pool of 5 black dice<br> |
||||||
|
<b>!bwo</b>: Roll a pool with exploding 6s, counts successes, ones, and explosions <i>!bwo B5</i> will roll a poll of 5 black dice<br> |
||||||
|
<b>!advancement</b>: Print the table of test types.<br> |
||||||
|
<b>!prayers</b>: Print the table of valid uses of the Faith attribute.<br> |
||||||
|
<b>!secondsight</b>: Print the table of second sight difficulties.<br> |
||||||
|
<b>!touchofages</b>: Print the table of touch of ages difficulties.<br> |
||||||
|
<b>!aurareading</b>: Print the table of aura reading difficulties.<br> |
||||||
|
<b>!sessionend</b>: Print the Artha awards table.<br> |
@ -0,0 +1,29 @@ |
|||||||
|
[Plugin Information] |
||||||
|
PluginVersion = 1.0.0 |
||||||
|
PluginName = Burning Dice |
||||||
|
PluginDescription = A plugin for rolling dice in Burning Wheel. |
||||||
|
PluginLanguage = EN |
||||||
|
PluginCommands: [ |
||||||
|
"bw", |
||||||
|
"advancement", |
||||||
|
"prayers", |
||||||
|
"secondsight", |
||||||
|
"touchofages", |
||||||
|
"aurareading", |
||||||
|
"sessionend", |
||||||
|
"bwo" |
||||||
|
] |
||||||
|
|
||||||
|
[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 |
Binary file not shown.
@ -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,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…
Reference in new issue