Exemplo n.º 1
0
 def update_from_action(self, game_action: GameAction):
     if game_action.is_enter_fight:
         self.set_fighting(True)
     elif game_action.is_moving:
         entity = Collection(
             self.entities).find_one(id=game_action.entity_id)
         if entity:
             entity.cell = game_action.cell
             self.update_gui()
     elif game_action.modifier:
         game_action.modifier.apply(
             Collection(
                 self.entities).find_one(id=game_action.modifier.entity))
     self.update_player_gui()
Exemplo n.º 2
0
 def _find_player(self):
     if not self.player_entity_id:
         entity = Collection(self.entities).find_one(name=self.player_name)
         if entity:
             self.player_entity_id = entity.id
             logging.info("Found Player id: {}".format(
                 self.player_entity_id))
Exemplo n.º 3
0
 def update_entities(self, entities: [Entity]):
     for e in entities:
         to_update = Collection(self.entities).find_one(id=e.id)
         if to_update:
             to_update.__dict__.update(
                 Dictionary(e.__dict__).filter_keys(
                     ['health', 'pa', 'pm', 'dead', 'cell']))
             logging.info('Update Entity {}'.format(e))
     self.update_player_gui()
Exemplo n.º 4
0
 def place_entities(self, entities: [Entity]):
     indexed_by_cell = Collection(entities).index_by('cell')
     for cell in indexed_by_cell.keys():
         if cell in indexed_by_cell and int(cell) < len(self.cells):
             self.cells[int(cell)].set_entity(indexed_by_cell[cell])
         else:
             logging.error(
                 "indexed_by_cell out of range key: {cell} obj: {indexed_by_cell}"
             )
Exemplo n.º 5
0
 def get_group_mobs(self):
     mobs = self.wait_until(
         lambda x: Collection(x.entities).find_all(type='GroupMob'),
         self.gs, 5)
     if not mobs or len(mobs) == 0:
         return None
     return list(
         filter(
             lambda m: m.cell != 0 and sum(m.levels) <= config.
             MAX_MOB_GROUP_LEVEL and not self.gs.map.cells[m.cell].isSun,
             mobs))
Exemplo n.º 6
0
    def open_new_window(self):
        windows = Window.list_windows()
        player_window = Collection(windows).find_one(
            callback=lambda x: self.player_info['name'] in x.name)
        if player_window:
            return player_window
        login_window = Collection(windows).find_one(
            name=f'Dofus Retro v{VERSION}')
        if login_window:
            return login_window

        try:
            win32api.WinExec(BINARY)
        except Exception as e:
            logging.warning(e)

        while True:
            logging.info(f'Opening new window for {self.player_info["name"]}')
            time.sleep(1)
            window = Collection(
                Window.list_windows()).find_one(name=f'Dofus Retro v{VERSION}')
            if window:
                return window
Exemplo n.º 7
0
 def find_window(self, *arg):
     if self.window:
         return True
     windows = Window.list_windows()
     w = Collection(windows).find_one(
         callback=lambda x: self.player_name in x.name)
     if w:
         self.window = w
         self.window.resize()
         self.window.focus()
         self.keyboard = Keyboard(w)
         self.eye = Eye(self.window)
         logging.info(f'Found window for {self.player_name} !')
         return True
     return False
Exemplo n.º 8
0
 def get_mob_entities(self):
     return Collection(self.entities).find_all(type='Mob')
Exemplo n.º 9
0
 def get_player_entity(self):
     entity = Collection(self.entities).find_one(
         id=self.player_entity_id) if self.player_entity_id else None
     return entity if entity else Collection(self.entities).find_one(
         name=self.player_name)
Exemplo n.º 10
0
 def set_player_ready(self, raw_data):
     entity_ready = GameFight.parse_fight_ready(raw_data)
     entity = Collection(
         self.gs.entities).find_one(id=entity_ready['entity_id'])
     entity.ready = entity_ready['ready_state']
     logging.info(f'set_player_ready: {str(entity_ready)}')