summaryrefslogtreecommitdiff
path: root/Userland/Games
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-01-20 12:45:02 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-22 21:31:36 +0000
commit8b3a94ffbc43d55b48a6038253f96d66838c4da1 (patch)
tree5a4992f58c4ddf17f9733e4b573369788373695b /Userland/Games
parent83687f85df7fd1b454fecee27699c445568b18f3 (diff)
downloadserenity-8b3a94ffbc43d55b48a6038253f96d66838c4da1.zip
LibCards+Games+GamesSettings: Return ErrorOr from CardStack::push()
Very few of these calls can propagate their errors yet, but one step at a time. :^)
Diffstat (limited to 'Userland/Games')
-rw-r--r--Userland/Games/Solitaire/Game.cpp24
-rw-r--r--Userland/Games/Spider/Game.cpp12
2 files changed, 18 insertions, 18 deletions
diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp
index 8028d22558..1104b6bbe7 100644
--- a/Userland/Games/Solitaire/Game.cpp
+++ b/Userland/Games/Solitaire/Game.cpp
@@ -70,9 +70,9 @@ void Game::timer_event(Core::TimerEvent&)
if (current_pile.count() < m_new_game_animation_pile) {
auto card = m_new_deck.take_last();
card->set_upside_down(true);
- current_pile.push(card);
+ current_pile.push(card).release_value_but_fixme_should_propagate_errors();
} else {
- current_pile.push(m_new_deck.take_last());
+ current_pile.push(m_new_deck.take_last()).release_value_but_fixme_should_propagate_errors();
++m_new_game_animation_pile;
}
@@ -81,7 +81,7 @@ void Game::timer_event(Core::TimerEvent&)
if (m_new_game_animation_pile == piles.size()) {
auto& stock_pile = stack_at_location(Stock);
while (!m_new_deck.is_empty())
- stock_pile.push(m_new_deck.take_last());
+ stock_pile.push(m_new_deck.take_last()).release_value_but_fixme_should_propagate_errors();
update(stock_pile.bounding_box());
@@ -404,13 +404,13 @@ void Game::draw_cards()
NonnullRefPtrVector<Card> moved_cards;
while (!play.is_empty()) {
auto card = play.pop();
- stock.push(card);
+ stock.push(card).release_value_but_fixme_should_propagate_errors();
moved_cards.prepend(card);
}
while (!waste.is_empty()) {
auto card = waste.pop();
- stock.push(card);
+ stock.push(card).release_value_but_fixme_should_propagate_errors();
moved_cards.prepend(card);
}
@@ -424,7 +424,7 @@ void Game::draw_cards()
update(stock.bounding_box());
} else {
auto play_bounding_box = play.bounding_box();
- play.take_all(waste);
+ play.take_all(waste).release_value_but_fixme_should_propagate_errors();
size_t cards_to_draw = 0;
switch (m_mode) {
@@ -445,7 +445,7 @@ void Game::draw_cards()
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
auto card = stock.pop();
cards_drawn.prepend(card);
- play.push(move(card));
+ play.push(move(card)).release_value_but_fixme_should_propagate_errors();
}
remember_move_for_undo(stock, play, cards_drawn);
@@ -466,7 +466,7 @@ void Game::pop_waste_to_play_stack()
if (play.is_empty() && !waste.is_empty()) {
auto card = waste.pop();
moving_cards().append(card);
- play.push(move(card));
+ play.push(move(card)).release_value_but_fixme_should_propagate_errors();
}
}
@@ -490,7 +490,7 @@ bool Game::attempt_to_move_card_to_foundations(CardStack& from)
auto card = from.pop();
mark_intersecting_stacks_dirty(card);
- foundation.push(card);
+ foundation.push(card).release_value_but_fixme_should_propagate_errors();
NonnullRefPtrVector<Card> moved_card;
moved_card.append(card);
@@ -612,12 +612,12 @@ void Game::perform_undo()
if (m_last_move.from->type() == CardStack::Type::Play && m_mode == Mode::SingleCardDraw) {
auto& waste = stack_at_location(Waste);
if (!m_last_move.from->is_empty())
- waste.push(m_last_move.from->pop());
+ waste.push(m_last_move.from->pop()).release_value_but_fixme_should_propagate_errors();
}
for (auto& to_intersect : m_last_move.cards) {
mark_intersecting_stacks_dirty(to_intersect);
- m_last_move.from->push(to_intersect);
+ m_last_move.from->push(to_intersect).release_value_but_fixme_should_propagate_errors();
(void)m_last_move.to->pop();
}
@@ -632,7 +632,7 @@ void Game::perform_undo()
}
}
for (auto& card : cards_popped) {
- play.push(card);
+ play.push(card).release_value_but_fixme_should_propagate_errors();
}
}
diff --git a/Userland/Games/Spider/Game.cpp b/Userland/Games/Spider/Game.cpp
index ad246b9f9c..d78d63aca2 100644
--- a/Userland/Games/Spider/Game.cpp
+++ b/Userland/Games/Spider/Game.cpp
@@ -95,7 +95,7 @@ void Game::perform_undo()
for (size_t i = 0; i < m_last_move.card_count; i++)
cards.append(m_last_move.to->pop());
for (ssize_t i = m_last_move.card_count - 1; i >= 0; i--)
- m_last_move.from->push(cards[i]);
+ m_last_move.from->push(cards[i]).release_value_but_fixme_should_propagate_errors();
update_score(-1);
@@ -162,7 +162,7 @@ void Game::detect_full_stacks()
auto original_current_rect = current_pile.bounding_box();
for (size_t j = 0; j < Card::card_count; j++) {
- completed_stack.push(current_pile.pop());
+ completed_stack.push(current_pile.pop()).release_value_but_fixme_should_propagate_errors();
}
update(original_current_rect);
@@ -384,9 +384,9 @@ void Game::timer_event(Core::TimerEvent&)
if (current_pile.count() < (cards_to_draw - 1)) {
auto card = m_new_deck.take_last();
card->set_upside_down(true);
- current_pile.push(card);
+ current_pile.push(card).release_value_but_fixme_should_propagate_errors();
} else {
- current_pile.push(m_new_deck.take_last());
+ current_pile.push(m_new_deck.take_last()).release_value_but_fixme_should_propagate_errors();
++m_new_game_animation_pile;
}
@@ -397,7 +397,7 @@ void Game::timer_event(Core::TimerEvent&)
auto& stock_pile = stack_at_location(Stock);
while (!m_new_deck.is_empty())
- stock_pile.push(m_new_deck.take_last());
+ stock_pile.push(m_new_deck.take_last()).release_value_but_fixme_should_propagate_errors();
update(stock_pile.bounding_box());
@@ -414,7 +414,7 @@ void Game::timer_event(Core::TimerEvent&)
auto& current_pile = stack_at_location(piles.at(m_draw_animation_pile));
auto card = stock_pile.pop();
card->set_upside_down(false);
- current_pile.push(card);
+ current_pile.push(card).release_value_but_fixme_should_propagate_errors();
update(current_pile.bounding_box());
++m_draw_animation_pile;