|
|
@ -198,26 +198,26 @@ class Hangman:
|
|
|
|
outphrase = phrases[randint(0, len(phrases) - 1)].partition(" (")[0]
|
|
|
|
outphrase = phrases[randint(0, len(phrases) - 1)].partition(" (")[0]
|
|
|
|
return outphrase
|
|
|
|
return outphrase
|
|
|
|
|
|
|
|
|
|
|
|
def _hideanswer(self):
|
|
|
|
def _hideanswer(self, guild):
|
|
|
|
"""Returns the obscured answer"""
|
|
|
|
"""Returns the obscured answer"""
|
|
|
|
out_str = ""
|
|
|
|
out_str = ""
|
|
|
|
|
|
|
|
|
|
|
|
self.winbool = True
|
|
|
|
self.winbool = True
|
|
|
|
for i in self.the_data["answer"]:
|
|
|
|
for i in self.the_data[guild]["answer"]:
|
|
|
|
if i == " " or i == "-":
|
|
|
|
if i == " " or i == "-":
|
|
|
|
out_str += i * 2
|
|
|
|
out_str += i * 2
|
|
|
|
elif i in self.the_data["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
|
|
|
elif i in self.the_data[guild]["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
|
|
|
out_str += "__" + i + "__ "
|
|
|
|
out_str += "__" + i + "__ "
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
out_str += "**\_** "
|
|
|
|
out_str += "**\_** "
|
|
|
|
self.winbool = False
|
|
|
|
self.winbool[guild] = False
|
|
|
|
|
|
|
|
|
|
|
|
return out_str
|
|
|
|
return out_str
|
|
|
|
|
|
|
|
|
|
|
|
def _guesslist(self):
|
|
|
|
def _guesslist(self, guild):
|
|
|
|
"""Returns the current letter list"""
|
|
|
|
"""Returns the current letter list"""
|
|
|
|
out_str = ""
|
|
|
|
out_str = ""
|
|
|
|
for i in self.the_data["guesses"]:
|
|
|
|
for i in self.the_data[guild]["guesses"]:
|
|
|
|
out_str += str(i) + ","
|
|
|
|
out_str += str(i) + ","
|
|
|
|
out_str = out_str[:-1]
|
|
|
|
out_str = out_str[:-1]
|
|
|
|
|
|
|
|
|
|
|
@ -233,7 +233,7 @@ class Hangman:
|
|
|
|
await channel.send("Already guessed that! Try again")
|
|
|
|
await channel.send("Already guessed that! Try again")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if guess.upper() not in self.the_data[channel.guild]["answer"]:
|
|
|
|
if guess.upper() not in self.the_data[channel.guild]["answer"]:
|
|
|
|
self.the_data["hangman"] += 1
|
|
|
|
self.the_data[channel.guild]["hangman"] += 1
|
|
|
|
|
|
|
|
|
|
|
|
self.the_data[channel.guild]["guesses"].append(guess.upper())
|
|
|
|
self.the_data[channel.guild]["guesses"].append(guess.upper())
|
|
|
|
|
|
|
|
|
|
|
@ -243,7 +243,7 @@ class Hangman:
|
|
|
|
""" Thanks to flapjack reactpoll for guidelines
|
|
|
|
""" Thanks to flapjack reactpoll for guidelines
|
|
|
|
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
|
|
|
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
|
|
|
|
|
|
|
|
|
|
|
if not self.the_data["trackmessage"]:
|
|
|
|
if reaction.message.id != self.the_data[user.guild]["trackmessage"]:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if user == self.bot.user:
|
|
|
|
if user == self.bot.user:
|
|
|
@ -251,9 +251,6 @@ class Hangman:
|
|
|
|
message = reaction.message
|
|
|
|
message = reaction.message
|
|
|
|
emoji = reaction.emoji
|
|
|
|
emoji = reaction.emoji
|
|
|
|
|
|
|
|
|
|
|
|
if not message.id == self.the_data["trackmessage"]:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if str(emoji) in self.letters:
|
|
|
|
if str(emoji) in self.letters:
|
|
|
|
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[self.letters.index(str(emoji))]
|
|
|
|
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[self.letters.index(str(emoji))]
|
|
|
|
await self._guessletter(letter, message.channel)
|
|
|
|
await self._guessletter(letter, message.channel)
|
|
|
@ -292,14 +289,14 @@ class Hangman:
|
|
|
|
|
|
|
|
|
|
|
|
async def _printgame(self, channel):
|
|
|
|
async def _printgame(self, channel):
|
|
|
|
"""Print the current state of game"""
|
|
|
|
"""Print the current state of game"""
|
|
|
|
cSay = ("Guess this: " + str(self._hideanswer()) + "\n"
|
|
|
|
cSay = ("Guess this: " + str(self._hideanswer(channel.guild)) + "\n"
|
|
|
|
+ "Used Letters: " + str(self._guesslist()) + "\n"
|
|
|
|
+ "Used Letters: " + str(self._guesslist(channel.guild)) + "\n"
|
|
|
|
+ self.hanglist[self.the_data["hangman"]] + "\n"
|
|
|
|
+ self.hanglist[self.the_data[channel.guild]["hangman"]] + "\n"
|
|
|
|
+ self.navigate[0] + " for A-M, " + self.navigate[-1] + " for N-Z")
|
|
|
|
+ self.navigate[0] + " for A-M, " + self.navigate[-1] + " for N-Z")
|
|
|
|
|
|
|
|
|
|
|
|
message = await channel.send(cSay)
|
|
|
|
message = await channel.send(cSay)
|
|
|
|
|
|
|
|
|
|
|
|
self.the_data["trackmessage"] = message.id
|
|
|
|
self.the_data[channel.guild]["trackmessage"] = message.id
|
|
|
|
|
|
|
|
|
|
|
|
await self._reactmessage_menu(message)
|
|
|
|
await self._reactmessage_menu(message)
|
|
|
|
await self._checkdone(channel)
|
|
|
|
await self._checkdone(channel)
|
|
|
|