pygamelib.board_items.Treasure¶
-
class
pygamelib.board_items.
Treasure
(**kwargs)¶ A Treasure is an
Immovable
that is pickable and with a non zero value. It is an helper class that allows to focus on game design and mechanics instead of small building blocks.Parameters: - model (str) – The model that will represent the treasure on the map
- value (int) – The value of the treasure, it is usually used to calculate the score.
- inventory_space (int) – The space occupied by the treasure. It is used by
Inventory
as a measure of space. If the treasure’s size exceed the Inventory size (or the cumulated size of all items + the treasure exceed the inventory max_size()) theInventory
will refuse to add the treasure.
Note
All the options from
Immovable
are also available to this constructor.Example:
money_bag = Treasure(model=Sprites.MONEY_BAG,value=100,inventory_space=2) print(f"This is a money bag {money_bag}") player.inventory.add_item(money_bag) print(f"The inventory value is {player.inventory.value()} and is at {player.inventory.size()}/{player.inventory.max_size}")
-
__init__
(**kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(**kwargs)Initialize self. can_move
()Return the capability of moving of an item. collides_with
(other)Tells if this item collides with another item. column
Convenience method to get the current stored column of the item. debug_info
()Return a string with the list of the attributes and their current value. display
()Print the model WITHOUT carriage return. distance_to
(other)Calculates the distance with an item. height
Convenience method to get the height of the item. inventory_space
()Return the size of the Immovable Item for the Inventory
.overlappable
()This represent the capacity for a Treasure to be overlapped by player or NPC. pickable
()This represent the capacity for a Treasure to be picked-up by player or NPC. position_as_vector
()Returns the current item position as a Vector2D restorable
()This represent the capacity for a Treasure to be restored after being overlapped. row
Convenience method to get the current stored row of the item. store_position
(row, column)Store the BoardItem position for self access. width
Convenience method to get the width of the item.