Rework logic to also check on the first word given; don't allow dupes
This commit is contained in:
parent
7a029ddf96
commit
48c4a30e4c
|
@ -36,35 +36,33 @@ class Games(commands.Cog):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# The info for the last word used
|
# Setup the info needed for the game
|
||||||
last_word = start_word
|
message = ctx.message
|
||||||
last_letter = grab_letter(start_word)
|
mesage.content = start_word
|
||||||
last_author = ctx.author
|
words_used = []
|
||||||
words_used = [start_word]
|
|
||||||
|
|
||||||
# Add the reaction to the first message, to show we've started
|
|
||||||
await ctx.message.add_reaction("✅")
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
message = await ctx.bot.wait_for("message", check=check)
|
# Grab the first letter of this new word and check it
|
||||||
|
|
||||||
# Grab the first letter of this new word
|
|
||||||
first_letter = grab_letter(message.content, last=False)
|
first_letter = grab_letter(message.content, last=False)
|
||||||
|
# Include extra check for if this is the first word
|
||||||
if first_letter != last_letter:
|
if words_used and first_letter != last_letter:
|
||||||
break
|
break
|
||||||
|
# Now set the "last" information, to start checking if it's correct
|
||||||
# As long as we got a valid message, and the letter matches, then we're all good. Continue on
|
|
||||||
last_word = message.content
|
last_word = message.content
|
||||||
last_letter = grab_letter(message.content)
|
last_letter = grab_letter(last_word)
|
||||||
|
last_author = message.author
|
||||||
|
|
||||||
# Extra check for the japanese version, ん cannot be used
|
# Extra check for the japanese version, ん cannot be used
|
||||||
if last_letter in ("ん", "ン"):
|
if last_letter in ("ん", "ン"):
|
||||||
break
|
break
|
||||||
|
# Cannot reuuse words; though make sure this doesn't get caught on the very first usage
|
||||||
|
if last_word in words_used and len(words_used) > 1:
|
||||||
|
break
|
||||||
|
|
||||||
last_author = message.author
|
# If we're here, then the last letter used was valid
|
||||||
words_used.append(last_word)
|
words_used.append(last_word)
|
||||||
await message.add_reaction("✅")
|
await message.add_reaction("✅")
|
||||||
|
message = await ctx.bot.wait_for("message", check=check)
|
||||||
|
|
||||||
# If we're here, game over, someone messed up
|
# If we're here, game over, someone messed up
|
||||||
await message.add_reaction("❌")
|
await message.add_reaction("❌")
|
||||||
|
|
Loading…
Reference in a new issue