Пример #1
0
 def take_item(self, item: Item) -> None:
     if item not in self.items:
         if not item.immovable:
             print(f'{item.description}: Taken.')
             self.items.append(item)
             item.move(
                 "player",
                 True if self.location.name == item.locations[1] else False)
         else:
             print(f'The {item.name} is fixed in place.')
     else:
         print(f'You are already carrying the {item.name}.')
Пример #2
0
    def parse_object(self, content):

        return Item(property_1=self.get_property_1(content),
                    property_2=self.get_property_2(content),
                    property_3=self.get_property_3(content),
                    property_4=self.get_property_4(content),
                    property_5=self.get_property_5(content))
Пример #3
0
    def parse_object(self, content):

        return Item(title=self.get_title(content),
                    price=self.get_price(content),
                    transmission=self.get_transmission(content),
                    motor=self.get_motor(content),
                    locationofengine=self.get_locationofengine(content))
Пример #4
0
 def parse_object(self, content):
     tree = html.fromstring(content)
     answer = []
     length = len(
         tree.xpath(
             '//*[@id="main_table_countries_today"]/tbody[1]/text()'))
     for idx in range(9, length):
         item = Item(property_1=self.get_property_1(tree, idx),
                     property_2=self.get_property_2(tree, idx),
                     property_3=self.get_property_3(tree, idx),
                     property_4=self.get_property_4(tree, idx),
                     property_5=self.get_property_5(tree, idx))
         if not item.property_1 == " ":
             answer.append(item)
     return answer
Пример #5
0
    def setUp(self) -> None:
        """
        Sets up the game by creating locations dictionary, items dictionary, player
        :return:
        """

        # Create item objects and assign add the item to its location
        global objects
        _location_objects = {}

        # Create objects instances dictionary
        for key, value in objects_dict.items():
            initial_location = initial_object_locations[key]
            item = Item(value[0], key, value[1], value[2], initial_location)

            # Now update the location_objects. This is for performance,
            # so that locations can easily populate their initial objects.
            objects[key] = item
            _location_objects.setdefault(initial_location[0], {})[key] = item
            if initial_location[1] != 0:
                _location_objects.setdefault(initial_location[1],
                                             {})[key] = item

        # Create location objects
        global locations
        for name, desc in location.long_descriptions.items():
            short_desc = location.short_descriptions.get(name, None)

            index = next(
                (k for k, v in location.location_lookup.items() if v == name),
                None)
            loc = location.Location(index, name, desc, short_desc,
                                    _location_objects.get(name, {}))
            locations[name] = loc

            # Build up a dictionary of destinations for each location
            for dir, dest in travel_table[name].items():
                locations[name].add_destination(dir, dest)

        del _location_objects

        self.dwarves = []
        for loc, is_pirate in dwarves_info:
            d = Dwarf(loc, is_pirate)
            self.dwarves.append(d)

        self.player = Player()
Пример #6
0
    def parse_object(self, content):
        tree = html.fromstring(content)
        table = tree.xpath('/html/body/div[3]/div[2]/div[4]/div[2]/div[1]/div/div[3]/div/table/text()')

        answer = []

        for idx in range(3,len(table)):
            result = self.get_result(tree, idx)
            item = Item(
                date=self.get_date(tree, idx),
                time=self.get_time(tree, idx),
                place=self.get_place(tree, idx),
                teamName=self.get_teamName(tree, idx),
                scored=result[0],
                missed=result[1]
            )
            if item.teamName == ' ' or item.scored == ' ':
                continue
            answer.append(item)

        return answer
Пример #7
0
 def drop_item(self, item: Item) -> None:
     print(f'{item.name}: Dropped/ Released.')
     self.items.remove(item)
     item.move(self.location.name)