Merge pull request #111 from cellos51/held_jokers_refactor

Small refactor for the joker lists to have wrapping functions to add and remove jokers
This commit is contained in:
MeirGavish
2025-08-30 02:16:15 +03:00
committed by GitHub
+12 -7
View File
@@ -161,7 +161,15 @@ List *get_jokers(void) {
return jokers;
}
void add_joker(JokerObject *joker_object)
{
list_append(jokers, joker_object);
}
void remove_held_joker(int joker_idx)
{
list_remove_by_idx(jokers, joker_idx);
}
int get_deck_top(void) {
return deck_top;
@@ -2413,7 +2421,7 @@ void game_sell_joker(int joker_idx)
display_money(money);
erase_price_under_sprite_object(joker_object->sprite_object);
list_remove_by_idx(jokers, joker_idx);
remove_held_joker(joker_idx);
int_list_append(jokers_available_to_shop, (intptr_t)joker_object->joker->id);
joker_start_discard_animation(joker_object);
@@ -2435,10 +2443,10 @@ static int shop_top_row_get_size()
return list_get_size(shop_jokers) + 1; // + 1 to account for next round button
}
void add_joker(JokerObject *joker_object)
static void add_to_held_jokers(JokerObject *joker_object)
{
list_append(jokers, joker_object);
joker_object->sprite_object->ty = int2fx(HELD_JOKERS_POS.y);
add_joker(joker_object);
}
static void game_shop_buy_joker(int shop_joker_idx)
@@ -2449,8 +2457,7 @@ static void game_shop_buy_joker(int shop_joker_idx)
display_money(money); // Update the money display
erase_price_under_sprite_object(joker_object->sprite_object);
sprite_object_set_focus(joker_object->sprite_object, false);
add_joker(joker_object);
add_to_held_jokers(joker_object);
list_remove_by_idx(shop_jokers, shop_joker_idx); // Remove the joker from the shop
}
@@ -2491,8 +2498,6 @@ static void shop_top_row_on_key_hit(SelectionGrid* selection_grid, Selection* se
}
}
static void shop_top_row_on_selection_changed(SelectionGrid* selection_grid, int row_idx,
const Selection* prev_selection,
const Selection* new_selection)