# Path: data/pokedex.py

# 
# Path: plugins/games.py
# class GenericGame:
#     def __init__(self, ws, room):
#         self.ws = ws
#         self.room = room
#     def isThisGame(self, game):
#         return type(self) == game
# 
# Path: invoker.py
# class ReplyObject:
#     """ Class for returning information from a command to the core program.
# 
#     Parameters used for creating this class defines the behaviour of the main
#     program when it comes across the reply object.
# 
#     Attributes:
#         text: str, the content of the reply.
#         samePlace: bool, if the response will always be in pm or where the command
#         was said.
#         ignoreEscaping: bool, default every reply is escaped to not allow
#         arbitrary commands to be executed through replies. Some commands require
#         to be able to use PS commands, which is when this should be overwritten.
#         ignoreBroadcastPermission: bool, ignore the global broadcast permission
#         for the reply if this is true.
#         gameCommand: bool, unused, pending removal.
#         canPmReply: bool, override the default request for users without broadcast
#         permission to pm the command and instead return the result of the action.
#         isException: bool, if a command throws an exception this will be true.
#     """
#     def __init__(self, res = '', reply = False, escape = False, broadcast = False, game = False, pmreply = False, ignoreml = False):
#         self.text = str(res)
#         self.samePlace = reply
#         self.ignoreEscaping = escape
#         self.ignoreBroadcastPermission = broadcast
#         self.ignoreMultiline = ignoreml
#         self.gameCommand = game
#         self.canPmReply = pmreply
#         self.isException = isinstance(res, Exception)
# 
#     def __eq__(self, other):
#         try:
#             return (self.text == other.text
#                 and self.samePlace == other.samePlace
#                 and self.ignoreEscaping == other.ignoreEscaping
#                 and self.ignoreBroadcastPermission == other.ignoreBroadcastPermission
#                 and self.ignoreMultiline == other.ignoreMultiline
#                 and self.gameCommand == other.gameCommand
#                 and self.canPmReply == other.canPmReply
#                 and self.isException == other.isException
#             )
#         except:
#             # This only happens if the other object isn't a matching object
#             return False
# 
#     def response(self, text):
#         self.text = text
#         return self
#     def extra(self, text):
#         self.text += text
#         return self
# 
# class Command:
#     """ Wrapper class that every command should use when being created.
# 
#     The default run method should never be called, and any instance of the
#     class should override this method on creation of the instance.
# 
#     Commands should also implement any private methods they may need for completion
# 
#     Attributes:
#         cmdTriggers: List, list of every trigger that should be used to invoke
#         this method.
#         altHtml: Bool, true if the command has alternate output if HTML is supported.
#     """
#     def __init__(self, triggers, nonAbsRun = None, html = False):
#         self.cmdTriggers = triggers
#         self.altHtml = html
#         self.hasBroadcastAlt = False
#         # This will hide the default run method if it is given on object creation
#         self.run = nonAbsRun if nonAbsRun else self.run
#     def run(self, robot, cmd, room, params, user):
#         """Abstract method for executing a command after it has been found. Each command
#         has to reimplement this function to work.
# 
#         Args:
#             robot: PokemonShowdownBot, the instance of PokemonShowdownBot that called this function.
#             cmd: string, the command that was send.
#             room: Room, the room object that the command was sent from.
#             params: string, additional paramters that the command may need.
#             user: User, the user object of the user who sent the command.
#         Returns:
#             ReplyObject.
#         Raises:
#             NotImplementedError if not implemented, otherwise unknown. """
#         raise NotImplementedError('Command#run method not implemented')


from data.pokedex import Pokedex
from data.moves import Moves
from data.abilities import Abilities
from plugins.games import GenericGame
from invoker import ReplyObject, Command
import re
import random
import datetime
import yaml
    if room.isPM and not cmd.startswith('score'): return reply.response("Don't try to play games in pm please")
    if msg == 'new':
        if not user.hasRank('%'): return reply.response('You do not have permission to start a game in this room. (Requires %)')
        if room.activity: return reply.response('A game is already running somewhere')
        if not room.allowGames: return reply.response('This room does not support chatgames.')
        room.activity = Anagram()
        return reply.response('A new anagram has been created (guess with ~a):\n' + room.activity.getWord())

    elif msg == 'hint':
        if room.activity: return reply.response('The hint is: ' + room.activity.getHint())
        return reply.response('There is no active anagram right now')
    elif msg == 'end':
        if not user.hasRank('%'): return reply.response('You do not have permission to end the anagram. (Requires %)')
        if not (room.activity and room.activity.isThisGame(Anagram)): return reply.response('There is no active anagram or a different game is active.')
        solved = room.activity.getSolvedWord()
        room.activity = None
        return reply.response('The anagram was forcefully ended by {baduser}. (Killjoy)\nThe solution was: **{solved}**'.format(baduser = user.name, solved = solved))

    elif msg.lower().startswith('score'):
        if msg.strip() == 'score': msg += ' {user}'.format(user = user.id)
        name = bot.toId(msg[len('score '):])
        if name not in Scoreboard: return reply.response("This user never won any anagrams")
        return reply.response('This user has won {number} anagram{plural}'.format(number = Scoreboard[name], plural = '' if not type(Scoreboard[name]) == str and Scoreboard[name] < 2  else 's'))
    else:
        if msg: return reply.response('{param} is not a valid parameter for ~anagram. Make guesses with ~a'.format(param = msg))
        if room.activity and room.activity.isThisGame(Anagram):
            return reply.response('Current anagram: {word}'.format(word = room.activity.getWord()))
        return reply.response('There is no active anagram right now')

def answer(bot, cmd, msg, user, room):

# Path: data/pokedex.py

# 
# Path: plugins/games.py
# class GenericGame:
#     def __init__(self, ws, room):
#         self.ws = ws
#         self.room = room
#     def isThisGame(self, game):
#         return type(self) == game
# 
# Path: invoker.py
# class ReplyObject:
#     """ Class for returning information from a command to the core program.
# 
#     Parameters used for creating this class defines the behaviour of the main
#     program when it comes across the reply object.
# 
#     Attributes:
#         text: str, the content of the reply.
#         samePlace: bool, if the response will always be in pm or where the command
#         was said.
#         ignoreEscaping: bool, default every reply is escaped to not allow
#         arbitrary commands to be executed through replies. Some commands require
#         to be able to use PS commands, which is when this should be overwritten.
#         ignoreBroadcastPermission: bool, ignore the global broadcast permission
#         for the reply if this is true.
#         gameCommand: bool, unused, pending removal.
#         canPmReply: bool, override the default request for users without broadcast
#         permission to pm the command and instead return the result of the action.
#         isException: bool, if a command throws an exception this will be true.
#     """
#     def __init__(self, res = '', reply = False, escape = False, broadcast = False, game = False, pmreply = False, ignoreml = False):
#         self.text = str(res)
#         self.samePlace = reply
#         self.ignoreEscaping = escape
#         self.ignoreBroadcastPermission = broadcast
#         self.ignoreMultiline = ignoreml
#         self.gameCommand = game
#         self.canPmReply = pmreply
#         self.isException = isinstance(res, Exception)
# 
#     def __eq__(self, other):
#         try:
#             return (self.text == other.text
#                 and self.samePlace == other.samePlace
#                 and self.ignoreEscaping == other.ignoreEscaping
#                 and self.ignoreBroadcastPermission == other.ignoreBroadcastPermission
#                 and self.ignoreMultiline == other.ignoreMultiline
#                 and self.gameCommand == other.gameCommand
#                 and self.canPmReply == other.canPmReply
#                 and self.isException == other.isException
#             )
#         except:
#             # This only happens if the other object isn't a matching object
#             return False
# 
#     def response(self, text):
#         self.text = text
#         return self
#     def extra(self, text):
#         self.text += text
#         return self
# 
# class Command:
#     """ Wrapper class that every command should use when being created.
# 
#     The default run method should never be called, and any instance of the
#     class should override this method on creation of the instance.
# 
#     Commands should also implement any private methods they may need for completion
# 
#     Attributes:
#         cmdTriggers: List, list of every trigger that should be used to invoke
#         this method.
#         altHtml: Bool, true if the command has alternate output if HTML is supported.
#     """
#     def __init__(self, triggers, nonAbsRun = None, html = False):
#         self.cmdTriggers = triggers
#         self.altHtml = html
#         self.hasBroadcastAlt = False
#         # This will hide the default run method if it is given on object creation
#         self.run = nonAbsRun if nonAbsRun else self.run
#     def run(self, robot, cmd, room, params, user):
#         """Abstract method for executing a command after it has been found. Each command
#         has to reimplement this function to work.
# 
#         Args:
#             robot: PokemonShowdownBot, the instance of PokemonShowdownBot that called this function.
#             cmd: string, the command that was send.
#             room: Room, the room object that the command was sent from.
#             params: string, additional paramters that the command may need.
#             user: User, the user object of the user who sent the command.
#         Returns:
#             ReplyObject.
#         Raises:
#             NotImplementedError if not implemented, otherwise unknown. """
#         raise NotImplementedError('Command#run method not implemented')


# Path: plugins/anagram.py
from data.pokedex import Pokedex
from data.moves import Moves
from data.abilities import Abilities
from plugins.games import GenericGame
from invoker import ReplyObject, Command
import re
import random
import datetime
import yaml

    if room.isPM and not cmd.startswith('score'): return reply.response("Don't try to play games in pm please")
    if msg == 'new':
        if not user.hasRank('%'): return reply.response('You do not have permission to start a game in this room. (Requires %)')
        if room.activity: return reply.response('A game is already running somewhere')
        if not room.allowGames: return reply.response('This room does not support chatgames.')
        room.activity = Anagram()
        return reply.response('A new anagram has been created (guess with ~a):\n' + room.activity.getWord())

    elif msg == 'hint':
        if room.activity: return reply.response('The hint is: ' + room.activity.getHint())
        return reply.response('There is no active anagram right now')
    elif msg == 'end':
        if not user.hasRank('%'): return reply.response('You do not have permission to end the anagram. (Requires %)')
        if not (room.activity and room.activity.isThisGame(Anagram)): return reply.response('There is no active anagram or a different game is active.')
        solved = room.activity.getSolvedWord()
        room.activity = None
        return reply.response('The anagram was forcefully ended by {baduser}. (Killjoy)\nThe solution was: **{solved}**'.format(baduser = user.name, solved = solved))

    elif msg.lower().startswith('score'):
        if msg.strip() == 'score': msg += ' {user}'.format(user = user.id)
        name = bot.toId(msg[len('score '):])
        if name not in Scoreboard: return reply.response("This user never won any anagrams")
        return reply.response('This user has won {number} anagram{plural}'.format(number = Scoreboard[name], plural = '' if not type(Scoreboard[name]) == str and Scoreboard[name] < 2  else 's'))
    else:
        if msg: return reply.response('{param} is not a valid parameter for ~anagram. Make guesses with ~a'.format(param = msg))
        if room.activity and room.activity.isThisGame(Anagram):
            return reply.response('Current anagram: {word}'.format(word = room.activity.getWord()))
        return reply.response('There is no active anagram right now')

def answer(bot, cmd, msg, user, room):

    reply = ReplyObject('', True, False, False, True, True)