mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:07:34 +00:00
Hearts: Highlight cards when an invalid play is attempted
This briefly inverts the selected card when the user attempts to make an invalid play.
This commit is contained in:
parent
2c772d1848
commit
971f4ca71c
4 changed files with 39 additions and 1 deletions
|
@ -402,6 +402,11 @@ void Game::advance_game()
|
|||
if (m_animation_playing)
|
||||
return;
|
||||
|
||||
if (m_inverted_card) {
|
||||
m_inverted_card->set_inverted(false);
|
||||
m_inverted_card.clear();
|
||||
}
|
||||
|
||||
if (m_state == State::Play && game_ended()) {
|
||||
m_state = State::GameEnded;
|
||||
on_status_change("Game ended.");
|
||||
|
@ -638,6 +643,11 @@ void Game::card_clicked_during_play(size_t card_index, Card& card)
|
|||
{
|
||||
String explanation;
|
||||
if (!is_valid_play(m_players[0], card, &explanation)) {
|
||||
if (m_inverted_card)
|
||||
m_inverted_card->set_inverted(false);
|
||||
card.set_inverted(true);
|
||||
m_inverted_card = card;
|
||||
update();
|
||||
on_status_change(String::formatted("You can't play this card: {}", explanation));
|
||||
continue_game_after_delay();
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue