1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +00:00

LibCards+Spider: Move ensure_top_card_is_visible() logic to CardStack

This commit is contained in:
Sam Atkins 2022-09-28 13:08:07 +01:00 committed by Sam Atkins
parent b26383bc6c
commit 12612703f9
4 changed files with 19 additions and 15 deletions

View file

@ -115,18 +115,6 @@ void Game::mark_intersecting_stacks_dirty(Card& intersecting_card)
update(intersecting_card.rect());
}
void Game::ensure_top_card_is_visible(NonnullRefPtr<CardStack> stack)
{
if (stack->is_empty())
return;
auto& top_card = stack->peek();
if (top_card.is_upside_down()) {
top_card.set_upside_down(false);
update(top_card.rect());
}
}
void Game::detect_full_stacks()
{
auto& completed_stack = stack_at_location(Completed);
@ -160,7 +148,8 @@ void Game::detect_full_stacks()
update(original_current_rect);
update(completed_stack.bounding_box());
ensure_top_card_is_visible(current_pile);
if (current_pile.make_top_card_visible())
update(current_pile.peek().rect());
update_score(101);
}
@ -283,7 +272,8 @@ void Game::move_focused_cards(CardStack& stack)
detect_full_stacks();
ensure_top_card_is_visible(*m_focused_stack);
if (m_focused_stack->make_top_card_visible())
update(m_focused_stack->peek().rect());
}
void Game::mouseup_event(GUI::MouseEvent& event)