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)
def handleJoinToTable(client, data): table = int(data[2][0]) if client['playing'] or client['waddling']: client.send('e', 200) if isinstance(client['room'], Game): client['room'].remove(client) for room in client['prevRooms'][::-1]: if isinstance(room, Place): room.append(client) break return Event('Leave-Waddling', client) Event('JoinTable-{}'.format(table), client, table)
def unsetEventInModule(self, name): Event.unsetEventInModule(name) PacketEventHandler.unsetEventInModule(name) GeneralEvent.unsetEventInModule(name)
def unsetEventsInModulesAndSubModules(self, name): Event.unsetEventsInModulesAndSubModules(name) PacketEventHandler.unsetEventsInModulesAndSubModules(name) GeneralEvent.unsetEventsInModulesAndSubModules(name)
def handleLeave(client, data): if client['game'] is None: return table = client['game'].table Event('LeaveTable-{}'.format(table), client, table)