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

LibCards: Combine CardStack constructors

And while I'm at it, clarify the name of `associated_stack` to
`covered_stack`. It's used in exactly one way, so we can make the code
clearer by giving it a less generic name.
This commit is contained in:
Sam Atkins 2022-09-28 12:48:01 +01:00 committed by Sam Atkins
parent bfa9ae809f
commit 21a818ab50
2 changed files with 8 additions and 16 deletions

View file

@ -15,18 +15,8 @@ CardStack::CardStack()
{
}
CardStack::CardStack(Gfx::IntPoint const& position, Type type)
: m_position(position)
, m_type(type)
, m_rules(rules_for_type(type))
, m_base(m_position, { Card::width, Card::height })
{
VERIFY(type != Type::Invalid);
calculate_bounding_box();
}
CardStack::CardStack(Gfx::IntPoint const& position, Type type, NonnullRefPtr<CardStack> associated_stack)
: m_associated_stack(move(associated_stack))
CardStack::CardStack(Gfx::IntPoint const& position, Type type, RefPtr<CardStack> covered_stack)
: m_covered_stack(move(covered_stack))
, m_position(position)
, m_type(type)
, m_rules(rules_for_type(type))
@ -49,7 +39,7 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color const& background_color)
for (const auto& card : m_stack)
number_of_moving_cards += card.is_moving();
if (m_associated_stack && !m_associated_stack->is_empty())
if (m_covered_stack && !m_covered_stack->is_empty())
return false;
if (!is_empty() && (m_stack.size() != number_of_moving_cards))
return false;