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

Exposes functions for working with the player. More...

#include "character.h"

Go to the source code of this file.

Functions

character_tcreate_new_player (memory_pool_t *memory_pool)
 Creates and initializes a new player character.

Detailed Description

Exposes functions for working with the player.

Definition in file player.h.

Function Documentation

◆ create_new_player()

character_t * create_new_player ( memory_pool_t * memory_pool)

Creates and initializes a new player character.

Parameters
memory_poolA pointer to the memory pool used for allocating the player character
Returns
A pointer to the newly created player character, or NULL if memory allocation fails

Definition at line 8 of file player.c.

8 {
9 NULL_PTR_HANDLER_RETURN(memory_pool, NULL, "Player", "Memory pool is NULL");
10
11 character_t* player = init_character(memory_pool, PLAYER, "Hero");
12 NULL_PTR_HANDLER_RETURN(player, NULL, "Player", "Failed to allocate memory for player");
13
14 set_character_stats(player, 5, 5, 5, 10);
15 set_initial_xp(player, 0);
16 set_level(player, 1);
17 set_skill_points(player, 5);
18 return player;
19}
void set_character_stats(character_t *character, int strength, int intelligence, int dexterity, int constitution)
Sets the stats for a character.
Definition character.c:66
character_t * init_character(memory_pool_t *memory_pool, const character_type_t type, const char *name)
Initializes a new character.
Definition character.c:13
void set_skill_points(character_t *character, int skill_points)
Sets the skill points for a character.
Definition character.c:315
void set_level(character_t *character, int level)
Sets the level for a character.
Definition character.c:305
void set_initial_xp(character_t *character, int xp)
sets initial xp for a character
Definition character.c:300