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

Exposes functions for working with stats. More...

#include "../common.h"

Go to the source code of this file.

Data Structures

struct  stats_t
struct  resources_t
struct  defenses_t

Enumerations

enum  stat_type_t {
  STRENGTH , INTELLIGENCE , DEXTERITY , CONSTITUTION ,
  MAX_STATS
}

Functions

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

Detailed Description

Exposes functions for working with stats.

Definition in file stats.h.

Enumeration Type Documentation

◆ stat_type_t

enum stat_type_t

Definition at line 10 of file stats.h.

10 {
11 STRENGTH,
12 INTELLIGENCE,
13 DEXTERITY,
14 CONSTITUTION,
15 MAX_STATS// Used to see how many stats there are
16} stat_type_t;

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