From 3a172ca259fcedc9efde8b6beeb27f81d893480a Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 03:04:02 -0400 Subject: [PATCH 01/25] initial commit of HuntNFish plugin. needs method of storing highscores and other tweaks --- README.txt | 1 + __init__.py | 67 +++++++++++++++++++++++++++++ __init__.pyc | Bin 0 -> 728 bytes __init__.py~ | 66 +++++++++++++++++++++++++++++ config.py | 56 +++++++++++++++++++++++++ config.pyc | Bin 0 -> 1237 bytes local/__init__.py | 1 + plugin.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++ plugin.py.backup | 77 ++++++++++++++++++++++++++++++++++ plugin.pyc | Bin 0 -> 5653 bytes test.py | 37 +++++++++++++++++ 11 files changed, 409 insertions(+) create mode 100644 README.txt create mode 100644 __init__.py create mode 100644 __init__.pyc create mode 100644 __init__.py~ create mode 100644 config.py create mode 100644 config.pyc create mode 100644 local/__init__.py create mode 100644 plugin.py create mode 100644 plugin.py.backup create mode 100644 plugin.pyc create mode 100644 test.py diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3a5865c --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Insert a description of your plugin here, with any notes, etc. about using it. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..02ddc2b --- /dev/null +++ b/__init__.py @@ -0,0 +1,67 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.Author('resistivecorpse', 'resistivecorpse', + 'resistivecorpse@gmail.com') + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# 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! + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/__init__.pyc b/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0805c9a512293d79f22da3a6f1145616bedc5dec GIT binary patch literal 728 zcmZWnO>fjN5S{E-n{>C~ip0Usf>SP5HlE#hm9-;#(p5Q9@gMk~ zJ#d7HlNAW8B}nl`R?JNf^p6Gd&95)!Jq&N#t75|ng|Le1E0Wt3dIx@ z;|wr@{T$RRJac&F-~u#z&%zJqCszzbeBucd3E%}_0?!ddIEDQZ+_zJD1;q*s^y&R2 z6qkT8>{BSxew5GaML*$phU8W$Q3{2=a=ImLjj&rmHHxaV3!?~@uGWspWg_5ZP(-J#S?R@uY)Rc||EkW$%7%D{csK5Z<~isK{Cj@C7b<{TN=MesbL z^So{L^@noXQEeS1Ayo#!nZAXTl{Mt_rX%b8*hb3EHKUc&TfGZahO-OQVPi`bW+LQG znH}|4q~~Fjk4@=4#T**^ox?Q?_yhi$WnS9@=KmZ_uFcjSN~6mvA6okSQ)lS@PWw8S tQX5TDX6+N5bBPZJtGWiS-!k`a7#5Rdl+G5@WfU{^Y8fT7I7%mR^c&3?x+eet literal 0 HcmV?d00001 diff --git a/__init__.py~ b/__init__.py~ new file mode 100644 index 0000000..1627c24 --- /dev/null +++ b/__init__.py~ @@ -0,0 +1,66 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.Authors('resistivecorpse', 'resistivecorpse@gmail.com') + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# 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! + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py new file mode 100644 index 0000000..abfd640 --- /dev/null +++ b/config.py @@ -0,0 +1,56 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.conf as conf +import supybot.registry as registry +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # 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. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('HuntNFish', True) + + +HuntNFish = conf.registerPlugin('HuntNFish') +# This is where your configuration variables (if any) should go. For example: +conf.registerChannelValue(HuntNFish, 'WeightType', + registry.String('lb', _("""Determines what form of weight, metric or imperial, is used by the plugin. options are lb and kg."""))) +conf.registerChannelValue(HuntNFish, 'enable', + registry.Boolean(True, _("""Turns on and off the hunt and fish commands."""))) +conf.registerChannelValue(HuntNFish, 'successRate', + registry.NonNegativeInteger(0, _("""Percent of chance of success"""))) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.pyc b/config.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce8ea77e2e14188e1d6faa222faa4b86ba030a11 GIT binary patch literal 1237 zcmb_cQEL-H5T3nD(k4wC6)99i7eUBFN$^E{C?d9qzJzcs3VD&s-Q;f5yWMkluQfuR z>c12GGyVXb-D_%vK6+$lXKuflo%v=i;ji7^&nMGq0@u$L?QdwAA0$%xF(?3*3}$R& z2Cxia7J4&)q6K9eW^E`tFzW!rHl!h3k;4|GE%**F+XiH?>~7xoytxC|gR~78!m08;XyNc~$Ns^N6FOZAA~^h|~UsrC_x zX;EiFevlTmjIB^IF2pyl*aHXu_W(~+VyqT2vt2rUUrRfACrq9&vf8vlTF11^OA>Tx zO6&lX4AunYYlVrm+oZ;F zW%Er2MwQrDuA-HU+%|MDd!K}&PmRiSk?7jqNSc7l|8DI^+xna7qd zlrFhi@Jo+ACsyt&n*2s%Fk7dfwvr*Fx z8P5wehjigtt)<~g`g65d_z*eGg@3W2+2DyPsod0z><&4YI!Vx&D7Glb1oN206m^2+ zLzyPIW7lcd$l*N#*uH~achj*F`5wEY&D*ANdgYsRW8C%=FJ8%rJRox8YMuBTIY8uw z*^iEWNZMuujwuz1#mBg)(bs+2jK2GWc&k)_v5Z_R>;n=LB`28Cmve#cYsygn9ftoj h5w7H;Ql)i)ub+}`_DKxbfb9qUpxYe;eRjZ_^#=fzEJ*+W literal 0 HcmV?d00001 diff --git a/local/__init__.py b/local/__init__.py new file mode 100644 index 0000000..7e7c5d2 --- /dev/null +++ b/local/__init__.py @@ -0,0 +1 @@ +# Stub so local is a module, used for third-party modules diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..1c2a45a --- /dev/null +++ b/plugin.py @@ -0,0 +1,104 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisHunt) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + irc.reply(win) + else: + lose = ("oops, you missed, " + msg.nick) + irc.reply(lose) + + + def fish(self,irc,msg,args): + """ + performs a random fishing trip + """ + if(self.registryValue('enable', msg.args[0])): + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', 'Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' X', ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Pile of Weed', ' Boat Anchor', 'Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + + currentWhat = random.choice(fishes) + currentWhere = random.choice(fishSpots) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisFishing = (msg.nick + " goes fishing in " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisFishing) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + irc.reply(win) + else: + lose = ("oops, it got away, " + msg.nick) + irc.reply(lose) + + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugin.py.backup b/plugin.py.backup new file mode 100644 index 0000000..b3ab8a7 --- /dev/null +++ b/plugin.py.backup @@ -0,0 +1,77 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick, "goes hunting", currentWhere, "for a", weight, weightType, currentWhat) + irc.reply(thisHunt) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go,", msg.nick, ". You killed the", weight, weightType, currentWhat) + irc.reply(win) + else: + lose = ("oops, you missed,", msg.nick) + irc.reply(lose) + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugin.pyc b/plugin.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d9a2df129cc3cc2e2623cedd270b8a854337b862 GIT binary patch literal 5653 zcmeHLTXP$?6$Yuhtc$HAR_xpmJ9XI9wVRnfAKcNg>m zYn2)4$^Bz}>;LHwXuos7rR`MBbf%d;nbbnK?ZLTz=YVtnSYI7)x7(?he&+H2k9hpw z&}jTML?*;ZLv$NFY>KQY4yOxq;$&WQ=j(k7;$%^D7wh4YI9V3m<$Aaxx+`^mRdiSD z{w2}9RQK0Jca8gVB3l>vhUjjHd{cBcMZ;_eJuhB@k;}qtQr|3#lPjVRz81t^g?K5% zGg{sfW=nM6Al03Jg|N^Qyx*@#p7?GF=DE-Zc~^!R#Suc>@Eo1vEq_LR3NZvhLlUDO|_+}ug$L1h!q7M?vk{zou$ z2J5jI&zfXL9DVI&Qsr@kg>AQPT1@ep)A z5n2lHbG}?N`YCT%5yUQdyCJsEmc+KcDYnC+I9sOG?Xwj;i(>nHRh%`%$&xr*rTIpH zM?i+p;s6BV3BTeKF4ZU8;uF@y8D`eRNQm-TLw`O!a9g)7JZZf?X`P8bhyH$DzjD4& zFK+N+0eyb~=lc!WpoL~tPCsK)!j!p(F-sWMFX}IfLd}!t}&1g56652JziH+x{?$j^SYN^uHxx!zf z!N{o$t~`?|RXMccH)t&#s-iHN%)nEevW4_6H?mjxq4AzP8&hf)1ij26J}4UFw95?3 zP>m%|gwhy)WwvZJMawu-sqqvkt_rj-42^VSQ~3AeP8#P{>kQL)twdr z4|4+TDG5L@CLmPH0zA`EDloy!r7DxT$}&s1VE>LLkUCF|9Sp%Gyp zek8=mr+G2<4gn&-XA`uvJ5Q~sa(K|Z(RTo4tJ1q;&K~|QoyCb@I&)_nwLnLI2}1q`5uU%+xYzisx!KrkY~lI5 zv5qf#&9%nO#^vUEV}{?q$L>9P@790D?;8#MjFGteUt{gQ&L^So__D z2zW8pCX9H5^}t%3(0LPU5BY@Gv38-MzpsH)KfUmzpJFX!J*r>12y1@;*8Z9F^*b~( zF#UI|rJPDJh7>-YZA-}d5p5Y`J1PS#M&SC!l$7lmD&#YhW$v^OxHzl|6_K)Si;qocU9RlS%lrTDbryL_5)WUG|PezH$s)%EdeO(kKG_Ln^e7?DJdU>m@Muar7_eKh97K9 zhw=cVM=&Eh0S7{bk=0Js%M~naVxH_6pikUp)XM402NK$$#K;;i{ z{;?X&RKr3&wPod_K00nNn8>zDS@uqjob6){Zrhlgj*QWf&aT6$I|aZxCgrxWrF_zt z4>BxRyvMfNH)XD%Gxl{J)V_|=w+9d8U5A|frWHlU)#XFpzxbZbNdB$lBOB78DP#xHIo(DlmJan6&rudpa=${|Q&E<$X(`LJ zj*wxa4#BEBu7nFpOcR~P|yh{zG zD!yJ2z#7j#`B1krMx~Qb>PqOkm{7qK?;dmz-8~*eL{2`Sl@F=;h?kX?pSfbRC>8J>>G+r~{>R6BM>;;vovtz((uU(>?NaoqGCnMEF(ic|f1o4Il8Yz*SvjI6qO#wIgtcNNrdckbO{)M{_U47Y`*k5oRMn2}N zYW=?b@~a}DUjY)@%)de&^WOLaBumZ`?NQGEr4`HeyBAIT2Qr_h-##}RtGI^JcWwH; L+FXOuuYL6|pKMtZ literal 0 HcmV?d00001 diff --git a/test.py b/test.py new file mode 100644 index 0000000..f2b1a9e --- /dev/null +++ b/test.py @@ -0,0 +1,37 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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 * + +class HuntNFishTestCase(PluginTestCase): + plugins = ('HuntNFish',) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From 24397af063f62f94f401f7dfe713cd9959705626 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 03:07:58 -0400 Subject: [PATCH 02/25] removed files --- README.txt | 1 - __init__.py | 67 ----------------------------- __init__.pyc | Bin 728 -> 0 bytes __init__.py~ | 66 ----------------------------- config.py | 56 ------------------------- config.pyc | Bin 1237 -> 0 bytes local/__init__.py | 1 - plugin.py | 104 ---------------------------------------------- plugin.py.backup | 77 ---------------------------------- plugin.pyc | Bin 5653 -> 0 bytes test.py | 37 ----------------- 11 files changed, 409 deletions(-) delete mode 100644 README.txt delete mode 100644 __init__.py delete mode 100644 __init__.pyc delete mode 100644 __init__.py~ delete mode 100644 config.py delete mode 100644 config.pyc delete mode 100644 local/__init__.py delete mode 100644 plugin.py delete mode 100644 plugin.py.backup delete mode 100644 plugin.pyc delete mode 100644 test.py diff --git a/README.txt b/README.txt deleted file mode 100644 index 3a5865c..0000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -Insert a description of your plugin here, with any notes, etc. about using it. diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 02ddc2b..0000000 --- a/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -""" -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. -""" - -import supybot -import supybot.world as world - -# Use this for the version of this plugin. You may wish to put a CVS keyword -# in here if you're keeping the plugin in CVS or some similar system. -__version__ = "" - -# XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.Author('resistivecorpse', 'resistivecorpse', - 'resistivecorpse@gmail.com') - -# This is a dictionary mapping supybot.Author instances to lists of -# contributions. -__contributors__ = {} - -# This is a url where the most recent plugin package can be downloaded. -__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' - -import config -import plugin -reload(plugin) # In case we're being reloaded. -# 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! - -if world.testing: - import test - -Class = plugin.Class -configure = config.configure - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/__init__.pyc b/__init__.pyc deleted file mode 100644 index 0805c9a512293d79f22da3a6f1145616bedc5dec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 728 zcmZWnO>fjN5S{E-n{>C~ip0Usf>SP5HlE#hm9-;#(p5Q9@gMk~ zJ#d7HlNAW8B}nl`R?JNf^p6Gd&95)!Jq&N#t75|ng|Le1E0Wt3dIx@ z;|wr@{T$RRJac&F-~u#z&%zJqCszzbeBucd3E%}_0?!ddIEDQZ+_zJD1;q*s^y&R2 z6qkT8>{BSxew5GaML*$phU8W$Q3{2=a=ImLjj&rmHHxaV3!?~@uGWspWg_5ZP(-J#S?R@uY)Rc||EkW$%7%D{csK5Z<~isK{Cj@C7b<{TN=MesbL z^So{L^@noXQEeS1Ayo#!nZAXTl{Mt_rX%b8*hb3EHKUc&TfGZahO-OQVPi`bW+LQG znH}|4q~~Fjk4@=4#T**^ox?Q?_yhi$WnS9@=KmZ_uFcjSN~6mvA6okSQ)lS@PWw8S tQX5TDX6+N5bBPZJtGWiS-!k`a7#5Rdl+G5@WfU{^Y8fT7I7%mR^c&3?x+eet diff --git a/__init__.py~ b/__init__.py~ deleted file mode 100644 index 1627c24..0000000 --- a/__init__.py~ +++ /dev/null @@ -1,66 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -""" -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. -""" - -import supybot -import supybot.world as world - -# Use this for the version of this plugin. You may wish to put a CVS keyword -# in here if you're keeping the plugin in CVS or some similar system. -__version__ = "" - -# XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.Authors('resistivecorpse', 'resistivecorpse@gmail.com') - -# This is a dictionary mapping supybot.Author instances to lists of -# contributions. -__contributors__ = {} - -# This is a url where the most recent plugin package can be downloaded. -__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' - -import config -import plugin -reload(plugin) # In case we're being reloaded. -# 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! - -if world.testing: - import test - -Class = plugin.Class -configure = config.configure - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py deleted file mode 100644 index abfd640..0000000 --- a/config.py +++ /dev/null @@ -1,56 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.conf as conf -import supybot.registry as registry -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -def configure(advanced): - # This will be called by supybot to configure this module. advanced is - # 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. - from supybot.questions import expect, anything, something, yn - conf.registerPlugin('HuntNFish', True) - - -HuntNFish = conf.registerPlugin('HuntNFish') -# This is where your configuration variables (if any) should go. For example: -conf.registerChannelValue(HuntNFish, 'WeightType', - registry.String('lb', _("""Determines what form of weight, metric or imperial, is used by the plugin. options are lb and kg."""))) -conf.registerChannelValue(HuntNFish, 'enable', - registry.Boolean(True, _("""Turns on and off the hunt and fish commands."""))) -conf.registerChannelValue(HuntNFish, 'successRate', - registry.NonNegativeInteger(0, _("""Percent of chance of success"""))) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.pyc b/config.pyc deleted file mode 100644 index ce8ea77e2e14188e1d6faa222faa4b86ba030a11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1237 zcmb_cQEL-H5T3nD(k4wC6)99i7eUBFN$^E{C?d9qzJzcs3VD&s-Q;f5yWMkluQfuR z>c12GGyVXb-D_%vK6+$lXKuflo%v=i;ji7^&nMGq0@u$L?QdwAA0$%xF(?3*3}$R& z2Cxia7J4&)q6K9eW^E`tFzW!rHl!h3k;4|GE%**F+XiH?>~7xoytxC|gR~78!m08;XyNc~$Ns^N6FOZAA~^h|~UsrC_x zX;EiFevlTmjIB^IF2pyl*aHXu_W(~+VyqT2vt2rUUrRfACrq9&vf8vlTF11^OA>Tx zO6&lX4AunYYlVrm+oZ;F zW%Er2MwQrDuA-HU+%|MDd!K}&PmRiSk?7jqNSc7l|8DI^+xna7qd zlrFhi@Jo+ACsyt&n*2s%Fk7dfwvr*Fx z8P5wehjigtt)<~g`g65d_z*eGg@3W2+2DyPsod0z><&4YI!Vx&D7Glb1oN206m^2+ zLzyPIW7lcd$l*N#*uH~achj*F`5wEY&D*ANdgYsRW8C%=FJ8%rJRox8YMuBTIY8uw z*^iEWNZMuujwuz1#mBg)(bs+2jK2GWc&k)_v5Z_R>;n=LB`28Cmve#cYsygn9ftoj h5w7H;Ql)i)ub+}`_DKxbfb9qUpxYe;eRjZ_^#=fzEJ*+W diff --git a/local/__init__.py b/local/__init__.py deleted file mode 100644 index 7e7c5d2..0000000 --- a/local/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Stub so local is a module, used for third-party modules diff --git a/plugin.py b/plugin.py deleted file mode 100644 index 1c2a45a..0000000 --- a/plugin.py +++ /dev/null @@ -1,104 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(1,200) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) - irc.reply(thisHunt) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) - irc.reply(win) - else: - lose = ("oops, you missed, " + msg.nick) - irc.reply(lose) - - - def fish(self,irc,msg,args): - """ - performs a random fishing trip - """ - if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', 'Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' X', ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Pile of Weed', ' Boat Anchor', 'Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') - fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - - currentWhat = random.choice(fishes) - currentWhere = random.choice(fishSpots) - weight = random.randint(1,200) - weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere + " for a " + str(weight) + weightType + currentWhat) - irc.reply(thisFishing) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) - irc.reply(win) - else: - lose = ("oops, it got away, " + msg.nick) - irc.reply(lose) - - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugin.py.backup b/plugin.py.backup deleted file mode 100644 index b3ab8a7..0000000 --- a/plugin.py.backup +++ /dev/null @@ -1,77 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(1,200) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick, "goes hunting", currentWhere, "for a", weight, weightType, currentWhat) - irc.reply(thisHunt) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go,", msg.nick, ". You killed the", weight, weightType, currentWhat) - irc.reply(win) - else: - lose = ("oops, you missed,", msg.nick) - irc.reply(lose) - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugin.pyc b/plugin.pyc deleted file mode 100644 index d9a2df129cc3cc2e2623cedd270b8a854337b862..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5653 zcmeHLTXP$?6$Yuhtc$HAR_xpmJ9XI9wVRnfAKcNg>m zYn2)4$^Bz}>;LHwXuos7rR`MBbf%d;nbbnK?ZLTz=YVtnSYI7)x7(?he&+H2k9hpw z&}jTML?*;ZLv$NFY>KQY4yOxq;$&WQ=j(k7;$%^D7wh4YI9V3m<$Aaxx+`^mRdiSD z{w2}9RQK0Jca8gVB3l>vhUjjHd{cBcMZ;_eJuhB@k;}qtQr|3#lPjVRz81t^g?K5% zGg{sfW=nM6Al03Jg|N^Qyx*@#p7?GF=DE-Zc~^!R#Suc>@Eo1vEq_LR3NZvhLlUDO|_+}ug$L1h!q7M?vk{zou$ z2J5jI&zfXL9DVI&Qsr@kg>AQPT1@ep)A z5n2lHbG}?N`YCT%5yUQdyCJsEmc+KcDYnC+I9sOG?Xwj;i(>nHRh%`%$&xr*rTIpH zM?i+p;s6BV3BTeKF4ZU8;uF@y8D`eRNQm-TLw`O!a9g)7JZZf?X`P8bhyH$DzjD4& zFK+N+0eyb~=lc!WpoL~tPCsK)!j!p(F-sWMFX}IfLd}!t}&1g56652JziH+x{?$j^SYN^uHxx!zf z!N{o$t~`?|RXMccH)t&#s-iHN%)nEevW4_6H?mjxq4AzP8&hf)1ij26J}4UFw95?3 zP>m%|gwhy)WwvZJMawu-sqqvkt_rj-42^VSQ~3AeP8#P{>kQL)twdr z4|4+TDG5L@CLmPH0zA`EDloy!r7DxT$}&s1VE>LLkUCF|9Sp%Gyp zek8=mr+G2<4gn&-XA`uvJ5Q~sa(K|Z(RTo4tJ1q;&K~|QoyCb@I&)_nwLnLI2}1q`5uU%+xYzisx!KrkY~lI5 zv5qf#&9%nO#^vUEV}{?q$L>9P@790D?;8#MjFGteUt{gQ&L^So__D z2zW8pCX9H5^}t%3(0LPU5BY@Gv38-MzpsH)KfUmzpJFX!J*r>12y1@;*8Z9F^*b~( zF#UI|rJPDJh7>-YZA-}d5p5Y`J1PS#M&SC!l$7lmD&#YhW$v^OxHzl|6_K)Si;qocU9RlS%lrTDbryL_5)WUG|PezH$s)%EdeO(kKG_Ln^e7?DJdU>m@Muar7_eKh97K9 zhw=cVM=&Eh0S7{bk=0Js%M~naVxH_6pikUp)XM402NK$$#K;;i{ z{;?X&RKr3&wPod_K00nNn8>zDS@uqjob6){Zrhlgj*QWf&aT6$I|aZxCgrxWrF_zt z4>BxRyvMfNH)XD%Gxl{J)V_|=w+9d8U5A|frWHlU)#XFpzxbZbNdB$lBOB78DP#xHIo(DlmJan6&rudpa=${|Q&E<$X(`LJ zj*wxa4#BEBu7nFpOcR~P|yh{zG zD!yJ2z#7j#`B1krMx~Qb>PqOkm{7qK?;dmz-8~*eL{2`Sl@F=;h?kX?pSfbRC>8J>>G+r~{>R6BM>;;vovtz((uU(>?NaoqGCnMEF(ic|f1o4Il8Yz*SvjI6qO#wIgtcNNrdckbO{)M{_U47Y`*k5oRMn2}N zYW=?b@~a}DUjY)@%)de&^WOLaBumZ`?NQGEr4`HeyBAIT2Qr_h-##}RtGI^JcWwH; L+FXOuuYL6|pKMtZ diff --git a/test.py b/test.py deleted file mode 100644 index f2b1a9e..0000000 --- a/test.py +++ /dev/null @@ -1,37 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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 * - -class HuntNFishTestCase(PluginTestCase): - plugins = ('HuntNFish',) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From 74ff479e761dd0151a123f0d5f0243451a868347 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 03:09:56 -0400 Subject: [PATCH 03/25] initial commit of HuntNFish plugin. needs method of storing highscores and other tweaks --- README.txt | 1 + __init__.py | 67 +++++++++++++++++++++++++++++ __init__.py~ | 66 +++++++++++++++++++++++++++++ config.py | 56 +++++++++++++++++++++++++ local/__init__.py | 1 + plugin.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++ plugin.py.backup | 77 ++++++++++++++++++++++++++++++++++ test.py | 37 +++++++++++++++++ 8 files changed, 409 insertions(+) create mode 100644 README.txt create mode 100644 __init__.py create mode 100644 __init__.py~ create mode 100644 config.py create mode 100644 local/__init__.py create mode 100644 plugin.py create mode 100644 plugin.py.backup create mode 100644 test.py diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3a5865c --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Insert a description of your plugin here, with any notes, etc. about using it. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..02ddc2b --- /dev/null +++ b/__init__.py @@ -0,0 +1,67 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.Author('resistivecorpse', 'resistivecorpse', + 'resistivecorpse@gmail.com') + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# 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! + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/__init__.py~ b/__init__.py~ new file mode 100644 index 0000000..1627c24 --- /dev/null +++ b/__init__.py~ @@ -0,0 +1,66 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.Authors('resistivecorpse', 'resistivecorpse@gmail.com') + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# 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! + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py new file mode 100644 index 0000000..abfd640 --- /dev/null +++ b/config.py @@ -0,0 +1,56 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.conf as conf +import supybot.registry as registry +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # 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. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('HuntNFish', True) + + +HuntNFish = conf.registerPlugin('HuntNFish') +# This is where your configuration variables (if any) should go. For example: +conf.registerChannelValue(HuntNFish, 'WeightType', + registry.String('lb', _("""Determines what form of weight, metric or imperial, is used by the plugin. options are lb and kg."""))) +conf.registerChannelValue(HuntNFish, 'enable', + registry.Boolean(True, _("""Turns on and off the hunt and fish commands."""))) +conf.registerChannelValue(HuntNFish, 'successRate', + registry.NonNegativeInteger(0, _("""Percent of chance of success"""))) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/local/__init__.py b/local/__init__.py new file mode 100644 index 0000000..7e7c5d2 --- /dev/null +++ b/local/__init__.py @@ -0,0 +1 @@ +# Stub so local is a module, used for third-party modules diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..1c2a45a --- /dev/null +++ b/plugin.py @@ -0,0 +1,104 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisHunt) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + irc.reply(win) + else: + lose = ("oops, you missed, " + msg.nick) + irc.reply(lose) + + + def fish(self,irc,msg,args): + """ + performs a random fishing trip + """ + if(self.registryValue('enable', msg.args[0])): + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', 'Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' X', ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Pile of Weed', ' Boat Anchor', 'Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + + currentWhat = random.choice(fishes) + currentWhere = random.choice(fishSpots) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisFishing = (msg.nick + " goes fishing in " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisFishing) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + irc.reply(win) + else: + lose = ("oops, it got away, " + msg.nick) + irc.reply(lose) + + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugin.py.backup b/plugin.py.backup new file mode 100644 index 0000000..b3ab8a7 --- /dev/null +++ b/plugin.py.backup @@ -0,0 +1,77 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(1,200) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick, "goes hunting", currentWhere, "for a", weight, weightType, currentWhat) + irc.reply(thisHunt) + time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go,", msg.nick, ". You killed the", weight, weightType, currentWhat) + irc.reply(win) + else: + lose = ("oops, you missed,", msg.nick) + irc.reply(lose) + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/test.py b/test.py new file mode 100644 index 0000000..f2b1a9e --- /dev/null +++ b/test.py @@ -0,0 +1,37 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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 * + +class HuntNFishTestCase(PluginTestCase): + plugins = ('HuntNFish',) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From 678bd1dd2dcf3ca22b8c7d41597be043cc4b2f30 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 03:10:56 -0400 Subject: [PATCH 04/25] removed files --- __init__.py~ | 66 ---------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 __init__.py~ diff --git a/__init__.py~ b/__init__.py~ deleted file mode 100644 index 1627c24..0000000 --- a/__init__.py~ +++ /dev/null @@ -1,66 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -""" -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. -""" - -import supybot -import supybot.world as world - -# Use this for the version of this plugin. You may wish to put a CVS keyword -# in here if you're keeping the plugin in CVS or some similar system. -__version__ = "" - -# XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.Authors('resistivecorpse', 'resistivecorpse@gmail.com') - -# This is a dictionary mapping supybot.Author instances to lists of -# contributions. -__contributors__ = {} - -# This is a url where the most recent plugin package can be downloaded. -__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' - -import config -import plugin -reload(plugin) # In case we're being reloaded. -# 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! - -if world.testing: - import test - -Class = plugin.Class -configure = config.configure - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From eb8c2b148f71fd860a96af5bd19ddeaad37d19fa Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 03:11:39 -0400 Subject: [PATCH 05/25] removed files --- plugin.py.backup | 77 ------------------------------------------------ 1 file changed, 77 deletions(-) delete mode 100644 plugin.py.backup diff --git a/plugin.py.backup b/plugin.py.backup deleted file mode 100644 index b3ab8a7..0000000 --- a/plugin.py.backup +++ /dev/null @@ -1,77 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(1,200) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick, "goes hunting", currentWhere, "for a", weight, weightType, currentWhat) - irc.reply(thisHunt) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go,", msg.nick, ". You killed the", weight, weightType, currentWhat) - irc.reply(win) - else: - lose = ("oops, you missed,", msg.nick) - irc.reply(lose) - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From 18de86c54633957b8638205006b6985e71354797 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 12 Sep 2012 17:36:32 -0400 Subject: [PATCH 06/25] added better output to hunt and fish commands --- plugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 1c2a45a..cdff745 100644 --- a/plugin.py +++ b/plugin.py @@ -60,7 +60,9 @@ class HuntNFish(callbacks.Plugin): weightType = self.registryValue('weightType') thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) irc.reply(thisHunt) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + irc.reply("aims....") + irc.reply("fires.....") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') @@ -77,16 +79,18 @@ class HuntNFish(callbacks.Plugin): performs a random fishing trip """ if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', 'Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' X', ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Pile of Weed', ' Boat Anchor', 'Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') currentWhat = random.choice(fishes) currentWhere = random.choice(fishSpots) weight = random.randint(1,200) weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + thisFishing = (msg.nick + " goes fishing in " + currentWhere) irc.reply(thisFishing) - time.sleep(5)#pauses the output between line 1 and 2 for 5 seconds + irc.reply("casts in....") + irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') From 5f1c4ced1f8d99dc6d097606b8a23b10c69270f7 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Fri, 14 Sep 2012 00:42:26 -0400 Subject: [PATCH 07/25] adds highscore tracking, command to check highscore and README content --- README.txt | 10 +++++++++- fishtrophy.txt | 3 +++ hunttrophy.txt | 3 +++ plugin.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 fishtrophy.txt create mode 100644 hunttrophy.txt diff --git a/README.txt b/README.txt index 3a5865c..3d825cb 100644 --- a/README.txt +++ b/README.txt @@ -1 +1,9 @@ -Insert a description of your plugin here, with any notes, etc. about using it. +this is a basic hunting and fishing game for supybot + +move the files fishtrophy.txt and hunttrophy.txt to your bot's data folder to prevent any errors. in future versions i intend to cut this step out by having the plugin generate the files if they dont exsist already + +chance of success is a % variable, 1 to 10. it is set with config plugins>HuntNFish.successRate + +the game can be turned off using config plugins.HuntNFish.enable + +type of weight used is also configurable, with config plugins.HuntNFish.weightType diff --git a/fishtrophy.txt b/fishtrophy.txt new file mode 100644 index 0000000..7c10f96 --- /dev/null +++ b/fishtrophy.txt @@ -0,0 +1,3 @@ +resistivecorpse + Tin Can +1 diff --git a/hunttrophy.txt b/hunttrophy.txt new file mode 100644 index 0000000..83bea9a --- /dev/null +++ b/hunttrophy.txt @@ -0,0 +1,3 @@ +resistivecorpse + Deer +1 diff --git a/plugin.py b/plugin.py index cdff745..e8dc647 100644 --- a/plugin.py +++ b/plugin.py @@ -33,6 +33,7 @@ from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks +import supybot.conf as conf import random as random import re import time @@ -69,6 +70,22 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) irc.reply(win) + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + bigHunt = data[2].rstrip('\n') + if weight > int(bigHunt): + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + else: lose = ("oops, you missed, " + msg.nick) irc.reply(lose) @@ -97,10 +114,46 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) irc.reply(win) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + bigFish = data[2].rstrip('\n') + if weight > int(bigFish): + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + else: lose = ("oops, it got away, " + msg.nick) irc.reply(lose) + def trophy(self,irc,msg,args): + """ + checks the current highscores for hunting and fishing + """ + if(self.registryValue('enable', msg.args[0])): + weightType = self.registryValue('weightType') + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: + data1 = file1.readlines() + hunter = data1[0].rstrip('\n') + hunted = data1[1].rstrip('\n') + score = data1[2].rstrip('\n') + irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: + data2 = file2.readlines() + fisherman = data2[0].rstrip('\n') + catch = data2[1].rstrip('\n') + size = data2[2].rstrip('\n') + irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + + Class = HuntNFish From 7339755facfc9076f0f3080a3932838f1bfba575 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Fri, 14 Sep 2012 06:17:52 -0400 Subject: [PATCH 08/25] fixed up calculation of current hunt/fish weight to be more dynamic --- plugin.py | 12 +++- plugin.py~ | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 plugin.py~ diff --git a/plugin.py b/plugin.py index e8dc647..4e8ad38 100644 --- a/plugin.py +++ b/plugin.py @@ -52,12 +52,15 @@ class HuntNFish(callbacks.Plugin): performs a random hunt """ if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer'] + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') currentWhat = random.choice(animals) currentWhere = random.choice(places) - weight = random.randint(1,200) + weight = random.randint(int(highScore)/2,int(highScore)+10) weightType = self.registryValue('weightType') thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) irc.reply(thisHunt) @@ -99,9 +102,12 @@ class HuntNFish(callbacks.Plugin): fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') currentWhat = random.choice(fishes) currentWhere = random.choice(fishSpots) - weight = random.randint(1,200) + weight = random.randint(int(highScore)/2,int(highScore)+10) weightType = self.registryValue('weightType') thisFishing = (msg.nick + " goes fishing in " + currentWhere) irc.reply(thisFishing) diff --git a/plugin.py~ b/plugin.py~ new file mode 100644 index 0000000..2cd37bc --- /dev/null +++ b/plugin.py~ @@ -0,0 +1,167 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import supybot.conf as conf +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisHunt) + irc.reply("aims....") + irc.reply("fires.....") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + bigHunt = data[2].rstrip('\n') + if weight > int(bigHunt): + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, you missed, " + msg.nick) + irc.reply(lose) + + + def fish(self,irc,msg,args): + """ + performs a random fishing trip + """ + if(self.registryValue('enable', msg.args[0])): + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + currentWhat = random.choice(fishes) + currentWhere = random.choice(fishSpots) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisFishing = (msg.nick + " goes fishing in " + currentWhere) + irc.reply(thisFishing) + irc.reply("casts in....") + irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + bigFish = data[2].rstrip('\n') + if weight > int(bigFish): + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, it got away, " + msg.nick) + irc.reply(lose) + + def trophy(self,irc,msg,args): + """ + checks the current highscores for hunting and fishing + """ + if(self.registryValue('enable', msg.args[0])): + weightType = self.registryValue('weightType') + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: + data1 = file1.readlines() + hunter = data1[0].rstrip('\n') + hunted = data1[1].rstrip('\n') + score = data1[2].rstrip('\n') + irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: + data2 = file2.readlines() + fisherman = data2[0].rstrip('\n') + catch = data2[1].rstrip('\n') + size = data2[2].rstrip('\n') + irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + + + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From 5ed80e15bec86ec42127e30ca82ce1781039095d Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Fri, 14 Sep 2012 06:20:40 -0400 Subject: [PATCH 09/25] removed a file --- plugin.py~ | 167 ----------------------------------------------------- 1 file changed, 167 deletions(-) delete mode 100644 plugin.py~ diff --git a/plugin.py~ b/plugin.py~ deleted file mode 100644 index 2cd37bc..0000000 --- a/plugin.py~ +++ /dev/null @@ -1,167 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import supybot.conf as conf -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) - irc.reply(thisHunt) - irc.reply("aims....") - irc.reply("fires.....") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - bigHunt = data[2].rstrip('\n') - if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, you missed, " + msg.nick) - irc.reply(lose) - - - def fish(self,irc,msg,args): - """ - performs a random fishing trip - """ - if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') - fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - currentWhat = random.choice(fishes) - currentWhere = random.choice(fishSpots) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere) - irc.reply(thisFishing) - irc.reply("casts in....") - irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: - data = file.readlines() - bigFish = data[2].rstrip('\n') - if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, it got away, " + msg.nick) - irc.reply(lose) - - def trophy(self,irc,msg,args): - """ - checks the current highscores for hunting and fishing - """ - if(self.registryValue('enable', msg.args[0])): - weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: - data1 = file1.readlines() - hunter = data1[0].rstrip('\n') - hunted = data1[1].rstrip('\n') - score = data1[2].rstrip('\n') - irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: - data2 = file2.readlines() - fisherman = data2[0].rstrip('\n') - catch = data2[1].rstrip('\n') - size = data2[2].rstrip('\n') - irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) - - - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From 291214588b544d2ef64025a94b45f74365a194c3 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Sun, 23 Sep 2012 00:24:08 -0400 Subject: [PATCH 10/25] fixes minor bug in randomization of current hunt or fish weight --- plugin.py | 2 + plugin.py~ | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 plugin.py~ diff --git a/plugin.py b/plugin.py index 4e8ad38..378941f 100644 --- a/plugin.py +++ b/plugin.py @@ -58,6 +58,7 @@ class HuntNFish(callbacks.Plugin): with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') + random.seed(time.time()) currentWhat = random.choice(animals) currentWhere = random.choice(places) weight = random.randint(int(highScore)/2,int(highScore)+10) @@ -105,6 +106,7 @@ class HuntNFish(callbacks.Plugin): with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') + random.seed(time.time()) currentWhat = random.choice(fishes) currentWhere = random.choice(fishSpots) weight = random.randint(int(highScore)/2,int(highScore)+10) diff --git a/plugin.py~ b/plugin.py~ new file mode 100644 index 0000000..4e8ad38 --- /dev/null +++ b/plugin.py~ @@ -0,0 +1,167 @@ +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import supybot.conf as conf +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisHunt) + irc.reply("aims....") + irc.reply("fires.....") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + bigHunt = data[2].rstrip('\n') + if weight > int(bigHunt): + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, you missed, " + msg.nick) + irc.reply(lose) + + + def fish(self,irc,msg,args): + """ + performs a random fishing trip + """ + if(self.registryValue('enable', msg.args[0])): + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + currentWhat = random.choice(fishes) + currentWhere = random.choice(fishSpots) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisFishing = (msg.nick + " goes fishing in " + currentWhere) + irc.reply(thisFishing) + irc.reply("casts in....") + irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + bigFish = data[2].rstrip('\n') + if weight > int(bigFish): + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, it got away, " + msg.nick) + irc.reply(lose) + + def trophy(self,irc,msg,args): + """ + checks the current highscores for hunting and fishing + """ + if(self.registryValue('enable', msg.args[0])): + weightType = self.registryValue('weightType') + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: + data1 = file1.readlines() + hunter = data1[0].rstrip('\n') + hunted = data1[1].rstrip('\n') + score = data1[2].rstrip('\n') + irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: + data2 = file2.readlines() + fisherman = data2[0].rstrip('\n') + catch = data2[1].rstrip('\n') + size = data2[2].rstrip('\n') + irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + + + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From 5f9b1ee6b0f872c1f50b29ce985141ac0aacee87 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Sun, 23 Sep 2012 00:24:45 -0400 Subject: [PATCH 11/25] removed file --- plugin.py~ | 167 ----------------------------------------------------- 1 file changed, 167 deletions(-) delete mode 100644 plugin.py~ diff --git a/plugin.py~ b/plugin.py~ deleted file mode 100644 index 4e8ad38..0000000 --- a/plugin.py~ +++ /dev/null @@ -1,167 +0,0 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import supybot.conf as conf -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) - irc.reply(thisHunt) - irc.reply("aims....") - irc.reply("fires.....") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - bigHunt = data[2].rstrip('\n') - if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, you missed, " + msg.nick) - irc.reply(lose) - - - def fish(self,irc,msg,args): - """ - performs a random fishing trip - """ - if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') - fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - currentWhat = random.choice(fishes) - currentWhere = random.choice(fishSpots) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere) - irc.reply(thisFishing) - irc.reply("casts in....") - irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: - data = file.readlines() - bigFish = data[2].rstrip('\n') - if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, it got away, " + msg.nick) - irc.reply(lose) - - def trophy(self,irc,msg,args): - """ - checks the current highscores for hunting and fishing - """ - if(self.registryValue('enable', msg.args[0])): - weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: - data1 = file1.readlines() - hunter = data1[0].rstrip('\n') - hunted = data1[1].rstrip('\n') - score = data1[2].rstrip('\n') - irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: - data2 = file2.readlines() - fisherman = data2[0].rstrip('\n') - catch = data2[1].rstrip('\n') - size = data2[2].rstrip('\n') - irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) - - - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From de597fe29f1679ca802080bf79d73bd877b05e50 Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Sun, 23 Sep 2012 09:47:19 +0300 Subject: [PATCH 12/25] Convert all line endings to UNIX format using Flip --- README.txt | 18 +-- __init__.py | 134 +++++++++--------- config.py | 112 +++++++-------- local/__init__.py | 2 +- plugin.py | 338 +++++++++++++++++++++++----------------------- test.py | 74 +++++----- 6 files changed, 339 insertions(+), 339 deletions(-) diff --git a/README.txt b/README.txt index 3d825cb..94e254f 100644 --- a/README.txt +++ b/README.txt @@ -1,9 +1,9 @@ -this is a basic hunting and fishing game for supybot - -move the files fishtrophy.txt and hunttrophy.txt to your bot's data folder to prevent any errors. in future versions i intend to cut this step out by having the plugin generate the files if they dont exsist already - -chance of success is a % variable, 1 to 10. it is set with config plugins>HuntNFish.successRate - -the game can be turned off using config plugins.HuntNFish.enable - -type of weight used is also configurable, with config plugins.HuntNFish.weightType +this is a basic hunting and fishing game for supybot + +move the files fishtrophy.txt and hunttrophy.txt to your bot's data folder to prevent any errors. in future versions i intend to cut this step out by having the plugin generate the files if they dont exsist already + +chance of success is a % variable, 1 to 10. it is set with config plugins>HuntNFish.successRate + +the game can be turned off using config plugins.HuntNFish.enable + +type of weight used is also configurable, with config plugins.HuntNFish.weightType diff --git a/__init__.py b/__init__.py index 02ddc2b..ec0fa11 100644 --- a/__init__.py +++ b/__init__.py @@ -1,67 +1,67 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -""" -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. -""" - -import supybot -import supybot.world as world - -# Use this for the version of this plugin. You may wish to put a CVS keyword -# in here if you're keeping the plugin in CVS or some similar system. -__version__ = "" - -# XXX Replace this with an appropriate author or supybot.Author instance. -__author__ = supybot.Author('resistivecorpse', 'resistivecorpse', - 'resistivecorpse@gmail.com') - -# This is a dictionary mapping supybot.Author instances to lists of -# contributions. -__contributors__ = {} - -# This is a url where the most recent plugin package can be downloaded. -__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' - -import config -import plugin -reload(plugin) # In case we're being reloaded. -# 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! - -if world.testing: - import test - -Class = plugin.Class -configure = config.configure - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.Author('resistivecorpse', 'resistivecorpse', + 'resistivecorpse@gmail.com') + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' + +import config +import plugin +reload(plugin) # In case we're being reloaded. +# 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! + +if world.testing: + import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py index abfd640..1027380 100644 --- a/config.py +++ b/config.py @@ -1,56 +1,56 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.conf as conf -import supybot.registry as registry -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -def configure(advanced): - # This will be called by supybot to configure this module. advanced is - # 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. - from supybot.questions import expect, anything, something, yn - conf.registerPlugin('HuntNFish', True) - - -HuntNFish = conf.registerPlugin('HuntNFish') -# This is where your configuration variables (if any) should go. For example: -conf.registerChannelValue(HuntNFish, 'WeightType', - registry.String('lb', _("""Determines what form of weight, metric or imperial, is used by the plugin. options are lb and kg."""))) -conf.registerChannelValue(HuntNFish, 'enable', - registry.Boolean(True, _("""Turns on and off the hunt and fish commands."""))) -conf.registerChannelValue(HuntNFish, 'successRate', - registry.NonNegativeInteger(0, _("""Percent of chance of success"""))) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.conf as conf +import supybot.registry as registry +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # 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. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('HuntNFish', True) + + +HuntNFish = conf.registerPlugin('HuntNFish') +# This is where your configuration variables (if any) should go. For example: +conf.registerChannelValue(HuntNFish, 'WeightType', + registry.String('lb', _("""Determines what form of weight, metric or imperial, is used by the plugin. options are lb and kg."""))) +conf.registerChannelValue(HuntNFish, 'enable', + registry.Boolean(True, _("""Turns on and off the hunt and fish commands."""))) +conf.registerChannelValue(HuntNFish, 'successRate', + registry.NonNegativeInteger(0, _("""Percent of chance of success"""))) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/local/__init__.py b/local/__init__.py index 7e7c5d2..e86e97b 100644 --- a/local/__init__.py +++ b/local/__init__.py @@ -1 +1 @@ -# Stub so local is a module, used for third-party modules +# Stub so local is a module, used for third-party modules diff --git a/plugin.py b/plugin.py index 378941f..9cb4332 100644 --- a/plugin.py +++ b/plugin.py @@ -1,169 +1,169 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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. - -### - -import supybot.utils as utils -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -import supybot.conf as conf -import random as random -import re -import time -import string -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('HuntNFish') - -@internationalizeDocstring -class HuntNFish(callbacks.Plugin): - """Adds hunt and fish commands for a basic hunting and fishing game.""" - threaded = True - - def hunt(self,irc,msg,args): - """ - performs a random hunt - """ - if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] - places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - random.seed(time.time()) - currentWhat = random.choice(animals) - currentWhere = random.choice(places) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) - irc.reply(thisHunt) - irc.reply("aims....") - irc.reply("fires.....") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: - data = file.readlines() - bigHunt = data[2].rstrip('\n') - if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, you missed, " + msg.nick) - irc.reply(lose) - - - def fish(self,irc,msg,args): - """ - performs a random fishing trip - """ - if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') - fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: - data = file.readlines() - highScore = data[2].rstrip('\n') - random.seed(time.time()) - currentWhat = random.choice(fishes) - currentWhere = random.choice(fishSpots) - weight = random.randint(int(highScore)/2,int(highScore)+10) - weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere) - irc.reply(thisFishing) - irc.reply("casts in....") - irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds - huntChance = random.randint(1,100) - successRate = self.registryValue('SuccessRate') - - if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) - irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: - data = file.readlines() - bigFish = data[2].rstrip('\n') - if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: - data[0] = msg.nick - data[1] = currentWhat - data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) - irc.reply("you got a new highscore") - - - else: - lose = ("oops, it got away, " + msg.nick) - irc.reply(lose) - - def trophy(self,irc,msg,args): - """ - checks the current highscores for hunting and fishing - """ - if(self.registryValue('enable', msg.args[0])): - weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: - data1 = file1.readlines() - hunter = data1[0].rstrip('\n') - hunted = data1[1].rstrip('\n') - score = data1[2].rstrip('\n') - irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: - data2 = file2.readlines() - fisherman = data2[0].rstrip('\n') - catch = data2[1].rstrip('\n') - size = data2[2].rstrip('\n') - irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) - - - -Class = HuntNFish - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: +### +# Copyright (c) 2012, resistivecorpse +# 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. + +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import supybot.conf as conf +import random as random +import re +import time +import string +from supybot.i18n import PluginInternationalization, internationalizeDocstring + +_ = PluginInternationalization('HuntNFish') + +@internationalizeDocstring +class HuntNFish(callbacks.Plugin): + """Adds hunt and fish commands for a basic hunting and fishing game.""" + threaded = True + + def hunt(self,irc,msg,args): + """ + performs a random hunt + """ + if(self.registryValue('enable', msg.args[0])): + animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] + places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] + + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + random.seed(time.time()) + currentWhat = random.choice(animals) + currentWhere = random.choice(places) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + irc.reply(thisHunt) + irc.reply("aims....") + irc.reply("fires.....") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + data = file.readlines() + bigHunt = data[2].rstrip('\n') + if weight > int(bigHunt): + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, you missed, " + msg.nick) + irc.reply(lose) + + + def fish(self,irc,msg,args): + """ + performs a random fishing trip + """ + if(self.registryValue('enable', msg.args[0])): + fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') + + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + highScore = data[2].rstrip('\n') + random.seed(time.time()) + currentWhat = random.choice(fishes) + currentWhere = random.choice(fishSpots) + weight = random.randint(int(highScore)/2,int(highScore)+10) + weightType = self.registryValue('weightType') + thisFishing = (msg.nick + " goes fishing in " + currentWhere) + irc.reply(thisFishing) + irc.reply("casts in....") + irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") + time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + huntChance = random.randint(1,100) + successRate = self.registryValue('SuccessRate') + + if huntChance < successRate: + win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + irc.reply(win) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + data = file.readlines() + bigFish = data[2].rstrip('\n') + if weight > int(bigFish): + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + data[0] = msg.nick + data[1] = currentWhat + data[2] = weight + file.writelines(str(data[0])) + file.writelines('\n') + file.writelines(str(data[1])) + file.writelines('\n') + file.writelines(str(data[2])) + irc.reply("you got a new highscore") + + + else: + lose = ("oops, it got away, " + msg.nick) + irc.reply(lose) + + def trophy(self,irc,msg,args): + """ + checks the current highscores for hunting and fishing + """ + if(self.registryValue('enable', msg.args[0])): + weightType = self.registryValue('weightType') + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: + data1 = file1.readlines() + hunter = data1[0].rstrip('\n') + hunted = data1[1].rstrip('\n') + score = data1[2].rstrip('\n') + irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: + data2 = file2.readlines() + fisherman = data2[0].rstrip('\n') + catch = data2[1].rstrip('\n') + size = data2[2].rstrip('\n') + irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + + + +Class = HuntNFish + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/test.py b/test.py index f2b1a9e..5ae054b 100644 --- a/test.py +++ b/test.py @@ -1,37 +1,37 @@ -### -# Copyright (c) 2012, resistivecorpse -# 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 * - -class HuntNFishTestCase(PluginTestCase): - plugins = ('HuntNFish',) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: +### +# Copyright (c) 2012, resistivecorpse +# 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 * + +class HuntNFishTestCase(PluginTestCase): + plugins = ('HuntNFish',) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: From f359ce3443caf5d4bdbd12a6b496d657ebf8fefb Mon Sep 17 00:00:00 2001 From: Exiles Date: Sun, 23 Sep 2012 00:41:59 -0700 Subject: [PATCH 13/25] Update HuntNFish/plugin.py --- plugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 9cb4332..399529a 100644 --- a/plugin.py +++ b/plugin.py @@ -58,7 +58,8 @@ class HuntNFish(callbacks.Plugin): with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') - random.seed(time.time()) + huntrandom = random.getstate() + random.seed(time.time()) currentWhat = random.choice(animals) currentWhere = random.choice(places) weight = random.randint(int(highScore)/2,int(highScore)+10) @@ -67,9 +68,10 @@ class HuntNFish(callbacks.Plugin): irc.reply(thisHunt) irc.reply("aims....") irc.reply("fires.....") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + time.sleep(time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') + random.setstate(huntrandom) if huntChance < successRate: win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) @@ -106,7 +108,8 @@ class HuntNFish(callbacks.Plugin): with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') - random.seed(time.time()) + fishrandom = random.getstate() + random.seed(time.time()) currentWhat = random.choice(fishes) currentWhere = random.choice(fishSpots) weight = random.randint(int(highScore)/2,int(highScore)+10) @@ -115,9 +118,10 @@ class HuntNFish(callbacks.Plugin): irc.reply(thisFishing) irc.reply("casts in....") irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") - time.sleep(7)#pauses the output between line 1 and 2 for 5 seconds + time.sleep(time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') + random.setstate(fishrandom) if huntChance < successRate: win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) From 2ba5ed3177936ad90db2c75d6f532cf3919d4952 Mon Sep 17 00:00:00 2001 From: Exiles Date: Sun, 23 Sep 2012 01:27:03 -0700 Subject: [PATCH 14/25] Update HuntNFish/plugin.py --- plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 399529a..580c51a 100644 --- a/plugin.py +++ b/plugin.py @@ -68,7 +68,7 @@ class HuntNFish(callbacks.Plugin): irc.reply(thisHunt) irc.reply("aims....") irc.reply("fires.....") - time.sleep(time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds + time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') random.setstate(huntrandom) @@ -118,7 +118,7 @@ class HuntNFish(callbacks.Plugin): irc.reply(thisFishing) irc.reply("casts in....") irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") - time.sleep(time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds + time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') random.setstate(fishrandom) From 145e004b29efeb89b148f7b5c1a3e0a49d2dfc13 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Sun, 23 Sep 2012 18:37:35 -0400 Subject: [PATCH 15/25] made plugin.py generate highscores files upon load and fixed typos in README --- README.txt | 4 +--- plugin.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 94e254f..b75c96f 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,6 @@ this is a basic hunting and fishing game for supybot -move the files fishtrophy.txt and hunttrophy.txt to your bot's data folder to prevent any errors. in future versions i intend to cut this step out by having the plugin generate the files if they dont exsist already - -chance of success is a % variable, 1 to 10. it is set with config plugins>HuntNFish.successRate +chance of success is a % variable, 1 to 100. it is set with config plugins.HuntNFish.successRate the game can be turned off using config plugins.HuntNFish.enable diff --git a/plugin.py b/plugin.py index 580c51a..1889ea3 100644 --- a/plugin.py +++ b/plugin.py @@ -42,6 +42,19 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('HuntNFish') +try: + with open(conf.supybot.directories.data.dirize('hunttrophy.txt')) as f: pass +except IOError: + with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + file.writelines('Nobody\n nothing\n2') + +try: + with open(conf.supybot.directories.data.dirize('fishtrophy.txt')) as f: pass +except IOError: + with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + file.writelines('Nobody\n nothing\n2') + + @internationalizeDocstring class HuntNFish(callbacks.Plugin): """Adds hunt and fish commands for a basic hunting and fishing game.""" From f599d57969f3603fbf2f94cfd5fd04f197f0ee0f Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Sun, 23 Sep 2012 18:42:02 -0400 Subject: [PATCH 16/25] removed huntrophy.txt and fishtrophy.txt now that they are generated by the plugin --- fishtrophy.txt | 3 --- hunttrophy.txt | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 fishtrophy.txt delete mode 100644 hunttrophy.txt diff --git a/fishtrophy.txt b/fishtrophy.txt deleted file mode 100644 index 7c10f96..0000000 --- a/fishtrophy.txt +++ /dev/null @@ -1,3 +0,0 @@ -resistivecorpse - Tin Can -1 diff --git a/hunttrophy.txt b/hunttrophy.txt deleted file mode 100644 index 83bea9a..0000000 --- a/hunttrophy.txt +++ /dev/null @@ -1,3 +0,0 @@ -resistivecorpse - Deer -1 From ae89e765ac8048f57b9451280bbad39a1a016233 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 26 Sep 2012 16:57:53 -0400 Subject: [PATCH 17/25] switch to using .bd file extentions for trophy files and switched check for files to to os.path.isfile --- plugin.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/plugin.py b/plugin.py index 1889ea3..c0d3d1f 100644 --- a/plugin.py +++ b/plugin.py @@ -28,30 +28,27 @@ ### +import os +import re +import time +import string +import random as random +import supybot.conf as conf import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks -import supybot.conf as conf -import random as random -import re -import time -import string from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('HuntNFish') -try: - with open(conf.supybot.directories.data.dirize('hunttrophy.txt')) as f: pass -except IOError: - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: +if not os.path.isfile(conf.supybot.directories.data.dirize('hunttrophy.db')): + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as file: file.writelines('Nobody\n nothing\n2') -try: - with open(conf.supybot.directories.data.dirize('fishtrophy.txt')) as f: pass -except IOError: - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: +if not os.path.isfile(conf.supybot.directories.data.dirize('fishtrophy.db')): + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as file: file.writelines('Nobody\n nothing\n2') @@ -68,7 +65,7 @@ class HuntNFish(callbacks.Plugin): animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') huntrandom = random.getstate() @@ -89,11 +86,11 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file: + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file: data = file.readlines() bigHunt = data[2].rstrip('\n') if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'w') as file: + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as file: data[0] = msg.nick data[1] = currentWhat data[2] = weight @@ -104,11 +101,11 @@ class HuntNFish(callbacks.Plugin): file.writelines(str(data[2])) irc.reply("you got a new highscore") - else: lose = ("oops, you missed, " + msg.nick) irc.reply(lose) + hunt = wrap(hunt) def fish(self,irc,msg,args): """ @@ -118,7 +115,7 @@ class HuntNFish(callbacks.Plugin): fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file: data = file.readlines() highScore = data[2].rstrip('\n') fishrandom = random.getstate() @@ -139,11 +136,11 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file: + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file: data = file.readlines() bigFish = data[2].rstrip('\n') if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'w') as file: + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as file: data[0] = msg.nick data[1] = currentWhat data[2] = weight @@ -165,13 +162,13 @@ class HuntNFish(callbacks.Plugin): """ if(self.registryValue('enable', msg.args[0])): weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.txt'), 'r') as file1: + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file1: data1 = file1.readlines() hunter = data1[0].rstrip('\n') hunted = data1[1].rstrip('\n') score = data1[2].rstrip('\n') irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.txt'), 'r') as file2: + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file2: data2 = file2.readlines() fisherman = data2[0].rstrip('\n') catch = data2[1].rstrip('\n') From 096ab0e4abf1466b554d1d916b4008c011eba6f8 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 26 Sep 2012 19:27:10 -0400 Subject: [PATCH 18/25] adds command to reset highscores --- plugin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin.py b/plugin.py index c0d3d1f..aa22f0b 100644 --- a/plugin.py +++ b/plugin.py @@ -175,7 +175,14 @@ class HuntNFish(callbacks.Plugin): size = data2[2].rstrip('\n') irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + def resetscores(self,irc,msg,args): + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: + f.writelines('Nobody\n nothing\n2') + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: + f.writelines('Nobody\n nothing\n2') + irc.replySuccess() + resetscores = wrap(resetscores, ['owner']) Class = HuntNFish From b5a3a377ca19880533df068fee2af4110ddeeb00 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 26 Sep 2012 20:38:34 -0400 Subject: [PATCH 19/25] fixed/added help messages for all commands --- plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin.py b/plugin.py index aa22f0b..8eb2593 100644 --- a/plugin.py +++ b/plugin.py @@ -58,7 +58,7 @@ class HuntNFish(callbacks.Plugin): threaded = True def hunt(self,irc,msg,args): - """ + """takes no arguments performs a random hunt """ if(self.registryValue('enable', msg.args[0])): @@ -108,7 +108,7 @@ class HuntNFish(callbacks.Plugin): hunt = wrap(hunt) def fish(self,irc,msg,args): - """ + """takes no arguments performs a random fishing trip """ if(self.registryValue('enable', msg.args[0])): @@ -157,7 +157,7 @@ class HuntNFish(callbacks.Plugin): irc.reply(lose) def trophy(self,irc,msg,args): - """ + """takes no arguments checks the current highscores for hunting and fishing """ if(self.registryValue('enable', msg.args[0])): @@ -176,6 +176,9 @@ class HuntNFish(callbacks.Plugin): irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) def resetscores(self,irc,msg,args): + """takes no arguments + resets the highscores for both hunting and fishing. this command is limited to the owner, to prevent just anyone from clearing the scores + """ with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: f.writelines('Nobody\n nothing\n2') with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: From 7c918c64efd1c5c7ae1da47f4b78ec5be145fb8d Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Wed, 26 Sep 2012 21:34:20 -0400 Subject: [PATCH 20/25] switched from using file as the variable name for hunt and fish trophy files --- plugin.py | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/plugin.py b/plugin.py index 8eb2593..429d22a 100644 --- a/plugin.py +++ b/plugin.py @@ -44,12 +44,12 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('HuntNFish') if not os.path.isfile(conf.supybot.directories.data.dirize('hunttrophy.db')): - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as file: - file.writelines('Nobody\n nothing\n2') + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: + f.writelines('Nobody\n nothing\n2') if not os.path.isfile(conf.supybot.directories.data.dirize('fishtrophy.db')): - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as file: - file.writelines('Nobody\n nothing\n2') + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: + f.writelines('Nobody\n nothing\n2') @internationalizeDocstring @@ -65,8 +65,8 @@ class HuntNFish(callbacks.Plugin): animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file: - data = file.readlines() + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + data = f.readlines() highScore = data[2].rstrip('\n') huntrandom = random.getstate() random.seed(time.time()) @@ -86,19 +86,19 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file: - data = file.readlines() + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + data = f.readlines() bigHunt = data[2].rstrip('\n') if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as file: + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: data[0] = msg.nick data[1] = currentWhat data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) + f.writelines(str(data[0])) + f.writelines('\n') + f.writelines(str(data[1])) + f.writelines('\n') + f.writelines(str(data[2])) irc.reply("you got a new highscore") else: @@ -115,8 +115,8 @@ class HuntNFish(callbacks.Plugin): fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file: - data = file.readlines() + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + data = f.readlines() highScore = data[2].rstrip('\n') fishrandom = random.getstate() random.seed(time.time()) @@ -136,19 +136,19 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file: - data = file.readlines() + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + data = f.readlines() bigFish = data[2].rstrip('\n') if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as file: + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: data[0] = msg.nick data[1] = currentWhat data[2] = weight - file.writelines(str(data[0])) - file.writelines('\n') - file.writelines(str(data[1])) - file.writelines('\n') - file.writelines(str(data[2])) + f.writelines(str(data[0])) + f.writelines('\n') + f.writelines(str(data[1])) + f.writelines('\n') + f.writelines(str(data[2])) irc.reply("you got a new highscore") @@ -162,17 +162,17 @@ class HuntNFish(callbacks.Plugin): """ if(self.registryValue('enable', msg.args[0])): weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as file1: - data1 = file1.readlines() - hunter = data1[0].rstrip('\n') - hunted = data1[1].rstrip('\n') - score = data1[2].rstrip('\n') + with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + data = f.readlines() + hunter = data[0].rstrip('\n') + hunted = data[1].rstrip('\n') + score = data[2].rstrip('\n') irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as file2: - data2 = file2.readlines() - fisherman = data2[0].rstrip('\n') - catch = data2[1].rstrip('\n') - size = data2[2].rstrip('\n') + with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + data = f.readlines() + fisherman = data[0].rstrip('\n') + catch = data[1].rstrip('\n') + size = data[2].rstrip('\n') irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) def resetscores(self,irc,msg,args): From 33b9bab68786e91e96e4e07a50d20e5251affa55 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Thu, 27 Sep 2012 00:57:58 -0400 Subject: [PATCH 21/25] cleaned up code to set location of hunt and fish trophies as a global variable --- plugin.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/plugin.py b/plugin.py index 429d22a..0f65f28 100644 --- a/plugin.py +++ b/plugin.py @@ -43,13 +43,16 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('HuntNFish') -if not os.path.isfile(conf.supybot.directories.data.dirize('hunttrophy.db')): - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: - f.writelines('Nobody\n nothing\n2') +hunttrophy = conf.supybot.directories.data.dirize('hunttrophy.db') +fishtrophy = conf.supybot.directories.data.dirize('fishtrophy.db') -if not os.path.isfile(conf.supybot.directories.data.dirize('fishtrophy.db')): - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: - f.writelines('Nobody\n nothing\n2') +if not os.path.isfile(hunttrophy): + with open(hunttrophy, 'w') as f: + f.write('Nobody\n nothing\n2') + +if not os.path.isfile(fishtrophy): + with open(fishtrophy, 'w') as f: + f.write('Nobody\n nothing\n2') @internationalizeDocstring @@ -65,7 +68,7 @@ class HuntNFish(callbacks.Plugin): animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + with open(hunttrophy, 'r') as f: data = f.readlines() highScore = data[2].rstrip('\n') huntrandom = random.getstate() @@ -74,7 +77,7 @@ class HuntNFish(callbacks.Plugin): currentWhere = random.choice(places) weight = random.randint(int(highScore)/2,int(highScore)+10) weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) irc.reply(thisHunt) irc.reply("aims....") irc.reply("fires.....") @@ -86,11 +89,11 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + with open(hunttrophy, 'r') as f: data = f.readlines() bigHunt = data[2].rstrip('\n') if weight > int(bigHunt): - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: + with open(hunttrophy, 'w') as f: data[0] = msg.nick data[1] = currentWhat data[2] = weight @@ -115,7 +118,7 @@ class HuntNFish(callbacks.Plugin): fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + with open(fishtrophy, 'r') as f: data = f.readlines() highScore = data[2].rstrip('\n') fishrandom = random.getstate() @@ -136,11 +139,11 @@ class HuntNFish(callbacks.Plugin): if huntChance < successRate: win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) irc.reply(win) - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + with open(fishtrophy, 'r') as f: data = f.readlines() bigFish = data[2].rstrip('\n') if weight > int(bigFish): - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: + with open(fishtrophy, 'w') as f: data[0] = msg.nick data[1] = currentWhat data[2] = weight @@ -162,13 +165,13 @@ class HuntNFish(callbacks.Plugin): """ if(self.registryValue('enable', msg.args[0])): weightType = self.registryValue('weightType') - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'r') as f: + with open(hunttrophy, 'r') as f: data = f.readlines() hunter = data[0].rstrip('\n') hunted = data[1].rstrip('\n') score = data[2].rstrip('\n') irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'r') as f: + with open(fishtrophy, 'r') as f: data = f.readlines() fisherman = data[0].rstrip('\n') catch = data[1].rstrip('\n') @@ -179,10 +182,10 @@ class HuntNFish(callbacks.Plugin): """takes no arguments resets the highscores for both hunting and fishing. this command is limited to the owner, to prevent just anyone from clearing the scores """ - with open(conf.supybot.directories.data.dirize('hunttrophy.db'), 'w') as f: - f.writelines('Nobody\n nothing\n2') - with open(conf.supybot.directories.data.dirize('fishtrophy.db'), 'w') as f: - f.writelines('Nobody\n nothing\n2') + with open(hunttrophy, 'w') as f: + f.write('Nobody\n nothing\n2') + with open(fishtrophy, 'w') as f: + f.write('Nobody\n nothing\n2') irc.replySuccess() resetscores = wrap(resetscores, ['owner']) From bc9caac0114d7a41e4af94bded6608fd9f03b3f4 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Thu, 27 Sep 2012 01:22:58 -0400 Subject: [PATCH 22/25] cleaned up code to use only 1 line when writing highscores --- plugin.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugin.py b/plugin.py index 0f65f28..d57f8cd 100644 --- a/plugin.py +++ b/plugin.py @@ -97,11 +97,7 @@ class HuntNFish(callbacks.Plugin): data[0] = msg.nick data[1] = currentWhat data[2] = weight - f.writelines(str(data[0])) - f.writelines('\n') - f.writelines(str(data[1])) - f.writelines('\n') - f.writelines(str(data[2])) + f.write(str(data[0]) + '\n' + str(data[1]) + '\n' + str(data[2])) irc.reply("you got a new highscore") else: @@ -147,18 +143,15 @@ class HuntNFish(callbacks.Plugin): data[0] = msg.nick data[1] = currentWhat data[2] = weight - f.writelines(str(data[0])) - f.writelines('\n') - f.writelines(str(data[1])) - f.writelines('\n') - f.writelines(str(data[2])) + f.writelines(str(data[0]) + '\n' + str(data[1]) + '\n' + str(data[2])) irc.reply("you got a new highscore") - else: lose = ("oops, it got away, " + msg.nick) irc.reply(lose) + fish = wrap(fish) + def trophy(self,irc,msg,args): """takes no arguments checks the current highscores for hunting and fishing @@ -178,6 +171,8 @@ class HuntNFish(callbacks.Plugin): size = data[2].rstrip('\n') irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + trophy = wrap(trophy) + def resetscores(self,irc,msg,args): """takes no arguments resets the highscores for both hunting and fishing. this command is limited to the owner, to prevent just anyone from clearing the scores From d3ad647d677533276d9ea7371d88508cb95ef531 Mon Sep 17 00:00:00 2001 From: resistivecorpse Date: Thu, 27 Sep 2012 03:31:13 -0400 Subject: [PATCH 23/25] fixed code to not use addition to form strings --- plugin.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugin.py b/plugin.py index d57f8cd..e927b6d 100644 --- a/plugin.py +++ b/plugin.py @@ -48,11 +48,11 @@ fishtrophy = conf.supybot.directories.data.dirize('fishtrophy.db') if not os.path.isfile(hunttrophy): with open(hunttrophy, 'w') as f: - f.write('Nobody\n nothing\n2') + f.write('Nobody\nnothing\n2') if not os.path.isfile(fishtrophy): with open(fishtrophy, 'w') as f: - f.write('Nobody\n nothing\n2') + f.write('Nobody\nnothing\n2') @internationalizeDocstring @@ -65,7 +65,7 @@ class HuntNFish(callbacks.Plugin): performs a random hunt """ if(self.registryValue('enable', msg.args[0])): - animals = [' bear', ' gopher', ' rabbit', ' hunter', ' deer', ' fox', ' duck', ' moose', ' pokemon named Pikachu', ' park ranger', ' Yogi Bear', ' Boo Boo Bear', ' dog named Benji', ' cow', ' raccoon', ' koala bear', ' camper', ' channel lamer', ' your mom'] + animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer', 'your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] with open(hunttrophy, 'r') as f: @@ -75,9 +75,9 @@ class HuntNFish(callbacks.Plugin): random.seed(time.time()) currentWhat = random.choice(animals) currentWhere = random.choice(places) - weight = random.randint(int(highScore)/2,int(highScore)+10) weightType = self.registryValue('weightType') - thisHunt = (msg.nick + " goes hunting " + currentWhere + " for a " + str(weight) + weightType + currentWhat) + weight = (random.randint(int(highScore)/2,int(highScore)+10)) + thisHunt = '%s goes hunting %s for a %s%s %s' % (msg.nick, currentWhere, weight, weightType, currentWhat) irc.reply(thisHunt) irc.reply("aims....") irc.reply("fires.....") @@ -87,7 +87,7 @@ class HuntNFish(callbacks.Plugin): random.setstate(huntrandom) if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You killed the " + str(weight) + weightType + currentWhat) + win = 'way to go, %s. You killed the %s%s %s' % (msg.nick, weight, weightType, currentWhat) irc.reply(win) with open(hunttrophy, 'r') as f: data = f.readlines() @@ -101,7 +101,7 @@ class HuntNFish(callbacks.Plugin): irc.reply("you got a new highscore") else: - lose = ("oops, you missed, " + msg.nick) + lose = ' '.join(["oops, you missed", msg.nick]) irc.reply(lose) hunt = wrap(hunt) @@ -111,7 +111,7 @@ class HuntNFish(callbacks.Plugin): performs a random fishing trip """ if(self.registryValue('enable', msg.args[0])): - fishes = (' Salmon', ' Herring', ' Yellowfin Tuna', ' Pink Salmon', ' Chub', ' Barbel', ' Perch', ' Northern Pike', ' Brown Trout', ' Arctic Char', ' Roach', ' Brayling', ' Bleak', ' Cat Fish', ' Sun Fish', ' Old Tire', ' Rusty Tin Can', ' Genie Lamp', ' Love Message In A Bottle', ' Old Log', ' Rubber Boot' , ' Dead Body', ' Loch Ness Monster', ' Old Fishing Lure', ' Piece of the Titanic', ' Chunk of Atlantis', ' Squid', ' Whale', ' Dolphin', ' Porpoise' , ' Stingray', ' Submarine', ' Seal', ' Seahorse', ' Jellyfish', ' Starfish', ' Electric Eel', ' Great White Shark', ' Scuba Diver' , ' Lag Monster', ' Virus', ' Soggy Pack of Smokes', ' Bag of Weed', ' Boat Anchor', ' Pair Of Floaties', ' Mermaid', ' Merman', ' Halibut', ' Tiddler', ' Sock', ' Trout') + fishes = ('Salmon', 'Herring', 'Yellowfin Tuna', 'Pink Salmon', 'Chub', 'Barbel', 'Perch', 'Northern Pike', 'Brown Trout', 'Arctic Char', 'Roach', 'Brayling', 'Bleak', 'Cat Fish', 'Sun Fish', 'Old Tire', 'Rusty Tin Can', 'Genie Lamp', 'Love Message In A Bottle', 'Old Log', 'Rubber Boot' , 'Dead Body', 'Loch Ness Monster', 'Old Fishing Lure', 'Piece of the Titanic', 'Chunk of Atlantis', 'Squid', 'Whale', 'Dolphin', 'Porpoise' , 'Stingray', 'Submarine', 'Seal', 'Seahorse', 'Jellyfish', 'Starfish', 'Electric Eel', 'Great White Shark', 'Scuba Diver' , 'Lag Monster', 'Virus', 'Soggy Pack of Smokes', 'Bag of Weed', 'Boat Anchor', 'Pair Of Floaties', 'Mermaid', ' Merman', 'Halibut', 'Tiddler', 'Sock', 'Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') with open(fishtrophy, 'r') as f: @@ -123,17 +123,17 @@ class HuntNFish(callbacks.Plugin): currentWhere = random.choice(fishSpots) weight = random.randint(int(highScore)/2,int(highScore)+10) weightType = self.registryValue('weightType') - thisFishing = (msg.nick + " goes fishing in " + currentWhere) + thisFishing = '%s goes fishing in %s' % (msg.nick, currentWhere) irc.reply(thisFishing) irc.reply("casts in....") - irc.reply("a " + str(weight) + weightType + currentWhat + " is biting...") + irc.reply('a %s%s %s is biting...' % (str(weight), weightType, currentWhat)) time.sleep(random.randint(4,8))#pauses the output between line 1 and 2 for 4-8 seconds huntChance = random.randint(1,100) successRate = self.registryValue('SuccessRate') random.setstate(fishrandom) if huntChance < successRate: - win = ("way to go, " + msg.nick + ". You caught the " + str(weight) + weightType + currentWhat) + win = 'way to go, %s. You caught the %s%s %s' % (msg.nick, str(weight), weightType, currentWhat) irc.reply(win) with open(fishtrophy, 'r') as f: data = f.readlines() @@ -147,7 +147,7 @@ class HuntNFish(callbacks.Plugin): irc.reply("you got a new highscore") else: - lose = ("oops, it got away, " + msg.nick) + lose = ' '.join(["oops, it got away", msg.nick]) irc.reply(lose) fish = wrap(fish) @@ -162,14 +162,14 @@ class HuntNFish(callbacks.Plugin): data = f.readlines() hunter = data[0].rstrip('\n') hunted = data[1].rstrip('\n') - score = data[2].rstrip('\n') - irc.reply("hunting hiscore held by: " + hunter + " with a " + score + weightType + hunted) + size = data[2].rstrip('\n') + irc.reply('hunting highscore held by: %s with a %s%s %s' % (hunter, size, weightType, hunted)) with open(fishtrophy, 'r') as f: data = f.readlines() fisherman = data[0].rstrip('\n') catch = data[1].rstrip('\n') size = data[2].rstrip('\n') - irc.reply("fishing hiscore held by: " + fisherman + " with a " + size + weightType + catch) + irc.reply('fishing highscore held by: %s with a %s%s %s' % (fisherman, size, weightType, catch)) trophy = wrap(trophy) @@ -178,9 +178,9 @@ class HuntNFish(callbacks.Plugin): resets the highscores for both hunting and fishing. this command is limited to the owner, to prevent just anyone from clearing the scores """ with open(hunttrophy, 'w') as f: - f.write('Nobody\n nothing\n2') + f.write('Nobody\nnothing\n2') with open(fishtrophy, 'w') as f: - f.write('Nobody\n nothing\n2') + f.write('Nobody\nnothing\n2') irc.replySuccess() resetscores = wrap(resetscores, ['owner']) From b75b677568c077fc252a6fe49de4f3a1a0867b18 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Sun, 24 Feb 2019 21:35:28 -0500 Subject: [PATCH 24/25] python3 compatible. make stats per channel --- plugin.py | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/plugin.py b/plugin.py index e927b6d..d900eda 100644 --- a/plugin.py +++ b/plugin.py @@ -43,18 +43,6 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('HuntNFish') -hunttrophy = conf.supybot.directories.data.dirize('hunttrophy.db') -fishtrophy = conf.supybot.directories.data.dirize('fishtrophy.db') - -if not os.path.isfile(hunttrophy): - with open(hunttrophy, 'w') as f: - f.write('Nobody\nnothing\n2') - -if not os.path.isfile(fishtrophy): - with open(fishtrophy, 'w') as f: - f.write('Nobody\nnothing\n2') - - @internationalizeDocstring class HuntNFish(callbacks.Plugin): """Adds hunt and fish commands for a basic hunting and fishing game.""" @@ -64,6 +52,11 @@ class HuntNFish(callbacks.Plugin): """takes no arguments performs a random hunt """ + channel = msg.args[0] + hunttrophy = conf.supybot.directories.data.dirize("hunttrophy_{0}.db".format(channel)) + if not os.path.isfile(hunttrophy): + with open(hunttrophy, 'w') as f: + f.write('Nobody\nnothing\n2') if(self.registryValue('enable', msg.args[0])): animals = ['bear', 'gopher', 'rabbit', 'hunter', 'deer', 'fox', 'duck', 'moose', 'pokemon named Pikachu', 'park ranger', 'Yogi Bear', 'Boo Boo Bear', 'dog named Benji', 'cow', 'raccoon', 'koala bear', 'camper', 'channel lamer', 'your mom'] places = ['in some bushes', 'in a hunting blind', 'in a hole', 'up in a tree', 'in a hiding place', 'out in the open', 'in the middle of a field', 'downtown', 'on a street corner', 'at the local mall'] @@ -71,7 +64,7 @@ class HuntNFish(callbacks.Plugin): with open(hunttrophy, 'r') as f: data = f.readlines() highScore = data[2].rstrip('\n') - huntrandom = random.getstate() + huntrandom = random.getstate() random.seed(time.time()) currentWhat = random.choice(animals) currentWhere = random.choice(places) @@ -95,7 +88,7 @@ class HuntNFish(callbacks.Plugin): if weight > int(bigHunt): with open(hunttrophy, 'w') as f: data[0] = msg.nick - data[1] = currentWhat + data[1] = currentWhat data[2] = weight f.write(str(data[0]) + '\n' + str(data[1]) + '\n' + str(data[2])) irc.reply("you got a new highscore") @@ -110,6 +103,11 @@ class HuntNFish(callbacks.Plugin): """takes no arguments performs a random fishing trip """ + channel = msg.args[0] + fishtrophy = conf.supybot.directories.data.dirize("fishtrophy_{0}.db".format(channel)) + if not os.path.isfile(fishtrophy): + with open(fishtrophy, 'w') as f: + f.write('Nobody\nnothing\n2') if(self.registryValue('enable', msg.args[0])): fishes = ('Salmon', 'Herring', 'Yellowfin Tuna', 'Pink Salmon', 'Chub', 'Barbel', 'Perch', 'Northern Pike', 'Brown Trout', 'Arctic Char', 'Roach', 'Brayling', 'Bleak', 'Cat Fish', 'Sun Fish', 'Old Tire', 'Rusty Tin Can', 'Genie Lamp', 'Love Message In A Bottle', 'Old Log', 'Rubber Boot' , 'Dead Body', 'Loch Ness Monster', 'Old Fishing Lure', 'Piece of the Titanic', 'Chunk of Atlantis', 'Squid', 'Whale', 'Dolphin', 'Porpoise' , 'Stingray', 'Submarine', 'Seal', 'Seahorse', 'Jellyfish', 'Starfish', 'Electric Eel', 'Great White Shark', 'Scuba Diver' , 'Lag Monster', 'Virus', 'Soggy Pack of Smokes', 'Bag of Weed', 'Boat Anchor', 'Pair Of Floaties', 'Mermaid', ' Merman', 'Halibut', 'Tiddler', 'Sock', 'Trout') fishSpots = ('a Stream', 'a Lake', 'a River', 'a Pond', 'an Ocean', 'a Bathtub', 'a Kiddies Swimming Pool', 'a Toilet', 'a Pile of Vomit', 'a Pool of Urine', 'a Kitchen Sink', 'a Bathroom Sink', 'a Mud Puddle', 'a Pail of Water', 'a Bowl of Jell-O', 'a Wash Basin', 'a Rain Barrel', 'an Aquarium', 'a SnowBank', 'a WaterFall', 'a Cup of Coffee', 'a Glass of Milk') @@ -141,7 +139,7 @@ class HuntNFish(callbacks.Plugin): if weight > int(bigFish): with open(fishtrophy, 'w') as f: data[0] = msg.nick - data[1] = currentWhat + data[1] = currentWhat data[2] = weight f.writelines(str(data[0]) + '\n' + str(data[1]) + '\n' + str(data[2])) irc.reply("you got a new highscore") @@ -156,6 +154,15 @@ class HuntNFish(callbacks.Plugin): """takes no arguments checks the current highscores for hunting and fishing """ + channel = msg.args[0] + hunttrophy = conf.supybot.directories.data.dirize("hunttrophy_{0}.db".format(channel)) + fishtrophy = conf.supybot.directories.data.dirize("fishtrophy_{0}.db".format(channel)) + if not os.path.isfile(fishtrophy): + with open(fishtrophy, 'w') as f: + f.write('Nobody\nnothing\n2') + if not os.path.isfile(hunttrophy): + with open(hunttrophy, 'w') as f: + f.write('Nobody\nnothing\n2') if(self.registryValue('enable', msg.args[0])): weightType = self.registryValue('weightType') with open(hunttrophy, 'r') as f: @@ -177,13 +184,21 @@ class HuntNFish(callbacks.Plugin): """takes no arguments resets the highscores for both hunting and fishing. this command is limited to the owner, to prevent just anyone from clearing the scores """ + hunttrophy = conf.supybot.directories.data.dirize("hunttrophy_{0}.db".format(channel)) + fishtrophy = conf.supybot.directories.data.dirize("fishtrophy_{0}.db".format(channel)) + if not os.path.isfile(fishtrophy): + with open(fishtrophy, 'w') as f: + f.write('Nobody\nnothing\n2') + if not os.path.isfile(hunttrophy): + with open(hunttrophy, 'w') as f: + f.write('Nobody\nnothing\n2') with open(hunttrophy, 'w') as f: f.write('Nobody\nnothing\n2') with open(fishtrophy, 'w') as f: f.write('Nobody\nnothing\n2') irc.replySuccess() - resetscores = wrap(resetscores, ['owner']) + resetscores = wrap(resetscores, ['owner']) Class = HuntNFish From 60279c8d81d5e86b81dd193dd41336a1c3d8808f Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Sun, 24 Feb 2019 21:37:00 -0500 Subject: [PATCH 25/25] python3 compatible --- __init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index ec0fa11..89f5c4f 100644 --- a/__init__.py +++ b/__init__.py @@ -35,6 +35,7 @@ here. This should describe *what* the plugin does. import supybot import supybot.world as world +import importlib # Use this for the version of this plugin. You may wish to put a CVS keyword # in here if you're keeping the plugin in CVS or some similar system. @@ -51,14 +52,14 @@ __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. __url__ = '' # 'http://supybot.com/Members/yourname/HuntNFish/download' -import config -import plugin -reload(plugin) # In case we're being reloaded. +from . import config +from . import plugin +importlib.reload(plugin) # In case we're being reloaded. # 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! if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure