mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Hearts: Move code to reposition cards into a separate method
This commit is contained in:
parent
9a6c6a98e5
commit
4ba9cc82c0
Notes:
sideshowbarker
2024-07-18 17:24:39 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/4ba9cc82c00 Pull-request: https://github.com/SerenityOS/serenity/pull/7443
2 changed files with 12 additions and 5 deletions
|
@ -122,11 +122,7 @@ void Game::setup(String player_name)
|
|||
player.hand.append(card);
|
||||
}
|
||||
player.sort_hand();
|
||||
auto card_position = player.first_card_position;
|
||||
for (auto& card : player.hand) {
|
||||
card->set_position(card_position);
|
||||
card_position.translate_by(player.card_offset);
|
||||
}
|
||||
reposition_hand(player);
|
||||
}
|
||||
|
||||
advance_game();
|
||||
|
@ -519,6 +515,15 @@ bool Game::is_winner(Player& player)
|
|||
return (max_score.value() != sum_points_of_all_cards && player_score == min_score.value()) || player_score == sum_points_of_all_cards;
|
||||
}
|
||||
|
||||
void Game::reposition_hand(Player& player)
|
||||
{
|
||||
auto card_position = player.first_card_position;
|
||||
for (auto& card : player.hand) {
|
||||
card->set_position(card_position);
|
||||
card_position.translate_by(player.card_offset);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GUI::Frame::paint_event(event);
|
||||
|
|
|
@ -49,6 +49,8 @@ private:
|
|||
bool other_player_has_lower_value_card(Player& player, Card& card);
|
||||
bool other_player_has_higher_value_card(Player& player, Card& card);
|
||||
|
||||
void reposition_hand(Player& player);
|
||||
|
||||
void start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint const& end, Function<void()> did_finish_callback, int initial_delay_ms, int steps = 30);
|
||||
void stop_animation();
|
||||
|
||||
|
|
Loading…
Reference in a new issue