adding '.' other hint command

This commit is contained in:
rootcoma 2013-11-06 12:50:44 -08:00
parent 3a8476f5bb
commit 0a67df08a7
2 changed files with 43 additions and 4 deletions

View File

@ -30,6 +30,11 @@ conf.registerChannelValue(TriviaTime, 'quizfile',
)
# timeout, number of hints, values
conf.registerChannelValue(TriviaTime, 'showOtherHintCommand',
registry.NormalizedString(""".""",
"""The command to show alternative hints""")
)
conf.registerChannelValue(TriviaTime, 'showHintCommandKAOS',
registry.NormalizedString(""",""",
"""The command for showing the remaining KAOS""")
@ -122,7 +127,7 @@ conf.registerChannelValue(TriviaTime, 'charMask',
# victory text, help messages, formatting
conf.registerChannelValue(TriviaTime, 'starting',
registry.NormalizedString("""Another epic round of tivia is about to begin.""",
registry.NormalizedString("""Another epic round of trivia is about to begin.""",
"""Message shown when trivia starts""")
)
@ -142,7 +147,7 @@ conf.registerChannelValue(TriviaTime, 'alreadyStarted',
)
conf.registerChannelValue(TriviaTime, 'answeredKAOS',
registry.NormalizedString("""\x02%s\x02 gets \x02d\x02 points for: \x02%s\x02""",
registry.NormalizedString("""\x02%s\x02 gets \x02%d\x02 points for: \x02%s\x02""",
"""Message for one correct guess during KAOS""")
)

View File

@ -71,6 +71,12 @@ class TriviaTime(callbacks.Plugin):
"""
Catches all PRIVMSG, including channels communication
"""
username = str.lower(msg.nick)
try:
user = ircdb.users.getUser(msg.prefix) # rootcoma!~rootcomaa@unaffiliated/rootcoma
username = str.lower(user.name)
except KeyError:
pass
channel = ircutils.toLower(msg.args[0])
# Make sure that it is starting inside of a channel, not in pm
if not irc.isChannel(channel):
@ -81,6 +87,8 @@ class TriviaTime(callbacks.Plugin):
# Look for command to list remaining KAOS
if msg.args[1] == self.registryValue('showHintCommandKAOS',channel):
self.games[channel].getRemainingKAOS()
elif msg.args[1] == self.registryValue('showOtherHintCommand', channel):
self.games[channel].getOtherHint(username)
else:
# check the answer
self.games[channel].checkAnswer(msg)
@ -648,6 +656,7 @@ class TriviaTime(callbacks.Plugin):
# reset stats
self.shownHint = False
self.skipVoteCount = {}
self.shownOtherHint = {}
self.streak = 0
self.lastWinner = ''
self.hintsCounter = 0
@ -858,7 +867,7 @@ class TriviaTime(callbacks.Plugin):
divider = int(len(ans) * ratio)
if divider > 3:
divider = 3
if divider > len(ans):
if divider >= len(ans):
divider = len(ans)-1
hints += ans[:divider]
masked = ans[divider:]
@ -867,7 +876,7 @@ class TriviaTime(callbacks.Plugin):
divider = int(len(ans) * ratio)
if divider > 3:
divider = 3
if divider > len(ans):
if divider >= len(ans):
divider = len(ans)-1
lettersInARow=divider-1
maskedInARow=0
@ -896,6 +905,29 @@ class TriviaTime(callbacks.Plugin):
hints += ']'
return hints
def getOtherHintString(self):
hintRatio = self.registryValue('hintShowRatio') # % to show each hint
ratio = float(hintRatio * .01)
timeElapsed = float(time.time() - self.askedAt)
showPercentage = float((timeElapsed + (self.registryValue('timeout', self.channel)/2)) / (self.registryValue('timeout', self.channel) * 2))
charMask = self.registryValue('charMask', self.channel)
if len(self.answers) > 1 or len(self.answers) < 1:
return
ans = self.answers[0]
divider = int(len(ans) * ratio * showPercentage + 1)
if divider >= len(ans):
divider = len(ans)-1
hints = 'Hint: \x02\x0312'
hints += ans[:divider]
return hints
def getOtherHint(self, username):
if username in self.shownOtherHint:
return
self.shownOtherHint[username] = True
if len(self.answers) == 1:
self.sendMessage(self.getOtherHintString())
def getRemainingKAOS(self):
if len(self.answers) > 1:
if self.shownHint == False:
@ -912,6 +944,7 @@ class TriviaTime(callbacks.Plugin):
self.sendMessage('Hint %s: %s' % (self.hintsCounter, hints), 1, 9)
#reset hint shown
self.shownHint = False
self.shownOtherHint = {}
timeout = 2
if len(self.answers) > 1:
@ -938,6 +971,7 @@ class TriviaTime(callbacks.Plugin):
self.questionOver = False
self.shownHint = False
self.skipVoteCount = {}
self.shownOtherHint = {}
self.question = ''
self.answers = []
self.alternativeAnswers = []