コード例 #1
0
ファイル: items.py プロジェクト: shyba/gemuo
    def _next(self):
        client = self._client
        world = client.world

        exclude = set()

        while True:
            a = world.find_item_in(
                self.container,
                lambda i: i.serial not in exclude and i.item_id in self.ids)
            if a is None:
                self._success()
                return

            exclude.add(a.serial)

            b = world.find_item_in(
                self.container, lambda i: i.serial != a.serial and i.item_id ==
                a.item_id and i.hue == a.hue)
            if b is not None:
                break

        print "merge", a, b

        client.send(p.LiftRequest(a.serial))
        client.send(p.Drop(a.serial, 0, 0, 0, b.serial))
        reactor.callLater(1, self._next)
コード例 #2
0
ファイル: equip.py プロジェクト: jackuoll/GemUO
    def _found(self, item):
        client = self._client
        world = client.world

        client.send(p.LiftRequest(item.serial))
        client.send(p.EquipRequest(item.serial, 0x2, world.player.serial))

        reactor.callLater(1, self._success)
コード例 #3
0
ファイル: restock.py プロジェクト: uotools/GemUO
def drop_into(client, item, container, amount=0xffff):
    dest = client.world.find_item_in(
        container, lambda x: x.item_id == item.item_id and x.hue == item.hue
        and x.amount < 60000)
    if dest is None or (dest.amount == 1 and item.amount == 1):
        dest = container
    client.send(p.LiftRequest(item.serial, amount))
    client.send(p.Drop(item.serial, 0, 0, 0, dest.serial))
コード例 #4
0
ファイル: cook.py プロジェクト: jackuoll/GemUO
    def _unstack(self):
        client = self._client
        world = client.world
        stack = world.find_reachable_item(
            lambda x: x.item_id == ITEM_RAW_FISH_STEAK and x.amount >= 2)
        if stack is None:
            self._success()
            return

        client.send(p.LiftRequest(stack.serial, 1))
        client.send(
            p.Drop(stack.serial, stack.position.x, stack.position.y,
                   stack.position.z, 0))
        reactor.callLater(1, self._cook_single_steak)
コード例 #5
0
ファイル: restock.py プロジェクト: uotools/GemUO
    def _do_counts(self):
        if len(self._counts) == 0:
            self._success()
            return

        x = self._counts[0]
        item_id, count = x
        if isinstance(item_id, int):
            item_ids = (item_id, )
        else:
            item_ids = item_id
        item_ids = set(item_ids)

        client = self._client
        world = client.world

        n = 0
        for x in world.items_in(self._client.world.player):
            if x.item_id in item_ids:
                if x.amount is None:
                    n += 1
                else:
                    n += x.amount
        for x in world.items_in(self._source):
            if x.item_id in item_ids:
                if x.amount is None:
                    n += 1
                else:
                    n += x.amount

        if n > count:
            x = world.find_item_in(self._source,
                                   lambda x: x.item_id in item_ids)
            if x is None:
                self._failure(NoSuchEntity())
                return

            client.send(p.LiftRequest(x.serial, n - count))
            client.send(p.Drop(x.serial, 0, 0, 0, self._destination.serial))

            reactor.callLater(1, self._do_counts)
        elif n < count:
            d = deferred_find_item_in_recursive(
                self._client, self._destination,
                lambda x: x.item_id in item_ids)
            d.addCallback(self._found, count - n)
            d.addErrback(self._not_found, item_ids)
        else:
            self._counts = self._counts[1:]
            reactor.callLater(0, self._do_counts)