mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 02:56:10 +00:00
LibCards+Games: Make CardGame::add_stack()
fallible
And while we're at it, handle the CardStack allocation (and failure thereof) internally.
This commit is contained in:
parent
08ff87b3ce
commit
d7ba577c90
Notes:
sideshowbarker
2024-07-17 05:19:06 +09:00
Author: https://github.com/AtkinsSJ
Commit: d7ba577c90
Pull-request: https://github.com/SerenityOS/serenity/pull/16851
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/trflynn89 ✅
4 changed files with 24 additions and 23 deletions
|
@ -33,11 +33,6 @@ CardGame::CardGame()
|
|||
set_background_color(background_color.value_or(Color::from_rgb(0x008000)));
|
||||
}
|
||||
|
||||
void CardGame::add_stack(NonnullRefPtr<CardStack> stack)
|
||||
{
|
||||
m_stacks.append(move(stack));
|
||||
}
|
||||
|
||||
void CardGame::mark_intersecting_stacks_dirty(Cards::Card const& intersecting_card)
|
||||
{
|
||||
for (auto& stack : stacks()) {
|
||||
|
|
|
@ -28,7 +28,13 @@ public:
|
|||
NonnullRefPtrVector<CardStack>& stacks() { return m_stacks; }
|
||||
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
|
||||
CardStack& stack_at_location(int location) { return m_stacks[location]; }
|
||||
void add_stack(NonnullRefPtr<CardStack>);
|
||||
|
||||
template<class... Args>
|
||||
ErrorOr<void> add_stack(Args&&... args)
|
||||
{
|
||||
auto stack = TRY(try_make_ref_counted<CardStack>(forward<Args>(args)...));
|
||||
return m_stacks.try_append(move(stack));
|
||||
}
|
||||
void mark_intersecting_stacks_dirty(Card const& intersecting_card);
|
||||
|
||||
bool is_moving_cards() const { return !m_moving_cards.is_empty(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue