Inventory

By Chris Proctor

class quest.contrib.inventory.InventoryMixin[source]

A mixin for QuestGame which provides an inventory.

Pick up and drop behavior can be implemented in a very simple way because RemovableMixin provides most of what we need. Also creates an InventoryModal and binds a key to open it (by default, ‘i’).

inventory_shortcut

A key which should open the inventory.

inventory()[source]

A helper to return the inventory

pick_up(sprite)[source]

Removes a sprite from the game and adds it to the inventory.

drop(sprite)[source]

Removes a sprite from the inventory and adds it to the game.

Moves the sprite to the player’s position and sets its dropped_by property to the player (to make sure it doesn’t immediately get picked up).

on_key_press(key, modifier)[source]

Overrides on_key_press so that when the inventory shortcut key is pressed, opens the inventory. Otherwise, delegates to the parent on_key_press method.

class quest.contrib.inventory.InventoryItemMixin[source]

A mixin for QuestSprite which allows it to behave as an inventory item.

detailed_description

A more detailed description.

Type

str

dropped_by

Keeps track of whether the sprite was recently dropped.

Type

QuestSprite

usable

Indicates whether the item can be used.

Type

bool

on_update(game)[source]

When this sprite has recently been dropped, checks to see whether the dropped (probably the player) is still colliding. If not, sets self.dropped_by to None, indicating that the sprite can be picked up again.

on_collision(sprite, game)[source]

Causes the sprite to be picked up, unless it was just dropped.

use(game)[source]

What should happen when used. By default, kills the item.

class quest.contrib.inventory.InventoryModal(game, inventory)[source]

An extension of Modal which interaacts with inventories.

text_label_contents()[source]

Returns a list of strings to be presented as text labels.

option_label_contents()[source]

Returns a list of strings to be presented as option labels.

choose_option(value)[source]

When a button is clicked, it calls choose_option with its value.

class quest.contrib.inventory.InventoryItemModal(game, item, count)[source]

A modal for interacting with an inventory item.

text_label_contents()[source]

Returns a list of strings to be presented as text labels.

option_label_contents()[source]

Returns a list of strings to be presented as option labels.

choose_option(value)[source]

When a button is clicked, it calls choose_option with its value.