Exemplo n.º 1
0
    def target_items_in_room(self, user_input, input_kwargs):

        # check if the target is an item in the room
        target = None

        for y in Gen.items_in_room(self):

            if Lex.first_three(y.keyword) in user_input:
                target = y
                print("HANDLER | Target Found: item in room, ", target)

        return target
Exemplo n.º 2
0
    def get_item(self, user_input, input_kwargs):

        all_ok = False
        obj_generator = False

        if input_kwargs['target'] in Gen.items_in_room(self):

            print(input_kwargs['target'], input_kwargs['target'].attributes)

            if "obj_generator" in input_kwargs['target'].attributes:
                print("obj_gen")
            else:
                rooms[input_kwargs['target'].location].item_inv.remove(input_kwargs['target'])

            all_ok = True

        elif input_kwargs['target_parent'] is not None:

            container = items[input_kwargs['target_parent'].uuid_id]
            items[input_kwargs['target_parent'].uuid_id].item_inv.remove(input_kwargs['target'])

            all_ok = True

        elif input_kwargs['target'] == self.inventory['r_hand']['contents'] or input_kwargs['target'] == self.inventory['l_hand']['contents']:
            WsWrap.ws_send(self.client, {'type': 'text', 'spacing': 1}, "You already have that.")

        if all_ok == True:

            if self.inventory['r_hand']['contents'] == None:
                hand = self.inventory['r_hand']
                input_kwargs['target'].location = self.uuid_id
                input_kwargs['target'].location_body['location'] = "r_hand"
                self.inventory['r_hand']['contents'] = input_kwargs['target']
                Update_Client.update_player_inventory(self)

            elif self.inventory['l_hand']['contents'] == None:
                hand = self.inventory['l_hand']
                input_kwargs['target'].location = self.uuid_id
                input_kwargs['target'].location_body['location'] = "l_hand"
                self.inventory['l_hand']['contents'] = input_kwargs['target']
                Update_Client.update_player_inventory(self)

        if input_kwargs['target_parent'] is not None:

            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You pull {} out from inside of {}.".format(Lex.a_an(input_kwargs['target'].name), Lex.a_an(container.name)),
                target_person = "",
                third_person = "{} pulls {} from inside of {}.".format(self.name, Lex.a_an(input_kwargs['target'].name), Lex.a_an(container.name)))

        else:

            Lex.pub_print(
                self=self,
                target=None,
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You pickup {} in your {}.".format(Lex.a_an(input_kwargs['target'].name), hand['name']),
                target_person = "",
                third_person = "{} picks up {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))