Refactor - Moved shop data structures to shop.c/.h (#521)

* Moved shop data structures to `shop.c/.h`

* Renamed static variables and reset function
This commit is contained in:
MeirGavish
2026-05-31 12:32:27 +03:00
committed by GitHub
parent 63b6584706
commit 8dc96b6bbb
4 changed files with 69 additions and 63 deletions
+2 -43
View File
@@ -318,9 +318,6 @@ static List _owned_jokers_list;
static List _discarded_jokers_list;
static List _expired_jokers_list;
BITSET_DEFINE(_avail_jokers_bitset, MAX_DEFINABLE_JOKERS)
static List _shop_jokers_list;
// Stacks
static CardObject* played[MAX_SELECTION_SIZE] = {NULL};
static int played_top = -1;
@@ -336,22 +333,6 @@ static int shortcut_joker_count = 0;
static int four_fingers_joker_count = 0;
GBAL_UNUSED
static inline bool is_shop_joker_avail(int joker_id)
{
return bitset_get_idx(&_avail_jokers_bitset, joker_id);
}
static inline void reset_shop_jokers(void)
{
int num_jokers = get_joker_registry_size();
bitset_clear(&_avail_jokers_bitset);
for (int i = 0; i < num_jokers; i++)
{
bitset_set_idx(&_avail_jokers_bitset, i, true);
}
}
static inline void played_push(CardObject* card_object)
{
if (played_top >= MAX_SELECTION_SIZE - 1)
@@ -394,11 +375,6 @@ static inline Card* discard_pop()
return discard_pile[discard_top--];
}
static inline void jokers_available_to_shop_init(void)
{
reset_shop_jokers();
}
void game_init()
{
state_machine_remove(&game_sm);
@@ -407,11 +383,10 @@ void game_init()
_owned_jokers_list = list_init();
_discarded_jokers_list = list_init();
_expired_jokers_list = list_init();
_shop_jokers_list = list_init();
// TODO: Move this to an initialization of the play scoring states
_joker_scored_itr = list_itr_create(&_owned_jokers_list);
jokers_available_to_shop_init();
game_shop_reset();
g_game_vars.hands = MAX_HANDS;
g_game_vars.discards = MAX_DISCARDS;
@@ -450,7 +425,6 @@ void game_reset()
list_clear(&_owned_jokers_list);
list_clear(&_discarded_jokers_list);
list_clear(&_expired_jokers_list);
list_clear(&_shop_jokers_list);
game_init();
@@ -628,21 +602,6 @@ List* get_discarded_jokers_list(void)
return &_discarded_jokers_list;
}
List* get_shop_jokers_list(void)
{
return &_shop_jokers_list;
}
Bitset* get_avail_jokers_bitset(void)
{
return &_avail_jokers_bitset;
}
void set_shop_joker_avail(int joker_id, bool avail)
{
bitset_set_idx(&_avail_jokers_bitset, joker_id, avail);
}
bool is_shortcut_joker_active(void)
{
return shortcut_joker_count > 0;
@@ -688,7 +647,7 @@ void remove_owned_joker(int owned_joker_idx)
shortcut_joker_count--;
}
set_shop_joker_avail(joker_object->joker->id, true);
game_shop_set_joker_avail(joker_object->joker->id, true);
list_remove_at_idx(&_owned_jokers_list, owned_joker_idx);
}