|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
import discord
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from collections import defaultdict
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
from redbot.core import Config, checks, RedContext
|
|
|
|
|
import discord
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
from redbot.core import Config, checks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Hangman:
|
|
|
|
@ -20,7 +18,8 @@ class Hangman:
|
|
|
|
|
|
|
|
|
|
self.config.register_guild(**default_guild)
|
|
|
|
|
|
|
|
|
|
self.the_data = defaultdict(lambda:{"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''})
|
|
|
|
|
self.the_data = defaultdict(
|
|
|
|
|
lambda: {"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''})
|
|
|
|
|
self.answer_path = "hangman/data/hanganswers.txt"
|
|
|
|
|
self.winbool = defaultdict(lambda: False)
|
|
|
|
|
|
|
|
|
@ -77,7 +76,6 @@ class Hangman:
|
|
|
|
|
|\___
|
|
|
|
|
HAN""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""">
|
|
|
|
|
\_________
|
|
|
|
|
|/ |
|
|
|
|
@ -89,7 +87,6 @@ class Hangman:
|
|
|
|
|
|\___
|
|
|
|
|
HANG""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""">
|
|
|
|
|
\_________
|
|
|
|
|
|/ |
|
|
|
|
@ -101,8 +98,6 @@ class Hangman:
|
|
|
|
|
|\___
|
|
|
|
|
HANGM""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""">
|
|
|
|
|
\________
|
|
|
|
|
|/ |
|
|
|
|
@ -114,7 +109,6 @@ class Hangman:
|
|
|
|
|
|\___
|
|
|
|
|
HANGMA""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""">
|
|
|
|
|
\________
|
|
|
|
|
|/ |
|
|
|
|
@ -170,7 +164,6 @@ class Hangman:
|
|
|
|
|
else:
|
|
|
|
|
await self._guessletter(guess, ctx.channel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _startgame(self, guild):
|
|
|
|
|
"""Starts a new game of hangman"""
|
|
|
|
|
self.the_data[guild]["answer"] = self._getphrase().upper()
|
|
|
|
@ -250,8 +243,6 @@ class Hangman:
|
|
|
|
|
""" Thanks to flapjack reactpoll for guidelines
|
|
|
|
|
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.the_data["trackmessage"]:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@ -267,7 +258,6 @@ class Hangman:
|
|
|
|
|
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[self.letters.index(str(emoji))]
|
|
|
|
|
await self._guessletter(letter, message.channel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if str(emoji) in self.navigate:
|
|
|
|
|
if str(emoji) == self.navigate[0]:
|
|
|
|
|
await self._reactmessage_am(message)
|
|
|
|
@ -275,7 +265,6 @@ class Hangman:
|
|
|
|
|
if str(emoji) == self.navigate[-1]:
|
|
|
|
|
await self._reactmessage_nz(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _reactmessage_menu(self, message):
|
|
|
|
|
"""React with menu options"""
|
|
|
|
|
await message.clear_reactions()
|
|
|
|
@ -301,7 +290,6 @@ class Hangman:
|
|
|
|
|
|
|
|
|
|
await message.add_reaction(self.navigate[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _printgame(self, channel):
|
|
|
|
|
"""Print the current state of game"""
|
|
|
|
|
cSay = ("Guess this: " + str(self._hideanswer()) + "\n"
|
|
|
|
@ -321,4 +309,3 @@ def setup(bot):
|
|
|
|
|
n = Hangman(bot)
|
|
|
|
|
bot.add_cog(n)
|
|
|
|
|
bot.add_listener(n._on_react, "on_reaction_add")
|
|
|
|
|
|
|
|
|
|