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 2018-07-16 21:55:22 +01:00
parent dcbf3d174e
commit 58432b5cdf
2 changed files with 7 additions and 5 deletions

View File

@ -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]

View File

@ -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);