DungeonCrawl
Loading...
Searching...
No Matches
level.c
Go to the documentation of this file.
1
5
6#include "level.h"
7
8#include "../logging/logger.h"
9
10
12 // TODO: Maybe change to a more complex formula
13 return 100 + 10 * level;
14}
15
16
17void add_xp(character_t* player, int xp_earned) {
18 player->xp += xp_earned;
19
20 // Check if the player has enough XP to level up
21 if (player->xp >= calculate_xp_for_next_level(player->level)) {
22 level_up(player);
23 }
24}
25
26
27void level_up(character_t* player) {
28 player->level++;
29 player->xp -= calculate_xp_for_next_level(player->level - 1);
30 player->skill_points += 1;
31}
void level_up(character_t *player)
Handles the level-up process for a character.
Definition level.c:27
int calculate_xp_for_next_level(int level)
Calculates the XP required for the next level.
Definition level.c:11
void add_xp(character_t *player, int xp_earned)
Adds XP to a character and handles level-up if the XP threshold is reached.
Definition level.c:17
Exposes functions for working with the character.
Header file for logging functionality of the game.