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.
This commit is contained in:
rakiru committed 2018-07-16 21:55:22 +01:00
1 parent dcbf3d174e
commit 58432b5cdf
2 files changed
+7 -5

No files matched your search

+3 -1
View File
@@ -10,6 +10,7 @@ fuzz_amount = 3
def make_puzzle(obfuscate=True): def make_puzzle(obfuscate=True):
answer = 0 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(["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 += 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 += " " puzzle += " "
@@ -44,6 +45,7 @@ def make_puzzle(obfuscate=True):
p1 = random.choice(primes) p1 = random.choice(primes)
p2 = random.choice(primes) p2 = random.choice(primes)
answer = str(min(p1,p2)) + ',' + str(max(p1,p2)) 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)" 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: elif roll == 6:
prime = random.choice(primes) prime = random.choice(primes)
@@ -82,4 +84,4 @@ def make_puzzle(obfuscate=True):
for _ in range(fuzz_amount): for _ in range(fuzz_amount):
idx = random.randrange(len(puzzle)-1) #get between 0 and string length 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:]]) puzzle = ''.join([puzzle[0:idx], chr(random.randint(33,126)), puzzle[idx+1:]])
return [answer, puzzle] return [puzzle, answer, bonus]
+4 -4
View File
@@ -138,15 +138,15 @@ def challenge(channel, user, name, time):
return return
global challenges; global challenges;
challenge = puzzle.make_puzzle(); challenge = puzzle.make_puzzle();
challenges[user] = challenge[0]; #challenges[USER] = ANSWER challenges[user] = challenge[1:]; #challenges[USER] = [ANSWER, BONUS]
ircsock.send("PRIVMSG " + channel + " :" + name + ": " + challenge[1] + "\n"); ircsock.send("PRIVMSG " + channel + " :" + name + ": " + challenge[0] + "\n")
def challenge_response(channel, user, name, time, msg): def challenge_response(channel, user, name, time, msg):
global challenges global challenges
print(msg); print(msg);
if(challenges.has_key(user)): if(challenges.has_key(user)):
bonus = 1 if str(challenges[user]).find(',') != -1 else 0 #give a bonus for prime factoring answer, bonus = challenges[user]
if(msg.lower() == str(challenges[user]).lower() or msg == p.number_to_words(challenges[user])): if(msg.lower() == str(answer).lower() or msg == p.number_to_words(answer)):
give_tilde(channel, user, name, time, True, bonus); give_tilde(channel, user, name, time, True, bonus);
else: else:
give_tilde(channel, user, name, time, False, 0); give_tilde(channel, user, name, time, False, 0);