DungeonCrawl
Loading...
Searching...
No Matches
stats.c
Go to the documentation of this file.
1
5#include "stats.h"
6
7#include "../logging/logger.h"
8
9
10void raise_skill(stats_t* stats, stat_type_t stat, int skillpoint) {
11 if (stats == NULL) {
12 log_msg(ERROR, "Stats", "Stats pointer is NULL");
13 return;
14 }
15 if (1 <= skillpoint) {
16 skillpoint--;
17 switch (stat) {
18 case STRENGTH:
19 stats->strength++;
20 break;
21 case INTELLIGENCE:
22 stats->intelligence++;
23 break;
24 case DEXTERITY:
25 stats->dexterity++;
26 break;
27 case CONSTITUTION:
28 stats->constitution++;
29 break;
30 default:
31 log_msg(ERROR, "Stats", "Invalid stat type");
32 break;
33 }
34 } else {
35 log_msg(ERROR, "Stats", "Not enough skill points to allocate");
36 return;
37 }
38}
void log_msg(const log_level_t level, const char *module, const char *format,...)
Logs a formatted message with a specified log level and module.
Definition logger.c:246
Header file for logging functionality of the game.
void raise_skill(stats_t *stats, stat_type_t stat, int skillpoint)
Raises a specified skill by one point.
Definition stats.c:10
Exposes functions for working with stats.