DungeonCrawl
Loading...
Searching...
No Matches
stats.c File Reference

Implementation for stats. More...

#include "stats.h"
#include "../logging/logger.h"

Go to the source code of this file.

Functions

void raise_skill (stats_t *stats, stat_type_t stat, int skillpoint)
 Raises a specified skill by one point.

Detailed Description

Implementation for stats.

Definition in file stats.c.

Function Documentation

◆ raise_skill()

void raise_skill ( stats_t * stats,
stat_type_t stat,
int skillpoint )

Raises a specified skill by one point.

This function increases the value of the specified skill in the stats structure by one, provided that the skill point is valid.

Parameters
statsPointer to the stats structure.
statThe type of stat to raise (e.g., STRENGTH, INTELLIGENCE).
skillpointThe number of skill points available for allocation.

Definition at line 10 of file stats.c.

10 {
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