DungeonCrawl
Loading...
Searching...
No Matches
loot_generation.h File Reference

Exposes functions for loot generation. More...

#include "../character/monster.h"
#include "../item/gear.h"
#include "../item/potion.h"

Go to the source code of this file.

Functions

void generate_loot (character_t *character, gear_table_t *gear_table, potion_table_t *potion_table, int rolls)
 Generates loot for a character by randomly selecting a number of gear and potions.

Detailed Description

Exposes functions for loot generation.

Definition in file loot_generation.h.

Function Documentation

◆ generate_loot()

void generate_loot ( character_t * character,
gear_table_t * gear_table,
potion_table_t * potion_table,
int rolls )

Generates loot for a character by randomly selecting a number of gear and potions.

Parameters
characterThe character to generate loot for.
gear_tableThe table containing available gear.
potion_tableThe table containing available potions.
rollsThe number of loot rolls to perform.

Definition at line 10 of file loot_generation.c.

10 {
11 for (int i = 0; i < rolls; i++) {
12 int gear_index = rand() % MAX_GEARS;
13 int potion_index = rand() % MAX_POTION_TYPES;
14 add_gear(c, gear_table->gears[gear_index]);
15 add_potion(c, &potion_table->potions[potion_index]);
16 }
17}
void add_gear(character_t *character, gear_t *gear)
Adds gear to a character's inventory.
Definition character.c:156
void add_potion(character_t *character, potion_t *potion)
Adds a potion to a character's inventory.
Definition character.c:242