remove usage of extern for joker_registry. Add array size macro to util.h

This commit is contained in:
theturtlemafia
2025-07-28 14:24:33 -04:00
parent 5c58b092d7
commit ed1204db74
5 changed files with 24 additions and 8 deletions
+6 -4
View File
@@ -38,10 +38,10 @@ void joker_init()
Joker *joker_new(u8 id)
{
if (id >= joker_registry_size) return NULL;
if (id >= get_joker_registry_size()) return NULL;
Joker *joker = malloc(sizeof(Joker));
const JokerInfo *jinfo = &joker_registry[id];
const JokerInfo *jinfo = get_joker_registry_entry(id);
joker->id = id;
joker->modifier = BASE_EDITION; // TODO: Make this random later
@@ -61,8 +61,10 @@ void joker_destroy(Joker **joker)
JokerEffect joker_get_score_effect(Joker *joker, Card *scored_card)
{
if (joker->id >= joker_registry_size) return (JokerEffect){0};
return joker_registry[joker->id].effect(joker, scored_card);
const JokerInfo *jinfo = get_joker_registry_entry(joker->id);
if (!jinfo) return (JokerEffect){0};
return jinfo->effect(joker, scored_card);
}
// JokerObject methods