Player¶
Inventory¶
Inventory
-
class
Inventory(items: Tuple[crafting.world.items.Item])¶ Bases:
objectInventory is where Items are stored
-
items¶ All items that could be added to this inventory.
- Type
tuple of
Item
-
items_ids¶ All items_ids that could be added to this inventory.
- Type
tuple of int
-
items_max_stack¶ Max number of item per stack for each item.
- Type
tuple of int
-
content¶ Array of number of contained items in the inventory.
- Type
np.ndarray
-
item_id_to_slot¶ Function mapping item_ids to slot_index in content.
- Type
func
-
stacks_ind_and_size(stacks)¶
-
add_stacks(stacks: List[crafting.world.items.ItemStack]) → bool¶ Add a list of ItemStack into the inventory content
- Parameters
stacks – ItemStacks to add.
- Returns
True if successful, False otherwise.
-
remove_stacks(stacks: List[crafting.world.items.ItemStack]) → bool¶ Remove a list of ItemStack from the inventory content
- Parameters
stacks – ItemStacks to remove.
- Returns
True if successful, False otherwise.
- Raises
ValueError – If content does not have enough to remove.
-
Player¶
Player
-
class
Player(inventory: crafting.player.inventory.Inventory, zone: crafting.world.zones.Zone, name: str = 'Player')¶ Bases:
objectPlayer are entities with an inventory positioned in a zone.
-
inventory¶ Player inventory.
- Type
Inventory
-
zone¶ Player zone.
- Type
Zone
-
craft(recipe: crafting.world.recipes.Recipe) → bool¶ Use a recipe
- Parameters
recipe – The recipe to use.
- Returns
True if succeded, False otherwise.
-
can_craft(recipe: crafting.world.recipes.Recipe) → bool¶ Check if the recipe can be performed
- Parameters
recipe – Recipe to be tested.
- Returns
True if the recipe can be used, False otherwise.
-
choose_tool(item: crafting.world.items.Item) → crafting.world.items.Tool¶ Choose a tool to search for an item.
- Parameters
item – The item to search for.
- Returns
The chosen tool.
-
search_for(item: crafting.world.items.Item, tool: crafting.world.items.Tool) → int¶ Search for an item using a tool and add them to inventory.
- Parameters
item – The item to look for.
tool – The tool to use to search.
- Returns
Number of items found.
-
can_get(item: crafting.world.items.Item, tool: crafting.world.items.Tool) → bool¶ Check if the item can be found
- Parameters
item – The item to look for.
- Returns
True if the item can be found, False otherwise.
-
move_to(zone: crafting.world.zones.Zone) → bool¶ Move to a given new zone
- Parameters
zone – The zone to move to.
- Returns
True if succeded, False otherwise.
-
can_move_to(zone: crafting.world.zones.Zone) → bool¶ Check if the player can move to the zone
- Parameters
zone – The zone we want to access.
- Returns
True if the zone can be accessed, False otherwise.
-