From 58432b5cdf84bad9d1e8486194675f73d71fd669 Mon Sep 17 00:00:00 2001 From: rakiru Date: Mon, 16 Jul 2018 21:55:22 +0100 Subject: [PATCH] tildebot | Move bonus points to puzzle file It seemed like the more logical place to be, and the way it was detecting might've accidentally given bonuses to future questions. It also means the bonus could be adjusted per question type now, if so desired. --- Code/irc/puzzle.py | 4 +++- Code/irc/tildebot.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Code/irc/puzzle.py b/Code/irc/puzzle.py index 198ecd9..ad43d87 100644 --- a/Code/irc/puzzle.py +++ b/Code/irc/puzzle.py @@ -10,6 +10,7 @@ fuzz_amount = 3 def make_puzzle(obfuscate=True): answer = 0 + bonus = 0 puzzle = random.choice(["Prove you're not a robot: ", "Are you a robot?: ", "Anti-bot check: ", "Counter-cndorphant measures: ", "Cosnok countermeasures: ", "Anti-tildethief precautions: "]) puzzle += random.choice(["What is", "How many is", "What do you get from", "What do you get with", "What is the value of", "Can you answer", "Can you tell me"]) puzzle += " " @@ -44,6 +45,7 @@ def make_puzzle(obfuscate=True): p1 = random.choice(primes) p2 = random.choice(primes) answer = str(min(p1,p2)) + ',' + str(max(p1,p2)) + bonus = 1 puzzle += p.number_to_words(p1 * p2) + " when factored into its two primes (answer in the form of the two primes with a comma between)" elif roll == 6: prime = random.choice(primes) @@ -82,4 +84,4 @@ def make_puzzle(obfuscate=True): for _ in range(fuzz_amount): idx = random.randrange(len(puzzle)-1) #get between 0 and string length puzzle = ''.join([puzzle[0:idx], chr(random.randint(33,126)), puzzle[idx+1:]]) - return [answer, puzzle] + return [puzzle, answer, bonus] diff --git a/Code/irc/tildebot.py b/Code/irc/tildebot.py index 66ff85e..fea86a1 100755 --- a/Code/irc/tildebot.py +++ b/Code/irc/tildebot.py @@ -138,15 +138,15 @@ def challenge(channel, user, name, time): return global challenges; challenge = puzzle.make_puzzle(); - challenges[user] = challenge[0]; #challenges[USER] = ANSWER - ircsock.send("PRIVMSG " + channel + " :" + name + ": " + challenge[1] + "\n"); + challenges[user] = challenge[1:]; #challenges[USER] = [ANSWER, BONUS] + ircsock.send("PRIVMSG " + channel + " :" + name + ": " + challenge[0] + "\n") def challenge_response(channel, user, name, time, msg): global challenges print(msg); if(challenges.has_key(user)): - bonus = 1 if str(challenges[user]).find(',') != -1 else 0 #give a bonus for prime factoring - if(msg.lower() == str(challenges[user]).lower() or msg == p.number_to_words(challenges[user])): + answer, bonus = challenges[user] + if(msg.lower() == str(answer).lower() or msg == p.number_to_words(answer)): give_tilde(channel, user, name, time, True, bonus); else: give_tilde(channel, user, name, time, False, 0);