LI2 Roguelite
Classes | Macros | Typedefs | Functions
item.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  item
 Item structure represents an item in the game. More...
 

Macros

#define MAX_ITEMS   100
 
#define MAX_ITEM_NAME   20
 
#define WEAPON   0
 
#define PROJECTILE   1
 
#define ARMOR   2
 
#define POTION   3
 
#define GOLD   4
 
#define ROCK_VALUE   1
 
#define ROCK_DAMAGE_MIN   5
 
#define ROCK_DAMAGE_MAX   7
 
#define ROCK_SYMBOL   ':'
 
#define ROCK_TYPE   PROJECTILE
 
#define ROCK_RANGE   7
 
#define ROCK_COLOR   COLOR_CYAN
 
#define SMOKE_BOMB_VALUE   30
 
#define SMOKE_BOMB_DAMAGE_MIN   10
 
#define SMOKE_BOMB_DAMAGE_MAX   20
 
#define SMOKE_BOMB_SYMBOL   '*'
 
#define SMOKE_BOMB_TYPE   PROJECTILE
 
#define SMOKE_BOMB_RANGE   5
 
#define SMOKE_BOMB_COLOR   COLOR_WHITE
 
#define SMOKE_BOMB_EFFECT   1
 
#define SMOKE_BOMB_DURATION   5
 
#define FIRE_BOMB_VALUE   50
 
#define FIRE_BOMB_DAMAGE_MIN   15
 
#define FIRE_BOMB_DAMAGE_MAX   25
 
#define FIRE_BOMB_SYMBOL   '*'
 
#define FIRE_BOMB_TYPE   PROJECTILE
 
#define FIRE_BOMB_RANGE   6
 
#define FIRE_BOMB_COLOR   COLOR_RED
 
#define FIRE_BOMB_EFFECT   2
 
#define FIRE_BOMB_EFFECT_DAMAGE   7
 
#define FIRE_BOMB_DURATION   5
 
#define ICE_BOMB_VALUE   70
 
#define ICE_BOMB_DAMAGE_MIN   20
 
#define ICE_BOMB_DAMAGE_MAX   30
 
#define ICE_BOMB_SYMBOL   '*'
 
#define ICE_BOMB_TYPE   PROJECTILE
 
#define ICE_BOMB_RANGE   7
 
#define ICE_BOMB_COLOR   COLOR_CYAN
 
#define ICE_BOMB_EFFECT   3
 
#define ICE_BOMB_DURATION   7
 
#define IRON_SWORD_VALUE   20
 
#define IRON_SWORD_DAMAGE_MIN   10
 
#define IRON_SWORD_DAMAGE_MAX   20
 
#define IRON_SWORD_SYMBOL   'l'
 
#define IRON_SWORD_TYPE   WEAPON
 
#define IRON_SWORD_COLOR   COLOR_WHITE
 
#define GOLD_SWORD_VALUE   40
 
#define GOLD_SWORD_DAMAGE_MIN   20
 
#define GOLD_SWORD_DAMAGE_MAX   30
 
#define GOLD_SWORD_SYMBOL   'l'
 
#define GOLD_SWORD_TYPE   WEAPON
 
#define GOLD_SWORD_COLOR   COLOR_YELLOW
 
#define DIAMOND_SWORD_VALUE   60
 
#define DIAMOND_SWORD_DAMAGE_MIN   30
 
#define DIAMOND_SWORD_DAMAGE_MAX   40
 
#define DIAMOND_SWORD_SYMBOL   'l'
 
#define DIAMOND_SWORD_TYPE   WEAPON
 
#define DIAMOND_SWORD_COLOR   COLOR_CYAN
 
#define LEATHER_ARMOR_VALUE   20
 
#define LEATHER_ARMOR_DEFENSE   20
 
#define LEATHER_ARMOR_SYMBOL   'T'
 
#define LEATHER_ARMOR_TYPE   ARMOR
 
#define LEATHER_ARMOR_COLOR   COLOR_WHITE
 
#define CHAINMAIL_ARMOR_VALUE   40
 
#define CHAINMAIL_ARMOR_DEFENSE   40
 
#define CHAINMAIL_ARMOR_SYMBOL   'T'
 
#define CHAINMAIL_ARMOR_TYPE   ARMOR
 
#define CHAINMAIL_ARMOR_COLOR   COLOR_GREEN
 
#define PLATE_ARMOR_VALUE   60
 
#define PLATE_ARMOR_DEFENSE   60
 
#define PLATE_ARMOR_SYMBOL   'T'
 
#define PLATE_ARMOR_TYPE   ARMOR
 
#define PLATE_ARMOR_COLOR   COLOR_MAGENTA
 
#define POTION_OF_HEALING_SYMBOL   '!'
 
#define POTION_OF_HEALING_TYPE   POTION
 
#define POTION_OF_HEALING_VALUE   20
 
#define POTION_OF_HEALING_HP   50
 
#define POTION_OF_HEALING_COLOR   COLOR_MAGENTA
 
#define SENSORY_POTION_SYMBOL   '!'
 
#define SENSORY_POTION_TYPE   POTION
 
#define SENSORY_POTION_VALUE   50
 
#define SENSORY_POTION_VISION_RANGE   10
 
#define SENSORY_POTION_VISION_WIDTH   2
 
#define SENSORY_POTION_EARING_RANGE   20
 
#define SENSORY_POTION_EARING_PROB   60
 
#define SENSORY_POTION_TURNS   60
 
#define SENSORY_POTION_RANGE   10
 
#define SENSORY_POTION_COLOR   COLOR_BLUE
 
#define POTION_OF_INVINCIBILITY_SYMBOL   '!'
 
#define POTION_OF_INVINCIBILITY_TYPE   POTION
 
#define POTION_OF_INVINCIBILITY_VALUE   100
 
#define POTION_OF_INVINCIBILITY_TURNS   40
 
#define POTION_OF_INVINCIBILITY_DEFENSE   100
 
#define POTION_OF_INVINCIBILITY_COLOR   COLOR_GREEN
 
#define POT_OF_GOLD_SYMBOL   'O'
 
#define POT_OF_GOLD_TYPE   GOLD
 
#define POT_OF_GOLD_VALUE_MIN   1
 
#define POT_OF_GOLD_VALUE_MAX   10
 
#define POT_OF_GOLD_COLOR   COLOR_YELLOW
 

Typedefs

typedef struct map Map
 
typedef struct item Item
 Item structure represents an item in the game. More...
 

Functions

Item ** generateItems (int n)
 Generate n random items. More...
 
void drawAllItems (Item **items, int n)
 Draw all items in the Map. More...
 
void drawVisibleItems (Map *map, Item **items, int n)
 Draw all visible items in the Map. More...
 
ItemgetItem (Item **items, int nr_items, unsigned int x, unsigned int y)
 Get item at (x, y) in the map, also removes it from the array. More...
 
int insertItem (Item **items, int nr_items, Item *item)
 insert item into the items array (inventory) More...
 
void freeItem (void *i)
 Free an item. More...
 

Macro Definition Documentation

◆ ARMOR

#define ARMOR   2

◆ CHAINMAIL_ARMOR_COLOR

#define CHAINMAIL_ARMOR_COLOR   COLOR_GREEN

◆ CHAINMAIL_ARMOR_DEFENSE

#define CHAINMAIL_ARMOR_DEFENSE   40

◆ CHAINMAIL_ARMOR_SYMBOL

#define CHAINMAIL_ARMOR_SYMBOL   'T'

◆ CHAINMAIL_ARMOR_TYPE

#define CHAINMAIL_ARMOR_TYPE   ARMOR

◆ CHAINMAIL_ARMOR_VALUE

#define CHAINMAIL_ARMOR_VALUE   40

◆ DIAMOND_SWORD_COLOR

#define DIAMOND_SWORD_COLOR   COLOR_CYAN

◆ DIAMOND_SWORD_DAMAGE_MAX

#define DIAMOND_SWORD_DAMAGE_MAX   40

◆ DIAMOND_SWORD_DAMAGE_MIN

#define DIAMOND_SWORD_DAMAGE_MIN   30

◆ DIAMOND_SWORD_SYMBOL

#define DIAMOND_SWORD_SYMBOL   'l'

◆ DIAMOND_SWORD_TYPE

#define DIAMOND_SWORD_TYPE   WEAPON

◆ DIAMOND_SWORD_VALUE

#define DIAMOND_SWORD_VALUE   60

◆ FIRE_BOMB_COLOR

#define FIRE_BOMB_COLOR   COLOR_RED

◆ FIRE_BOMB_DAMAGE_MAX

#define FIRE_BOMB_DAMAGE_MAX   25

◆ FIRE_BOMB_DAMAGE_MIN

#define FIRE_BOMB_DAMAGE_MIN   15

◆ FIRE_BOMB_DURATION

#define FIRE_BOMB_DURATION   5

◆ FIRE_BOMB_EFFECT

#define FIRE_BOMB_EFFECT   2

◆ FIRE_BOMB_EFFECT_DAMAGE

#define FIRE_BOMB_EFFECT_DAMAGE   7

◆ FIRE_BOMB_RANGE

#define FIRE_BOMB_RANGE   6

◆ FIRE_BOMB_SYMBOL

#define FIRE_BOMB_SYMBOL   '*'

◆ FIRE_BOMB_TYPE

#define FIRE_BOMB_TYPE   PROJECTILE

◆ FIRE_BOMB_VALUE

#define FIRE_BOMB_VALUE   50

◆ GOLD

#define GOLD   4

◆ GOLD_SWORD_COLOR

#define GOLD_SWORD_COLOR   COLOR_YELLOW

◆ GOLD_SWORD_DAMAGE_MAX

#define GOLD_SWORD_DAMAGE_MAX   30

◆ GOLD_SWORD_DAMAGE_MIN

#define GOLD_SWORD_DAMAGE_MIN   20

◆ GOLD_SWORD_SYMBOL

#define GOLD_SWORD_SYMBOL   'l'

◆ GOLD_SWORD_TYPE

#define GOLD_SWORD_TYPE   WEAPON

◆ GOLD_SWORD_VALUE

#define GOLD_SWORD_VALUE   40

◆ ICE_BOMB_COLOR

#define ICE_BOMB_COLOR   COLOR_CYAN

◆ ICE_BOMB_DAMAGE_MAX

#define ICE_BOMB_DAMAGE_MAX   30

◆ ICE_BOMB_DAMAGE_MIN

#define ICE_BOMB_DAMAGE_MIN   20

◆ ICE_BOMB_DURATION

#define ICE_BOMB_DURATION   7

◆ ICE_BOMB_EFFECT

#define ICE_BOMB_EFFECT   3

◆ ICE_BOMB_RANGE

#define ICE_BOMB_RANGE   7

◆ ICE_BOMB_SYMBOL

#define ICE_BOMB_SYMBOL   '*'

◆ ICE_BOMB_TYPE

#define ICE_BOMB_TYPE   PROJECTILE

◆ ICE_BOMB_VALUE

#define ICE_BOMB_VALUE   70

◆ IRON_SWORD_COLOR

#define IRON_SWORD_COLOR   COLOR_WHITE

◆ IRON_SWORD_DAMAGE_MAX

#define IRON_SWORD_DAMAGE_MAX   20

◆ IRON_SWORD_DAMAGE_MIN

#define IRON_SWORD_DAMAGE_MIN   10

◆ IRON_SWORD_SYMBOL

#define IRON_SWORD_SYMBOL   'l'

◆ IRON_SWORD_TYPE

#define IRON_SWORD_TYPE   WEAPON

◆ IRON_SWORD_VALUE

#define IRON_SWORD_VALUE   20

◆ LEATHER_ARMOR_COLOR

#define LEATHER_ARMOR_COLOR   COLOR_WHITE

◆ LEATHER_ARMOR_DEFENSE

#define LEATHER_ARMOR_DEFENSE   20

◆ LEATHER_ARMOR_SYMBOL

#define LEATHER_ARMOR_SYMBOL   'T'

◆ LEATHER_ARMOR_TYPE

#define LEATHER_ARMOR_TYPE   ARMOR

◆ LEATHER_ARMOR_VALUE

#define LEATHER_ARMOR_VALUE   20

◆ MAX_ITEM_NAME

#define MAX_ITEM_NAME   20

◆ MAX_ITEMS

#define MAX_ITEMS   100

◆ PLATE_ARMOR_COLOR

#define PLATE_ARMOR_COLOR   COLOR_MAGENTA

◆ PLATE_ARMOR_DEFENSE

#define PLATE_ARMOR_DEFENSE   60

◆ PLATE_ARMOR_SYMBOL

#define PLATE_ARMOR_SYMBOL   'T'

◆ PLATE_ARMOR_TYPE

#define PLATE_ARMOR_TYPE   ARMOR

◆ PLATE_ARMOR_VALUE

#define PLATE_ARMOR_VALUE   60

◆ POT_OF_GOLD_COLOR

#define POT_OF_GOLD_COLOR   COLOR_YELLOW

◆ POT_OF_GOLD_SYMBOL

#define POT_OF_GOLD_SYMBOL   'O'

◆ POT_OF_GOLD_TYPE

#define POT_OF_GOLD_TYPE   GOLD

◆ POT_OF_GOLD_VALUE_MAX

#define POT_OF_GOLD_VALUE_MAX   10

◆ POT_OF_GOLD_VALUE_MIN

#define POT_OF_GOLD_VALUE_MIN   1

◆ POTION

#define POTION   3

◆ POTION_OF_HEALING_COLOR

#define POTION_OF_HEALING_COLOR   COLOR_MAGENTA

◆ POTION_OF_HEALING_HP

#define POTION_OF_HEALING_HP   50

◆ POTION_OF_HEALING_SYMBOL

#define POTION_OF_HEALING_SYMBOL   '!'

◆ POTION_OF_HEALING_TYPE

#define POTION_OF_HEALING_TYPE   POTION

◆ POTION_OF_HEALING_VALUE

#define POTION_OF_HEALING_VALUE   20

◆ POTION_OF_INVINCIBILITY_COLOR

#define POTION_OF_INVINCIBILITY_COLOR   COLOR_GREEN

◆ POTION_OF_INVINCIBILITY_DEFENSE

#define POTION_OF_INVINCIBILITY_DEFENSE   100

◆ POTION_OF_INVINCIBILITY_SYMBOL

#define POTION_OF_INVINCIBILITY_SYMBOL   '!'

◆ POTION_OF_INVINCIBILITY_TURNS

#define POTION_OF_INVINCIBILITY_TURNS   40

◆ POTION_OF_INVINCIBILITY_TYPE

#define POTION_OF_INVINCIBILITY_TYPE   POTION

◆ POTION_OF_INVINCIBILITY_VALUE

#define POTION_OF_INVINCIBILITY_VALUE   100

◆ PROJECTILE

#define PROJECTILE   1

◆ ROCK_COLOR

#define ROCK_COLOR   COLOR_CYAN

◆ ROCK_DAMAGE_MAX

#define ROCK_DAMAGE_MAX   7

◆ ROCK_DAMAGE_MIN

#define ROCK_DAMAGE_MIN   5

◆ ROCK_RANGE

#define ROCK_RANGE   7

◆ ROCK_SYMBOL

#define ROCK_SYMBOL   ':'

◆ ROCK_TYPE

#define ROCK_TYPE   PROJECTILE

◆ ROCK_VALUE

#define ROCK_VALUE   1

◆ SENSORY_POTION_COLOR

#define SENSORY_POTION_COLOR   COLOR_BLUE

◆ SENSORY_POTION_EARING_PROB

#define SENSORY_POTION_EARING_PROB   60

◆ SENSORY_POTION_EARING_RANGE

#define SENSORY_POTION_EARING_RANGE   20

◆ SENSORY_POTION_RANGE

#define SENSORY_POTION_RANGE   10

◆ SENSORY_POTION_SYMBOL

#define SENSORY_POTION_SYMBOL   '!'

◆ SENSORY_POTION_TURNS

#define SENSORY_POTION_TURNS   60

◆ SENSORY_POTION_TYPE

#define SENSORY_POTION_TYPE   POTION

◆ SENSORY_POTION_VALUE

#define SENSORY_POTION_VALUE   50

◆ SENSORY_POTION_VISION_RANGE

#define SENSORY_POTION_VISION_RANGE   10

◆ SENSORY_POTION_VISION_WIDTH

#define SENSORY_POTION_VISION_WIDTH   2

◆ SMOKE_BOMB_COLOR

#define SMOKE_BOMB_COLOR   COLOR_WHITE

◆ SMOKE_BOMB_DAMAGE_MAX

#define SMOKE_BOMB_DAMAGE_MAX   20

◆ SMOKE_BOMB_DAMAGE_MIN

#define SMOKE_BOMB_DAMAGE_MIN   10

◆ SMOKE_BOMB_DURATION

#define SMOKE_BOMB_DURATION   5

◆ SMOKE_BOMB_EFFECT

#define SMOKE_BOMB_EFFECT   1

◆ SMOKE_BOMB_RANGE

#define SMOKE_BOMB_RANGE   5

◆ SMOKE_BOMB_SYMBOL

#define SMOKE_BOMB_SYMBOL   '*'

◆ SMOKE_BOMB_TYPE

#define SMOKE_BOMB_TYPE   PROJECTILE

◆ SMOKE_BOMB_VALUE

#define SMOKE_BOMB_VALUE   30

◆ WEAPON

#define WEAPON   0

Typedef Documentation

◆ Item

typedef struct item Item

Item structure represents an item in the game.

This struct represents an item in the game. It can be a weapon, armor, potion or gold. Items are drawn in the map if the cell is visible. They are picked up by the player when he steps on them. And they are added to the player inventory.

Parameters
namethe name of the item
symbolthe symbol that represents the item
typethe type of item
valuethe value of the item in gold
xthe x coordinate of the item
ythe y coordinate of the item
damagethe damage of the item if it is a weapon
defensethe defense of the item if it is armor
hpthe hp of the item if it is a healing potion
countthe number of the same items
rangethe range of the item if it is a projectile
colorthe color of the item

◆ Map

typedef struct map Map

Function Documentation

◆ drawAllItems()

void drawAllItems ( Item **  items,
int  n 
)

Draw all items in the Map.

Parameters
itemsArray of items to draw
nNumber of items in the array
Returns
void

◆ drawVisibleItems()

void drawVisibleItems ( Map map,
Item **  items,
int  n 
)

Draw all visible items in the Map.

Parameters
mapMap
itemsArray of items to draw
nNumber of items in the array
Returns
void

◆ freeItem()

void freeItem ( void *  i)

Free an item.

Parameters
iItem to free
Returns
void

◆ generateItems()

Item** generateItems ( int  n)

Generate n random items.

Used to generate items to distribute on the map.

random items are generated based on each item probability.

Parameters
nNumber of items to generate
Returns
Item** Array of items

◆ getItem()

Item* getItem ( Item **  items,
int  nr_items,
unsigned int  x,
unsigned int  y 
)

Get item at (x, y) in the map, also removes it from the array.

TODO: use cell->item_index instead of x, y

◆ insertItem()

int insertItem ( Item **  items,
int  nr_items,
Item item 
)

insert item into the items array (inventory)

Returns
int the number of items in the array