summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCards
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-01-22 21:28:28 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-22 21:31:36 +0000
commit0855e9f014bbf4cd1ada1ef8933c0632e4dea994 (patch)
treea6d7231b23030352e1aa0d937e9d8e10a62d49dd /Userland/Libraries/LibCards
parent8b3a94ffbc43d55b48a6038253f96d66838c4da1 (diff)
downloadserenity-0855e9f014bbf4cd1ada1ef8933c0632e4dea994.zip
LibCards+Game: Return ErrorOr from CardGame::drop_cards_on_stack()
Diffstat (limited to 'Userland/Libraries/LibCards')
-rw-r--r--Userland/Libraries/LibCards/CardGame.cpp6
-rw-r--r--Userland/Libraries/LibCards/CardGame.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCards/CardGame.cpp b/Userland/Libraries/LibCards/CardGame.cpp
index ad1a8e6a0b..a863128709 100644
--- a/Userland/Libraries/LibCards/CardGame.cpp
+++ b/Userland/Libraries/LibCards/CardGame.cpp
@@ -83,17 +83,19 @@ RefPtr<CardStack> CardGame::find_stack_to_drop_on(CardStack::MovementRule moveme
return closest_stack;
}
-void CardGame::drop_cards_on_stack(Cards::CardStack& stack, CardStack::MovementRule movement_rule)
+ErrorOr<void> CardGame::drop_cards_on_stack(Cards::CardStack& stack, CardStack::MovementRule movement_rule)
{
VERIFY(stack.is_allowed_to_push(m_moving_cards.at(0), m_moving_cards.size(), movement_rule));
for (auto& to_intersect : moving_cards()) {
mark_intersecting_stacks_dirty(to_intersect);
- stack.push(to_intersect).release_value_but_fixme_should_propagate_errors();
+ TRY(stack.push(to_intersect));
(void)moving_cards_source_stack()->pop();
}
update(moving_cards_source_stack()->bounding_box());
update(stack.bounding_box());
+
+ return {};
}
void CardGame::clear_moving_cards()
diff --git a/Userland/Libraries/LibCards/CardGame.h b/Userland/Libraries/LibCards/CardGame.h
index d199471fff..d6d60e04c2 100644
--- a/Userland/Libraries/LibCards/CardGame.h
+++ b/Userland/Libraries/LibCards/CardGame.h
@@ -44,7 +44,7 @@ public:
RefPtr<CardStack> moving_cards_source_stack() const { return m_moving_cards_source_stack; }
void pick_up_cards_from_stack(CardStack&, Gfx::IntPoint click_location, CardStack::MovementRule);
RefPtr<CardStack> find_stack_to_drop_on(CardStack::MovementRule) const;
- void drop_cards_on_stack(CardStack&, CardStack::MovementRule);
+ ErrorOr<void> drop_cards_on_stack(CardStack&, CardStack::MovementRule);
void clear_moving_cards();
bool is_previewing_card() const { return !m_previewed_card_stack.is_null(); }