30 if (ability_table == NULL || potion_table == NULL || gear_table == NULL || player == NULL)
return 1;
32 add_potion(goblin, &potion_table->potions[HEALING]);
52 add_ability(goblin, &ability_table->abilities[BITE]);
63 player->base_attack = &ability_table->abilities[PUNCH];
65 add_potion(player, &potion_table->potions[HEALING]);
66 add_potion(player, &potion_table->potions[MANA]);
67 add_potion(player, &potion_table->potions[STAMINA]);
68 equip_gear(player, gear_table->gears[ARMING_SWORD]);
70 snprintf(player->name,
sizeof(player->name),
"%s", name);
72 snprintf(player->name,
sizeof(player->name),
"Hero");
83 player->base_attack = &ability_table->abilities[PUNCH];
void free_ability_table(memory_pool_t *memory_pool, ability_table_t *table)
Free the ability table, deallocates memory in the memory pool.
ability_table_t * init_ability_table(memory_pool_t *memory_pool, const db_connection_t *db_connection)
Initialize the ability table, allocates memory and returns the pointer to the table.
void equip_gear(character_t *character, gear_t *gear)
Equips a gear item to a character.
void add_potion(character_t *character, potion_t *potion)
Adds a potion to a character's inventory.
void free_character(memory_pool_t *memory_pool, character_t *character)
Frees the memory allocated for a character.
void add_ability(character_t *character, ability_t *ability)
Adds an ability to a character.
memory_pool_t * main_memory_pool
Global memory pool for the application.
Defines common macros, types, and global variables for color schemes and utilities.
Declares core game states, global database connection, and main game control functions.
int reset_goblin()
Resets the goblin character data by deallocating the current goblin instance and creating a new one.
int reset_player()
Resets the player character to its initial state, clearing all abilities, items, and stats.
int free_game_data()
Frees game-related data structures and resources, such as ability tables, characters,...
int init_player(char *name)
Initializes the player character with default abilities and items.
int init_game_data()
Initializes game data for the application.
Declares functions and globals for initializing, resetting, and freeing game data such as player,...
void free_gear_table(memory_pool_t *memory_pool, gear_table_t *table)
Frees the memory allocated for a gear table.
gear_table_t * init_gear_table(memory_pool_t *memory_pool, const db_connection_t *db_connection, ability_table_t *ability_table)
Initializes a gear table.
void generate_loot(character_t *c, 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.
Exposes functions for loot generation.
void memory_pool_free(memory_pool_t *pool, void *ptr)
Sets the given data pointer to not active in the given memory pool.
character_t * create_new_goblin(memory_pool_t *memory_pool)
Creates and initializes a new goblin character.
Declares routines for creating and destroying monster characters.
character_t * create_new_player(memory_pool_t *memory_pool)
Creates and initializes a new player character.
Exposes functions for working with the player.
potion_table_t * init_potion_table(memory_pool_t *memory_pool, const db_connection_t *db_connection)
initializes a potion table with potions from the database
void free_potion_table(memory_pool_t *memory_pool, potion_table_t *table)
Frees the memory allocated for a potion table.