Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
highScores.h
Go to the documentation of this file.
1
25
26#pragma once
27
28#include "linked_list.h"
29#include "swadgePass.h"
30
31#include <stdbool.h>
32#include <stdint.h>
33
34#define MAX_HIGH_SCORE_COUNT 20
35
36typedef struct
37{
39 int32_t score;
42} score_t;
43
54
62void initHighScores(highScores_t* hs, const char* nvsNamespace);
63
74bool updateHighScores(highScores_t* hs, const char* nvsNamespace, score_t newScores[], uint8_t numNewScores);
75
85void saveHighScoresFromSwadgePass(highScores_t* hs, const char* nvsNamespace, list_t swadgePasses,
86 int32_t (*fnGetSwadgePassHighScore)(const swadgePassPacket_t* packet));
87
96void addHighScoreToSwadgePassPacket(const char* nvsNamespace, swadgePassPacket_t* packet,
97 void (*fnSetSwadgePassHighScore)(swadgePassPacket_t* packet, int32_t highScore));
bool updateHighScores(highScores_t *hs, const char *nvsNamespace, score_t newScores[], uint8_t numNewScores)
Update the high score table and user high score with new scores from the player or SwadgePass and per...
Definition highScores.c:22
#define MAX_HIGH_SCORE_COUNT
Definition highScores.h:34
int32_t userHighScore
Definition highScores.h:50
int32_t score
The point value of this score. This will be 0 for uninitialized scores.
Definition highScores.h:39
score_t highScores[MAX_HIGH_SCORE_COUNT]
High score list, sorted from high to low.
Definition highScores.h:52
void saveHighScoresFromSwadgePass(highScores_t *hs, const char *nvsNamespace, list_t swadgePasses, int32_t(*fnGetSwadgePassHighScore)(const swadgePassPacket_t *packet))
Extract high score data received from SwadgePass and save to the high score table....
Definition highScores.c:102
void addHighScoreToSwadgePassPacket(const char *nvsNamespace, swadgePassPacket_t *packet, void(*fnSetSwadgePassHighScore)(swadgePassPacket_t *packet, int32_t highScore))
Write high score data to SwadgePass packet for sending to other swadges. This should be called from y...
Definition highScores.c:122
void initHighScores(highScores_t *hs, const char *nvsNamespace)
Load high score data from NVS.
Definition highScores.c:15
uint8_t highScoreCount
Number of high scores to save. Defaults to MAX_HIGH_SCORE_COUNT if not set.
Definition highScores.h:47
int32_t swadgePassUsername
The SwadgePass user who achieved this score, or 0 for this Swadge's user.
Definition highScores.h:41
Definition highScores.h:45
Definition highScores.h:37
A doubly linked list with pointers to the first and last nodes.
Definition linked_list.h:87
struct swadgePassPacket swadgePassPacket_t
A SwadgePass packet which is transmitted over ESP NOW.