commit 36843ddd615d86d1aff7e96bb263fdb5001561e9 Author: silverwizard Date: Wed Apr 27 21:24:32 2022 -0400 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..b338411 --- /dev/null +++ b/README.md @@ -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 diff --git a/__pycache__/burningdice.cpython-38.pyc b/__pycache__/burningdice.cpython-38.pyc new file mode 100644 index 0000000..d1998ff Binary files /dev/null and b/__pycache__/burningdice.cpython-38.pyc differ diff --git a/__pycache__/shadowdice.cpython-38.pyc b/__pycache__/shadowdice.cpython-38.pyc new file mode 100644 index 0000000..df675da Binary files /dev/null and b/__pycache__/shadowdice.cpython-38.pyc differ diff --git a/aliases.csv b/aliases.csv new file mode 100644 index 0000000..ec5ee8c --- /dev/null +++ b/aliases.csv @@ -0,0 +1,5 @@ +alias,command +tests,(advancement) +eos,(sessionend) +endofsession,(sessionend) +endsession,(sessionend) diff --git a/burningdice.py b/burningdice.py new file mode 100644 index 0000000..b7da3f7 --- /dev/null +++ b/burningdice.py @@ -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 = "
Die Pool:
" + 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"
Astrology:
" + 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", {new_die}" + 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"
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 = "
Die Pool:
" + 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"
Astrology:
" + 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", {new_die}" + 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"
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("
Routine Difficult Challenging
1D Ob1 * Ob 1* Ob 2+
2D Ob1 Ob 2 Ob 3+
3D Ob1-2 Ob 3 Ob 4+
4D Ob1-2 Ob 3-4 Ob 5+
5D Ob1-3 Ob 4-5 Ob 6+
6D Ob1-4 Ob 5-6 Ob 7+
7D Ob1-4 Ob 5-7 Ob 8+
8D Ob1-5 Ob 6-8 Ob 9+
9D Ob1-6 Ob 7-9 Ob 10+
10D Ob1-7 Ob 8-10 Ob 11+
11D Ob1-8 Ob 9-11 Ob 12+
12D Ob1-9 Ob 10-12 Ob 13+
13D Ob1-10 Ob 11-13 Ob 14+
14D Ob1-11 Ob 12-14 Ob 15+
15D Ob1-12 Ob 13-15 Ob 16+
16D Ob1-13 Ob 14-16 Ob 17+
17D Ob1-14 Ob 15-17 Ob 18+
18D Ob1-15 Ob 16-18 Ob 19+
", text_type='header', box_align='left') + return + + def cmd_prayers(self, data): + gs.gui_service.quick_gui("
ObEffect
2Boon: Open end any one ability for the rest of the scene.
3Blessing: Add +1D to one health, steel, stat, or skill test (duration Intent)
3Curse: Add +1 Ob to a single Ability for a single target, for a scene.
4Aid: 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.
4-6Hinderance: Immobalize a foe for a number of Fight actions equal to half your Faith. Base Ob is 4 and +1 per additional Foe.
5Guidance: You can find the correct path. Literally or metaphorically.
5Minor 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.
5Purification: With the touch of a hand, drive out rot and lesser Evil Spirirts (Strength/Will B5 or lower).
6Consecration: A lengthy prayer. Bar Spirits and Daemons whose Will is less than the user\'s Faith.
7Inspiration: Reveal what the priest wishes to know to them. Also often what they did not intend to learn.
8Intercession: Bring the devotee from danger. Or bring the danger from the devotee.
10Miracle: 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.
", text_type='header', box_align='left') + return + + def cmd_secondsight(self, data): + gs.gui_service.quick_gui("
Ob 1high power magic (major miracles, Mjolnir, the Burning Wheel, Ob 10 spells, Strength 10 spirits, etc.)
Ob 5moderately-powered magic (minor miracles, Ob 5 spells, a risen corpse, the Belt of Flying, Dragon Slaying Sword, Spirit Weapons, Strength 5-spirits)
Ob 8low power magic (Red Spectacles, Bless/Curse, Ob 2 spells, Strength 2 spirits etc.)
", text_type='header', box_align='left') + return + + def cmd_touchofages(self, data): + gs.gui_service.quick_gui("
Ob 1Type/name of object
Ob 2Age of object
Ob 3Length of the time the object has been in its current location
Ob 4Recent events surrounding the object that left physical evidence
Ob 5Recent events that left no physical mark
Ob 6Past events that left their mark
Ob 7Past events that left no mark
", text_type='header', box_align='left') + return + + def cmd_aurareading(self, data): + gs.gui_service.quick_gui("
Detecting if the subject is alive, dead, from this plane or anotherOb 1
Reading an aura traitOb 1
Reading moodOb 2
Seeing a character traitOb 3
Seeing a die or call-on traitOb 4
Sensing a person's intentOb 4
Seeing an InstinctOb 6
Seeing a BeliefOb 7
Seeing a character's pastOb 8
Seeing a character's futureOb 9
Reading an object to see if it is magical or mundaneOb 1
Reading a school of magicOb 2
Deciphering a facet of a spell or enchantmentOb 3
Naming a spell as it is being castOb 6
Detecting the presence and nature of a spiritOb 10 - strength
", text_type='header', box_align='left') + return + + def cmd_sessionend(self, data): + gs.gui_service.quick_gui("
Name Earns/Type Description
Belief 1 Fate Driving the game forward with a Belief
Instinct 1 Fate Playing an Instinct makes the character's life difficult
Trait 1 Fate Invoking a trait that sends the story in an unforeseen direction
Humour 1 Fate For an in-character game-stopper
Right Skill, Right Time 1 Fate For having a skill to make the story go
Embodiment 1 Persona For really good or distinctive roleplaying
Moldbreaker 1 Persona For going beyond the bounds of the character
Workhorse 1 Persona For doing all the work of the scenario
MVP 1 Persona For being the crucial element of success
Personal Goals 1 Persona Revenge, triumph, seduction, victory
Greater Goals 1 Deeds Accomplishing goals bigger than you!
Beyond the Call 1 Deeds Helping, no matter the cost
", text_type='header', box_align='left') diff --git a/help.html b/help.html new file mode 100644 index 0000000..69af63f --- /dev/null +++ b/help.html @@ -0,0 +1,9 @@ +All commands can be run by typing it in the chat or privately messaging JJMumbleBot.
+!bw: Roll a bunch of dice, count successes and ones !bw B5 will roll a pool of 5 black dice
+!bwo: Roll a pool with exploding 6s, counts successes, ones, and explosions !bwo B5 will roll a poll of 5 black dice
+!advancement: Print the table of test types.
+!prayers: Print the table of valid uses of the Faith attribute.
+!secondsight: Print the table of second sight difficulties.
+!touchofages: Print the table of touch of ages difficulties.
+!aurareading: Print the table of aura reading difficulties.
+!sessionend: Print the Artha awards table.
diff --git a/metadata.ini b/metadata.ini new file mode 100644 index 0000000..58bbd26 --- /dev/null +++ b/metadata.ini @@ -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 diff --git a/privileges.csv b/privileges.csv new file mode 100644 index 0000000..36f88ad --- /dev/null +++ b/privileges.csv @@ -0,0 +1,3 @@ +command,level +bw,1 +bwo,1 diff --git a/resources/__pycache__/strings.cpython-38.pyc b/resources/__pycache__/strings.cpython-38.pyc new file mode 100644 index 0000000..1ec22b7 Binary files /dev/null and b/resources/__pycache__/strings.cpython-38.pyc differ diff --git a/resources/strings.py b/resources/strings.py new file mode 100644 index 0000000..c92797f --- /dev/null +++ b/resources/strings.py @@ -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'" +] diff --git a/tests/test_randomizer_metadata.py b/tests/test_randomizer_metadata.py new file mode 100644 index 0000000..f3abda3 --- /dev/null +++ b/tests/test_randomizer_metadata.py @@ -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])))