mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:47:35 +00:00
Solitaire: Prevent player dragging entire stack to foundation
Currently, it is possible for the player to drag an entire stack of cards to the foundation stack, provided the top card of the stack (i.e the "root" card) can be dropped onto the foundation stack. This causes an invalid state where, e.g, red cards end up in a black foundation stack, or vice versa.
This commit is contained in:
parent
a743075b9f
commit
2f49241296
3 changed files with 6 additions and 3 deletions
|
@ -131,7 +131,7 @@ void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, Nonnu
|
|||
}
|
||||
}
|
||||
|
||||
bool CardStack::is_allowed_to_push(const Card& card) const
|
||||
bool CardStack::is_allowed_to_push(const Card& card, size_t stack_size) const
|
||||
{
|
||||
if (m_type == Stock || m_type == Waste || m_type == Play)
|
||||
return false;
|
||||
|
@ -148,6 +148,9 @@ bool CardStack::is_allowed_to_push(const Card& card) const
|
|||
return false;
|
||||
|
||||
if (m_type == Foundation) {
|
||||
// Prevent player from dragging an entire stack of cards to the foundation stack
|
||||
if (stack_size > 1)
|
||||
return false;
|
||||
return top_card.type() == card.type() && m_stack.size() == card.value();
|
||||
} else if (m_type == Normal) {
|
||||
return top_card.color() != card.color() && top_card.value() == card.value() + 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue