示例#1
0
    def setupCommands(self):
        CommandsPlugin = self.dependencies[0]

        if self.Call_AI_Command not in CommandsPlugin.__commands__:
            CommandsPlugin.__commands__.append(self.Call_AI_Command)

        GeneralEvent.on('command={}'.format(self.Call_AI_Command.lower()),
                        self.Play4)
        self.logger.debug("FindFour AI Call Command set. Command : %s",
                          self.Call_AI_Command)
示例#2
0
    def __init__(self):
        super(Commands, self).__init__()

        self.logger = logging.getLogger(TIMELINE_LOGGER)

        GeneralEvent.on('before-message', self)
        GeneralEvent.on('after-message-muted', self.deMute)

        self.setup()

        self.logger.debug("Player Commands Active!")
示例#3
0
    def __init__(self):
        super(FindFourAI, self).__init__()

        self.logger = logging.getLogger(TIMELINE_LOGGER)
        self.Bots = {}

        self.AICreatedDefer = self.setupAI()
        self.setupCommands()
        self.logger.debug("FindFour AI Active!")
        self.logger.debug("Please ensure you have dassets.swf active!")

        GeneralEvent.on('onEngine', self.attachBotToServer)
示例#4
0
    def Play4(self, client, params):
        if client['room'].ext_id is not 220:
            return

        engine = client.engine
        if engine not in self.Bots:
            return client.send('sm', client['id'],
                               "Sorry, bot is not available in this server!")

        AI = self.Bots[engine]['bot']
        if self.Bots[engine]['playing'] is not None:
            return client.send(
                'sm', AI['id'], "Sorry, am currently playing with {}".format(
                    self.Bots[engine]['playing']['nickname']))

        try:
            difficulty = int(params[0])
        except:
            difficulty = 2  # default

        if difficulty > self.Bots[engine]['difficulty'] or difficulty < 1:
            difficulty = self.Bots[engine]['difficulty']  # maximum

        client.send(
            'sm', AI['id'],
            "Let's play! Difficulty level set to {}".format(difficulty))
        sleep(3)

        client.send('sm', AI['id'], "Finding a board to play...")
        AvailableBoard = self.getFourBoard(engine)

        if AvailableBoard is None:
            return client.send('sm', AI['id'],
                               "Sorry, no boards are available to play! :(")

        self.Bots[engine]['playing'] = client
        AI.penguin.difficulty = difficulty

        GeneralEvent.on(
            'Table-Left-{}-{}'.format(client['id'], AvailableBoard.table),
            self.ClientLeft)

        client.send('zaf',
                    AvailableBoard.table)  # make sure you have dote's assets
        Event.call('JoinTable-{}'.format(AvailableBoard.table), AI,
                   AvailableBoard.table)

        AI['room'].send(
            'sm', AI['id'],
            "FindFour: {} V/S {}, difficulty: {}, started!".format(
                AI['nickname'], client['nickname'], difficulty))
        AI['game'].joinGame(AI)
示例#5
0
    def onCommand(command, protocol=AS3_PROTOCOL, function=None):
        command_ext = 'command[{}]={}'.format(protocol, command)

        commandPlugin = [i for i in PLUGIN_OBJECTS
                         if isinstance(i, Commands)][-1]
        commandPlugin.__commands__.append(
            command) if command not in commandPlugin.__commands__ else None

        return GeneralEvent.on(command_ext, function=function)
示例#6
0
 def setup(self):
     GeneralEvent.on('command=jr', self.JoinRoomByExtId)