コード例 #1
0
ファイル: inventory_async.py プロジェクト: MrSwiss/SpockBot
    def drop_slot(self, slot=None, *args, **kwargs):
        # TODO drop_slot is untested
        old_slot = getattr(slot, 'slot_nr', slot)

        action_id = self.inventory.drop_slot(slot, *args, **kwargs)
        if not action_id:
            raise TaskFailed('Drop slot failed: not clicked')
        yield 'inventory_click_response', check_key('action_id', action_id)

        new_slot = self.inventory.window.slots[old_slot]
        if old_slot is not None and new_slot.amount > 0:
            raise TaskFailed('Drop slot failed: slot %i not empty' % old_slot)
コード例 #2
0
ファイル: inventory_async.py プロジェクト: MrSwiss/SpockBot
    def click_slot(self, slot, *args, **kwargs):
        if isinstance(slot, int):
            slot = self.inventory.window.slots[slot]
        old_slot = slot.copy()
        old_cursor = self.inventory.cursor_slot.copy()

        action_id = self.inventory.click_slot(slot, *args, **kwargs)
        if not action_id:
            raise TaskFailed('Click slot failed: not clicked')
        yield 'inventory_click_response', check_key('action_id', action_id)
        # TODO make sure window is not closed while clicking

        empty_cursor = old_cursor.is_empty
        if old_slot.amount == old_slot.max_amount and not empty_cursor \
                or old_slot.is_empty and empty_cursor:
            return  # no need to check

        new_slot = self.inventory.window.slots[old_slot.slot_nr]
        new_cursor = self.inventory.cursor_slot
        if new_slot.matches(old_slot) and new_cursor.matches(old_cursor):
            raise TaskFailed('Click slot failed: slot %i did not change (%s)'
                             % (old_slot.slot_nr, old_slot))