mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
Spider: Automatically reveal top cards
This matches basically all other Spider implementations I've played, and makes playing much easier :) I have left click-to-reveal in place, but mostly incase there is a condition I've forgotten about.
This commit is contained in:
parent
1021aba226
commit
c0bc884295
2 changed files with 17 additions and 0 deletions
|
@ -114,6 +114,18 @@ void Game::draw_cards()
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
void Game::detect_full_stacks()
|
||||||
{
|
{
|
||||||
auto& completed_stack = stack(Completed);
|
auto& completed_stack = stack(Completed);
|
||||||
|
@ -143,6 +155,8 @@ void Game::detect_full_stacks()
|
||||||
completed_stack.push(current_pile.pop());
|
completed_stack.push(current_pile.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure_top_card_is_visible(current_pile);
|
||||||
|
|
||||||
update_score(101);
|
update_score(101);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +315,8 @@ void Game::mouseup_event(GUI::MouseEvent& event)
|
||||||
|
|
||||||
detect_full_stacks();
|
detect_full_stacks();
|
||||||
|
|
||||||
|
ensure_top_card_is_visible(*m_focused_stack);
|
||||||
|
|
||||||
rebound = false;
|
rebound = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
void start_timer_if_necessary();
|
void start_timer_if_necessary();
|
||||||
void update_score(int delta);
|
void update_score(int delta);
|
||||||
void draw_cards();
|
void draw_cards();
|
||||||
|
void ensure_top_card_is_visible(NonnullRefPtr<CardStack> stack);
|
||||||
void detect_full_stacks();
|
void detect_full_stacks();
|
||||||
void detect_victory();
|
void detect_victory();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue