|
LI2 Roguelite
|

Go to the source code of this file.
Classes | |
| struct | inventory |
| Inventory structure represents the player inventory. More... | |
Macros | |
| #define | INVENTORY_SIZE 10 |
Typedefs | |
| typedef struct item | Item |
| typedef struct state | State |
| typedef struct inventory | Inventory |
| Inventory structure represents the player inventory. More... | |
Functions | |
| Inventory * | initInventory () |
| Initializes a new inventory. Allocates memory for a new inventory and initializes its fields. More... | |
| void | addItem (Inventory *i, Item *item) |
| Adds an item to the inventory. More... | |
| void | removeItem (Inventory *i, Item *item) |
| Removes an item from the inventory. More... | |
| void | sellEquippedItem (State *st, Inventory *i) |
| Sells the equipped item. More... | |
| void | switchEquippedItem (Inventory *i) |
| Switches the equipped item on a inventory. More... | |
| void | freeInventory (void *p) |
| Frees the memory allocated for an inventory. More... | |
| void | useEquippedItem (State *st) |
| Uses the equipped item. More... | |
| #define INVENTORY_SIZE 10 |
Inventory structure represents the player inventory.
This struct represents the player inventory. It contains the items the player has picked up, the equipped item and is index in the inventory, and the amount of gold.
| items | the items in the inventory |
| nr_items | the number of items in the inventory |
| equipped_item | the equipped item |
| equiped_index | the index of the equipped item |
| equipped_sword | the equipped sword |
| equipped_armor | the equipped armor |
| gold | the amount of gold in the inventory |
Adds an item to the inventory.
Adds an item to the inventory. If the inventory is full, the item is not added. If the item is a rock, the number of rocks is increased. // free item
| i | Inventory to add item to |
| item | Item to add |
| void freeInventory | ( | void * | p | ) |
Frees the memory allocated for an inventory.
Frees the memory allocated for an inventory.
| p | Inventory to free |
| Inventory* initInventory | ( | ) |
Initializes a new inventory. Allocates memory for a new inventory and initializes its fields.
Removes an item from the inventory.
Removes an item from the inventory. If the item is not in the inventory, nothing happens.
| i | Inventory to remove item from |
| item | Item to remove |
Sells the equipped item.
Sells the equipped item. If the equipped item is NULL, nothing happens.
| i | Inventory to sell equipped item |
| st | State to send menu message (Other option send msg before calling this function) |
| void switchEquippedItem | ( | Inventory * | i | ) |
Switches the equipped item on a inventory.
Switches the equipped item on a inventory. If there is no possible equipable item, nothing happens.
| i | Inventory to switch equipped item |
| void useEquippedItem | ( | State * | st | ) |
Uses the equipped item.
Uses the equipped item. If the equipped item is a potion of healing, the player's health is increased. Receives a State struct as argument because needs to update the player, the map and game stats.
| st | State to use the equipped item |