Ejemplo n.º 1
0
    def drop_slot(self, slot=None, drop_stack=False):
        old_index = getattr(slot, 'slot_nr', slot)

        action_id = self.inventory.drop_slot(slot, drop_stack)
        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_index]
        if drop_stack and old_index is not None and new_slot.amount > 0:
            raise TaskFailed('Drop slot failed: slot %i not empty' % old_index)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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))
Ejemplo n.º 5
0
    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.item.stack_size 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))