diff --git a/Dicebot/README.md b/Dice/README.md similarity index 92% rename from Dicebot/README.md rename to Dice/README.md index 42dfc43..968b122 100644 --- a/Dicebot/README.md +++ b/Dice/README.md @@ -4,11 +4,11 @@ Install dependencies: python3 -m pip install -r requirements.txt ## Description -Dicebot plugin contains the commands which simulate rolling of dice. +Dice plugin contains the commands which simulate rolling of dice. Though core supybot plugin Games contain 'dice' command, it is very simple and is not sufficient for advanced uses, such as online playing of tabletop role-playing games using IRC. -The most basic feature of any dicebot is, of course, rolling of one or several +The most basic feature of any dice plugin is, of course, rolling of one or several identical dice and showing the results. That is what core 'dice' command can do. It takes an expression such as 3d6 and returns a series of numbers - results of rolling each (of 3) die (6-sided): '2, 4, and 4'. This may be @@ -61,9 +61,9 @@ shuffled before drawing next card. ## Thanks Ur-DnD roleplaying community (#dnd @ RusNet) for games, talking and fun, and -personally Zuzuzu for describing basic dicebot requirements, which led to +personally Zuzuzu for describing basic Dice requirements, which led to writing the first version of this plugin in August 2007. ## Tests -Run tests: supybot-test Dicebot && pytest +Run tests: supybot-test Dice && pytest diff --git a/Dicebot/__init__.py b/Dice/__init__.py similarity index 99% rename from Dicebot/__init__.py rename to Dice/__init__.py index 2791915..ca1ef81 100644 --- a/Dicebot/__init__.py +++ b/Dice/__init__.py @@ -28,7 +28,7 @@ ### """ -Dice bot +Dice """ import supybot @@ -55,7 +55,7 @@ from . import deck from imp import reload # In case we're being reloaded. reload(deck) -reload(plugin) +reload(plugin) # Add more reloads here if you add third-party modules and want them to be # reloaded when this plugin is reloaded. Don't forget to import them as well! diff --git a/Dicebot/config.py b/Dice/config.py similarity index 92% rename from Dicebot/config.py rename to Dice/config.py index a296790..ce97dbd 100644 --- a/Dicebot/config.py +++ b/Dice/config.py @@ -35,14 +35,14 @@ def configure(advanced): # a bool that specifies whether the user identified himself as an advanced # user or not. You should effect your configuration by manipulating the # registry as appropriate. - conf.registerPlugin('Dicebot', True) + conf.registerPlugin('Dice', True) -Dicebot = conf.registerPlugin('Dicebot') -conf.registerChannelValue(Dicebot, 'autoRoll', +Dice = conf.registerPlugin('Dice') +conf.registerChannelValue(Dice, 'autoRoll', registry.Boolean(False, """Determines whether the bot will automatically roll the dice it sees in the channel.""")) -conf.registerGlobalValue(Dicebot, 'autoRollInPrivate', +conf.registerGlobalValue(Dice, 'autoRollInPrivate', registry.Boolean(False, """Determines whether the bot will automatically roll the dice it sees in private messages.""")) diff --git a/Dicebot/deck.py b/Dice/deck.py similarity index 100% rename from Dicebot/deck.py rename to Dice/deck.py diff --git a/Dicebot/docs/7th Sea.txt b/Dice/docs/7th Sea.txt similarity index 100% rename from Dicebot/docs/7th Sea.txt rename to Dice/docs/7th Sea.txt diff --git a/Dicebot/docs/DH.txt b/Dice/docs/DH.txt similarity index 100% rename from Dicebot/docs/DH.txt rename to Dice/docs/DH.txt diff --git a/Dicebot/docs/NEWS.txt b/Dice/docs/NEWS.txt similarity index 100% rename from Dicebot/docs/NEWS.txt rename to Dice/docs/NEWS.txt diff --git a/Dicebot/docs/README.txt b/Dice/docs/README.txt similarity index 93% rename from Dicebot/docs/README.txt rename to Dice/docs/README.txt index 45ab7f1..6b42168 100644 --- a/Dicebot/docs/README.txt +++ b/Dice/docs/README.txt @@ -1,10 +1,10 @@ Description ~~~~~~~~~~~ -Dicebot plugin contains the commands which simulate rolling of dice. +Dice plugin contains the commands which simulate rolling of dice. Though core supybot plugin Games contain 'dice' command, it is very simple and is not sufficient for advanced uses, such as online playing of tabletop role-playing games using IRC. -The most basic feature of any dicebot is, of course, rolling of one or several +The most basic feature of any dice plugin is, of course, rolling of one or several identical dice and showing the results. That is what core 'dice' command can do. It takes an expression such as 3d6 and returns a series of numbers - results of rolling each (of 3) die (6-sided): '2, 4, and 4'. This may be @@ -57,6 +57,6 @@ shuffled before drawing next card. Thanks ~~~~~~ Ur-DnD roleplaying community (#dnd @ RusNet) for games, talking and fun, and -personally Zuzuzu for describing basic dicebot requirements, which led to +personally Zuzuzu for describing basic dice requirements, which led to writing the first version of this plugin in August 2007. diff --git a/Dicebot/docs/Shadowrun.txt b/Dice/docs/Shadowrun.txt similarity index 100% rename from Dicebot/docs/Shadowrun.txt rename to Dice/docs/Shadowrun.txt diff --git a/Dicebot/plugin.py b/Dice/plugin.py similarity index 99% rename from Dicebot/plugin.py rename to Dice/plugin.py index f70b1f0..e82dc7f 100644 --- a/Dicebot/plugin.py +++ b/Dice/plugin.py @@ -39,7 +39,7 @@ from supybot.utils.str import format, ordinal import supybot.ircmsgs as ircmsgs import supybot.callbacks as callbacks -class Dicebot(callbacks.Plugin): +class Dice(callbacks.Plugin): """This plugin supports rolling the dice using !roll 4d20+3 as well as automatically rolling such combinations it sees in the channel (if autoRoll option is enabled for that channel) or query (if @@ -65,7 +65,7 @@ class Dicebot(callbacks.Plugin): MAX_ROLLS = 30 def __init__(self, irc): - super(Dicebot, self).__init__(irc) + super(Dice, self).__init__(irc) self.deck = Deck() def _roll(self, dice, sides, mod=0): @@ -505,7 +505,7 @@ class Dicebot(callbacks.Plugin): text = msg.args[1] self._process(irc, text) -Class = Dicebot +Class = Dice # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/Dicebot/requirements.txt b/Dice/requirements.txt similarity index 100% rename from Dicebot/requirements.txt rename to Dice/requirements.txt diff --git a/Dicebot/sevenSea2EdRaiseRoller.py b/Dice/sevenSea2EdRaiseRoller.py similarity index 100% rename from Dicebot/sevenSea2EdRaiseRoller.py rename to Dice/sevenSea2EdRaiseRoller.py diff --git a/Dice/test.py b/Dice/test.py new file mode 100644 index 0000000..dba11b4 --- /dev/null +++ b/Dice/test.py @@ -0,0 +1,115 @@ +### +# Copyright (c) 2007-2010, Andrey Rahmatullin +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +### + +from supybot.test import PluginTestCase + +class DiceTestCase(PluginTestCase): + plugins = ('Dice',) + def testPlugin(self): + self.assertHelp('Dice roll') + self.assertNotError('Dice roll 1d2') + self.assertNoResponse('Dice roll dummy') + + def testRollStd(self): + self.assertRegexp('Dice roll 1d20', r'\[1d20\] \d+') + self.assertRegexp('Dice roll d20', r'\[1d20\] \d+') + self.assertRegexp('Dice roll 1d20+5', r'\[1d20\+5\] \d+') + self.assertRegexp('Dice roll d20+5', r'\[1d20\+5\] \d+') + self.assertRegexp('Dice roll 1d20-30', r'\[1d20-30\] -\d+') + self.assertRegexp('Dice roll d20-30', r'\[1d20-30\] -\d+') + self.assertRegexp('Dice roll 2d20-1', r'\[2d20-1\] \d+') + self.assertRegexp('Dice roll d20-1d6+3', r'\[1d20-1d6\+3\] -?\d+') + self.assertRegexp('Dice roll 1d20+d20+3', r'\[2d20\+3\] \d+') + self.assertRegexp('Dice roll 1d20+4+d6-3', r'\[1d20\+1d6\+1\] \d+') + self.assertNoResponse('Dice roll 1d1') + + def testRollMult(self): + self.assertRegexp('Dice roll 2#1d20', r'\[1d20\] \d+, \d+') + self.assertRegexp('Dice roll 2#d20', r'\[1d20\] \d+, \d+') + self.assertRegexp('Dice roll 2#1d20+5', r'\[1d20\+5\] \d+, \d+') + self.assertRegexp('Dice roll 2#d20+5', r'\[1d20\+5\] \d+, \d+') + self.assertRegexp('Dice roll 2#1d20-30', r'\[1d20-30\] -\d+, -\d+') + self.assertRegexp('Dice roll 2#d20-30', r'\[1d20-30\] -\d+, -\d+') + self.assertRegexp('Dice roll 2#2d20-1', r'\[2d20-1\] \d+, \d+') + self.assertNoResponse('Dice roll 2#1d1') + + def testRollSR(self): + self.assertRegexp('Dice roll 2#sd', r'\(pool 2\) (\d hits?|critical glitch!)') + self.assertRegexp('Dice roll 4#sd', r'\(pool 4\) (\d hits?(, glitch)?|critical glitch!)') + self.assertNoResponse('Dice roll 0#sd') + + def testRollSRX(self): + self.assertRegexp('Dice roll 2#sdx', r'\(pool 2, exploding\) (\d hits?|critical glitch!)') + self.assertRegexp('Dice roll 4#sdx', r'\(pool 4, exploding\) (\d hits?(, glitch)?|critical glitch!)') + self.assertNoResponse('Dice roll 0#sdx') + + def testRoll7S(self): + self.assertRegexp('Dice roll 3k2', r'\[3k2\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll 2k3', r'\[2k2\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll 3kk2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') + self.assertRegexp('Dice roll +3k2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') + self.assertRegexp('Dice roll -3k2', r'\[3k2, not exploding\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll +3kk2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') + self.assertRegexp('Dice roll -3kk2', r'\[3k2, not exploding\] \(\d+\) \d+, \d+ \| \d+') + self.assertRegexp('Dice roll 3k2+1', r'\[3k2\+1\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll 3k2-1', r'\[3k2-1\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll -3k2-1', r'\[3k2-1, not exploding\] \(\d+\) \d+, \d+') + self.assertRegexp('Dice roll 10k10', r'\[10k10\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12k10', r'\[10k10\+20\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12k9', r'\[10k10\+10\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12k8', r'\[10k10\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12k9+5', r'\[10k10\+15\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12kk9', r'\[10k10\+10\] \(\d+\) (\d+, ){9}\d+') + self.assertRegexp('Dice roll 12kk7', r'\[10k9\] \(\d+\) (\d+, ){8}\d+ \| \d+') + self.assertRegexp('Dice roll 3#3k2', r'\[3k2\] \(\d+\) \d+, \d+(; \(\d+\) \d+, \d+){2}') + + def testDeck(self): + validator = r'(2|3|4|5|6|7|8|9|10|J|Q|K|A)(♣|♦|♥|♠)|(Black|Red) Joker' + self.assertRegexp('Dice draw', validator) + self.assertResponse('Dice shuffle', 'shuffled') + for i in range(0, 54): + self.assertRegexp('Dice draw', validator) + + def testWoD(self): + self.assertRegexp('Dice roll 3w', r'\(3\) (\d success(es)?|FAIL)') + self.assertRegexp('Dice roll 3w-', r'\(3, not exploding\) (\d success(es)?|FAIL)') + self.assertRegexp('Dice roll 3w8', r'\(3, 8-again\) (\d success(es)?|FAIL)') + self.assertNoResponse('Dice roll 0w') + + def testDH(self): + self.assertRegexp('Dice roll vs(10)', r'-?\d+ \(\d+ vs 10\)') + self.assertRegexp('Dice roll vs(10+20)', r'-?\d+ \(\d+ vs 30\)') + self.assertRegexp('Dice roll vs(10+20-5)', r'-?\d+ \(\d+ vs 25\)') + self.assertRegexp('Dice roll 3vs(10+20)', r'-?\d+, -?\d+, -?\d+ \(\d+, \d+, \d+ vs 30\)') + + def testWG(self): + self.assertRegexp('Dice roll 10#wg', r'\[pool 10\] \d+ icon\(s\): [❶❷❸❹❺❻] ([1-5➅] )*(\| Glory|\| Complication)?') + + +# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/Dicebot/test_Raise.py b/Dice/test_Raise.py similarity index 100% rename from Dicebot/test_Raise.py rename to Dice/test_Raise.py diff --git a/Dicebot/test_RollResult.py b/Dice/test_RollResult.py similarity index 100% rename from Dicebot/test_RollResult.py rename to Dice/test_RollResult.py diff --git a/Dicebot/test_Roller.py b/Dice/test_Roller.py similarity index 100% rename from Dicebot/test_Roller.py rename to Dice/test_Roller.py diff --git a/Dicebot/test.py b/Dicebot/test.py deleted file mode 100644 index b9ba1dd..0000000 --- a/Dicebot/test.py +++ /dev/null @@ -1,115 +0,0 @@ -### -# Copyright (c) 2007-2010, Andrey Rahmatullin -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions, and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions, and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the author of this software nor the name of -# contributors to this software may be used to endorse or promote products -# derived from this software without specific prior written consent. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -### - -from supybot.test import PluginTestCase - -class DicebotTestCase(PluginTestCase): - plugins = ('Dicebot',) - def testPlugin(self): - self.assertHelp('dicebot roll') - self.assertNotError('dicebot roll 1d2') - self.assertNoResponse('dicebot roll dummy') - - def testRollStd(self): - self.assertRegexp('dicebot roll 1d20', r'\[1d20\] \d+') - self.assertRegexp('dicebot roll d20', r'\[1d20\] \d+') - self.assertRegexp('dicebot roll 1d20+5', r'\[1d20\+5\] \d+') - self.assertRegexp('dicebot roll d20+5', r'\[1d20\+5\] \d+') - self.assertRegexp('dicebot roll 1d20-30', r'\[1d20-30\] -\d+') - self.assertRegexp('dicebot roll d20-30', r'\[1d20-30\] -\d+') - self.assertRegexp('dicebot roll 2d20-1', r'\[2d20-1\] \d+') - self.assertRegexp('dicebot roll d20-1d6+3', r'\[1d20-1d6\+3\] -?\d+') - self.assertRegexp('dicebot roll 1d20+d20+3', r'\[2d20\+3\] \d+') - self.assertRegexp('dicebot roll 1d20+4+d6-3', r'\[1d20\+1d6\+1\] \d+') - self.assertNoResponse('dicebot roll 1d1') - - def testRollMult(self): - self.assertRegexp('dicebot roll 2#1d20', r'\[1d20\] \d+, \d+') - self.assertRegexp('dicebot roll 2#d20', r'\[1d20\] \d+, \d+') - self.assertRegexp('dicebot roll 2#1d20+5', r'\[1d20\+5\] \d+, \d+') - self.assertRegexp('dicebot roll 2#d20+5', r'\[1d20\+5\] \d+, \d+') - self.assertRegexp('dicebot roll 2#1d20-30', r'\[1d20-30\] -\d+, -\d+') - self.assertRegexp('dicebot roll 2#d20-30', r'\[1d20-30\] -\d+, -\d+') - self.assertRegexp('dicebot roll 2#2d20-1', r'\[2d20-1\] \d+, \d+') - self.assertNoResponse('dicebot roll 2#1d1') - - def testRollSR(self): - self.assertRegexp('dicebot roll 2#sd', r'\(pool 2\) (\d hits?|critical glitch!)') - self.assertRegexp('dicebot roll 4#sd', r'\(pool 4\) (\d hits?(, glitch)?|critical glitch!)') - self.assertNoResponse('dicebot roll 0#sd') - - def testRollSRX(self): - self.assertRegexp('dicebot roll 2#sdx', r'\(pool 2, exploding\) (\d hits?|critical glitch!)') - self.assertRegexp('dicebot roll 4#sdx', r'\(pool 4, exploding\) (\d hits?(, glitch)?|critical glitch!)') - self.assertNoResponse('dicebot roll 0#sdx') - - def testRoll7S(self): - self.assertRegexp('dicebot roll 3k2', r'\[3k2\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll 2k3', r'\[2k2\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll 3kk2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') - self.assertRegexp('dicebot roll +3k2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') - self.assertRegexp('dicebot roll -3k2', r'\[3k2, not exploding\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll +3kk2', r'\[3k2\] \(\d+\) \d+, \d+ \| \d+') - self.assertRegexp('dicebot roll -3kk2', r'\[3k2, not exploding\] \(\d+\) \d+, \d+ \| \d+') - self.assertRegexp('dicebot roll 3k2+1', r'\[3k2\+1\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll 3k2-1', r'\[3k2-1\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll -3k2-1', r'\[3k2-1, not exploding\] \(\d+\) \d+, \d+') - self.assertRegexp('dicebot roll 10k10', r'\[10k10\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12k10', r'\[10k10\+20\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12k9', r'\[10k10\+10\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12k8', r'\[10k10\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12k9+5', r'\[10k10\+15\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12kk9', r'\[10k10\+10\] \(\d+\) (\d+, ){9}\d+') - self.assertRegexp('dicebot roll 12kk7', r'\[10k9\] \(\d+\) (\d+, ){8}\d+ \| \d+') - self.assertRegexp('dicebot roll 3#3k2', r'\[3k2\] \(\d+\) \d+, \d+(; \(\d+\) \d+, \d+){2}') - - def testDeck(self): - validator = r'(2|3|4|5|6|7|8|9|10|J|Q|K|A)(♣|♦|♥|♠)|(Black|Red) Joker' - self.assertRegexp('dicebot draw', validator) - self.assertResponse('dicebot shuffle', 'shuffled') - for i in range(0, 54): - self.assertRegexp('dicebot draw', validator) - - def testWoD(self): - self.assertRegexp('dicebot roll 3w', r'\(3\) (\d success(es)?|FAIL)') - self.assertRegexp('dicebot roll 3w-', r'\(3, not exploding\) (\d success(es)?|FAIL)') - self.assertRegexp('dicebot roll 3w8', r'\(3, 8-again\) (\d success(es)?|FAIL)') - self.assertNoResponse('dicebot roll 0w') - - def testDH(self): - self.assertRegexp('dicebot roll vs(10)', r'-?\d+ \(\d+ vs 10\)') - self.assertRegexp('dicebot roll vs(10+20)', r'-?\d+ \(\d+ vs 30\)') - self.assertRegexp('dicebot roll vs(10+20-5)', r'-?\d+ \(\d+ vs 25\)') - self.assertRegexp('dicebot roll 3vs(10+20)', r'-?\d+, -?\d+, -?\d+ \(\d+, \d+, \d+ vs 30\)') - - def testWG(self): - self.assertRegexp('dicebot roll 10#wg', r'\[pool 10\] \d+ icon\(s\): [❶❷❸❹❺❻] ([1-5➅] )*(\| Glory|\| Complication)?') - - -# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: