Small refactor for the joker lists to have wrapping functions to add and remove jokers
This commit is contained in:
+12
-7
@@ -161,7 +161,15 @@ List *get_jokers(void) {
|
|||||||
return jokers;
|
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) {
|
int get_deck_top(void) {
|
||||||
return deck_top;
|
return deck_top;
|
||||||
@@ -2413,7 +2421,7 @@ void game_sell_joker(int joker_idx)
|
|||||||
display_money(money);
|
display_money(money);
|
||||||
erase_price_under_sprite_object(joker_object->sprite_object);
|
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);
|
int_list_append(jokers_available_to_shop, (intptr_t)joker_object->joker->id);
|
||||||
|
|
||||||
joker_start_discard_animation(joker_object);
|
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
|
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);
|
joker_object->sprite_object->ty = int2fx(HELD_JOKERS_POS.y);
|
||||||
|
add_joker(joker_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void game_shop_buy_joker(int shop_joker_idx)
|
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
|
display_money(money); // Update the money display
|
||||||
erase_price_under_sprite_object(joker_object->sprite_object);
|
erase_price_under_sprite_object(joker_object->sprite_object);
|
||||||
sprite_object_set_focus(joker_object->sprite_object, false);
|
sprite_object_set_focus(joker_object->sprite_object, false);
|
||||||
|
add_to_held_jokers(joker_object);
|
||||||
add_joker(joker_object);
|
|
||||||
list_remove_by_idx(shop_jokers, shop_joker_idx); // Remove the joker from the shop
|
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,
|
static void shop_top_row_on_selection_changed(SelectionGrid* selection_grid, int row_idx,
|
||||||
const Selection* prev_selection,
|
const Selection* prev_selection,
|
||||||
const Selection* new_selection)
|
const Selection* new_selection)
|
||||||
|
|||||||
Reference in New Issue
Block a user