Beispiel #1
0
    def do_exchange(self, args):
        """Exchange an Item with another with an NPC. EXCHANGE goblin potion bandage
        <means give potion to goblin and take bandage from him>"""
        args = parse(args)
        if not self.check_length(args, 3):
            return

        item_holder = NPC.get_or_none(NPC.name == args[0])
        item_to_give = Item.get_or_none(Item.name == args[1])
        item_to_take = Item.get_or_none(Item.name == args[2])

        if not self.set_inputs(action=T.exchange,
                               args=[item_holder, item_to_give, item_to_take]):
            return

        found = terminals.exchange(item_holder=item_holder,
                                   item_to_give=item_to_give,
                                   item_to_take=item_to_take)
        if not found:
            print("failed!")
            return
        print("player's belongings updated.")
        print_player_belongings()
        print("NPC belongings updated.")
        print_npc_belongings(item_holder)
        self.last_action_doable = True
def capture_1(target: NPC):
    """
    Get something, go someplace and use it to capture somebody
    :param target:
    :return:
    """
    item_to_fetch = Item.get_or_none(type=ItemTypes.tool.name,
                                     usage=T.capture.value)
    if not item_to_fetch:
        # No item usable for capture, left in the world
        item_to_fetch = Item.create(
            name='arbitrary_capture_tool_' + str(randint(100, 999)),
            type=ItemTypes.tool.name,
            usage=T.capture.value,
            generic=GenericItem.get_or_create(
                name=ItemTypes.singleton.name)[0],
            place=Place.select().order_by(fn.Random()).get(),
            impact_factor=1.0,
            worth=0.75)
        Message.debug(
            "No item usable for 'capture' left in the world, create a new one '%s'"
            % item_to_fetch)

    # steps:
    # get
    # goto
    # T.capture
    steps = [[item_to_fetch], [target.place, target], [target]]
    Message.instruction("Get '%s', then goto '%s' and capture '%s'" %
                        (item_to_fetch, target, target))
    return steps
Beispiel #3
0
    def do_take(self, args):
        """Take something from an NPC. TAKE bandage Goblin"""
        args = parse(args)
        if not self.check_length(args, 2):
            return

        item = Item.get_or_none(Item.name == args[0])
        npc = NPC.get_or_none(NPC.name == args[1])
        dead = NPCDead.get_or_none(NPCDead.name == args[1])

        if not npc and dead:
            # npc is dead, loot him
            if not self.set_inputs(action=T.take, args=[item]):
                return
            found = terminals.take_loot(item_to_take=item, loot_npc=dead)
        else:
            # npc is alive, or not found among dead, can't loot
            if not self.set_inputs(action=T.take, args=[item, npc]):
                return
            found = terminals.take(item_to_take=item, item_holder=npc)

        if not found:
            print("failed!")
            return

        print("player's belongings updated.")
        print_player_belongings()
        print("NPC belongings updated.")
        print_npc_belongings(npc)
        self.last_action_doable = True
Beispiel #4
0
    def do_use(self, args):
        """Use an item (tool) on an NPC. USE potion Lempeck"""
        args = parse(args)
        if not self.check_length(args, 2):
            return

        item = Item.get_or_none(Item.name == args[0])
        npc = NPC.get_or_none(NPC.name == args[1])

        if not self.set_inputs(action=T.use, args=[item, npc]):
            return

        found = terminals.use(item_to_use=item, target=npc)
        if not found:
            print("failed!")
            return
        print("NPC health meter:", npc.health_meter)
        self.last_action_doable = True
Beispiel #5
0
    def do_gather(self, args):
        """Gather an item. GATHER bandage"""
        args = parse(args)
        if not self.check_length(args, 1):
            return

        item = Item.get_or_none(Item.name == args[0])

        if not self.set_inputs(action=T.gather, args=[item]):
            return

        found = terminals.gather(item_to_gather=item)
        if not found:
            print("failed!")
            return
        print("player's belongings updated.")
        print_player_belongings()
        self.last_action_doable = True
Beispiel #6
0
    def do_read(self, args):
        """Read a piece of intel from a book (intel: type intel_value). READ location goblin_place address_book"""
        args = parse(args)
        if not self.check_length(args, 3):
            return

        intel = Intel.find_by_name(args[0], [args[1]])
        readable = Item.get_or_none(Item.name == args[2])

        if not self.set_inputs(action=T.read, args=[intel, readable]):
            return

        found = terminals.read(intel=intel, readable=readable)
        if not found:
            print("failed!")
            return
        print("Player intel updated.")
        print_player_intel()
        self.last_action_doable = True
Beispiel #7
0
    def do_give(self, args):
        """Give an NPC something. GIVE bandage Goblin"""
        args = parse(args)
        if not self.check_length(args, 2):
            return

        item = Item.get_or_none(Item.name == args[0])
        npc = NPC.get_or_none(NPC.name == args[1])

        if not self.set_inputs(action=T.give, args=[item, npc]):
            return

        found = terminals.give(item=item, receiver=npc)
        if not found:
            print("failed!")
            return
        print("player's belongings updated.")
        print_player_belongings()
        print("NPC belongings updated.")
        print_npc_belongings(npc)
        self.last_action_doable = True
Beispiel #8
0
    def do_explore(self, args):
        """Explore current location to find an NPC or Item. EXPLORE item potion | EXPLORE npc goblin"""
        args = parse(args)
        if not self.check_length(args, 2):
            return

        dest = Player.current().place
        if args[0] == 'item':
            item = Item.get_or_none(Item.name == args[1])
            if not self.set_inputs(action=T.explore, args=[dest, '', item]):
                return
            found = terminals.explore(area_location=dest, item=item)
        else:
            npc = NPC.get_or_none(NPC.name == args[1])

            if not self.set_inputs(action=T.explore, args=[dest, npc, '']):
                return
            found = terminals.explore(area_location=dest, npc=npc)

        if not found:
            print("failed!")
            return

        self.last_action_doable = True