|
LI2 Roguelite
|
#include <stdio.h>#include <stdlib.h>#include <ncurses.h>#include "state.h"#include "player.h"#include "inventory.h"#include "item.h"#include "combat.h"#include "map.h"#include "menu.h"
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... | |
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 |