mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Modified it to work with the new config scheme
This commit is contained in:
parent
3327eae8a0
commit
d5bb45eacc
@ -48,8 +48,8 @@ import conf
|
|||||||
import utils
|
import utils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
import configurable
|
|
||||||
import ircutils
|
import ircutils
|
||||||
|
import registry
|
||||||
|
|
||||||
|
|
||||||
def configure(onStart, afterConnect, advanced):
|
def configure(onStart, afterConnect, advanced):
|
||||||
@ -155,11 +155,24 @@ class HangmanGame:
|
|||||||
else:
|
else:
|
||||||
return 'a'
|
return 'a'
|
||||||
|
|
||||||
|
configurables = configurable.Dictionary(
|
||||||
|
[('tries', configurable.IntType, 6, 'Number of tries to guess a word'),
|
||||||
|
('prefix', configurable.StrType, '-= HANGMAN =-',
|
||||||
|
'Prefix string of the hangman plugin'),
|
||||||
|
('timeout', configurable.IntType, 300, 'Time before a game times out')]
|
||||||
|
)
|
||||||
|
|
||||||
|
conf.registerPlugin('Words')
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Words, 'hangmanMaxTries',
|
||||||
|
registry.Integer(6, """Number of tries to guess a word"""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Words, 'hangmanPrefix',
|
||||||
|
registry.String('{HM}', """Prefix string of the hangman plugin"""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Words, 'hangmanTimeout',
|
||||||
|
registry.Integer(300, """Time before a game times out"""))
|
||||||
|
|
||||||
class Words(callbacks.Privmsg, configurable.Mixin):
|
class Words(callbacks.Privmsg, configurable.Mixin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
configurable.Mixin.__init__(self)
|
|
||||||
dataDir = conf.supybot.directories.data()
|
dataDir = conf.supybot.directories.data()
|
||||||
self.dbHandler = WordsDB(os.path.join(dataDir, 'Words'))
|
self.dbHandler = WordsDB(os.path.join(dataDir, 'Words'))
|
||||||
try:
|
try:
|
||||||
@ -233,12 +246,6 @@ class Words(callbacks.Privmsg, configurable.Mixin):
|
|||||||
###
|
###
|
||||||
# HANGMAN
|
# HANGMAN
|
||||||
###
|
###
|
||||||
configurables = configurable.Dictionary(
|
|
||||||
[('tries', configurable.IntType, 6, 'Number of tries to guess a word'),
|
|
||||||
('prefix', configurable.StrType, '-= HANGMAN =-',
|
|
||||||
'Prefix string of the hangman plugin'),
|
|
||||||
('timeout', configurable.IntType, 300, 'Time before a game times out')]
|
|
||||||
)
|
|
||||||
dicturl = 'http://www.unixhideout.com/freebsd/share/dict/words'
|
dicturl = 'http://www.unixhideout.com/freebsd/share/dict/words'
|
||||||
games = ircutils.IrcDict()
|
games = ircutils.IrcDict()
|
||||||
validLetters = [chr(c) for c in range(ord('a'), ord('z')+1)]
|
validLetters = [chr(c) for c in range(ord('a'), ord('z')+1)]
|
||||||
@ -272,10 +279,10 @@ class Words(callbacks.Privmsg, configurable.Mixin):
|
|||||||
if self.games[channel] is None:
|
if self.games[channel] is None:
|
||||||
self.games[channel] = HangmanGame()
|
self.games[channel] = HangmanGame()
|
||||||
game = self.games[channel]
|
game = self.games[channel]
|
||||||
game.timeout = self.configurables.get('timeout', channel)
|
game.timeout = conf.supybot.plugins.Words.hangmanTimeout()
|
||||||
game.timeGuess = time.time()
|
game.timeGuess = time.time()
|
||||||
game.tries = self.configurables.get('tries', channel)
|
game.tries = conf.supybot.plugins.Words.hangmanMaxTries()
|
||||||
game.prefix = self.configurables.get('prefix', channel) + ' '
|
game.prefix = conf.supybot.plugins.Words.hangmanPrefix() + ' '
|
||||||
game.guessed = False
|
game.guessed = False
|
||||||
game.unused = copy.copy(self.validLetters)
|
game.unused = copy.copy(self.validLetters)
|
||||||
game.hidden = game.getWord(self.dbHandler)
|
game.hidden = game.getWord(self.dbHandler)
|
||||||
|
Loading…
Reference in New Issue
Block a user