diff options
-rw-r--r-- | Userland/Games/2048/BoardView.cpp | 6 | ||||
-rw-r--r-- | Userland/Games/2048/BoardView.h | 6 | ||||
-rw-r--r-- | Userland/Games/2048/Game.cpp | 16 | ||||
-rw-r--r-- | Userland/Games/2048/Game.h | 6 |
4 files changed, 17 insertions, 17 deletions
diff --git a/Userland/Games/2048/BoardView.cpp b/Userland/Games/2048/BoardView.cpp index d545484760..23ab32855b 100644 --- a/Userland/Games/2048/BoardView.cpp +++ b/Userland/Games/2048/BoardView.cpp @@ -10,7 +10,7 @@ #include <LibGfx/FontDatabase.h> #include <LibGfx/Palette.h> -BoardView::BoardView(const Game::Board* board) +BoardView::BoardView(Game::Board const* board) : m_board(board) { } @@ -19,7 +19,7 @@ BoardView::~BoardView() { } -void BoardView::set_board(const Game::Board* board) +void BoardView::set_board(Game::Board const* board) { if (m_board == board) return; @@ -44,7 +44,7 @@ void BoardView::pick_font() String best_font_name; int best_font_size = -1; auto& font_database = Gfx::FontDatabase::the(); - font_database.for_each_font([&](const Gfx::Font& font) { + font_database.for_each_font([&](Gfx::Font const& font) { if (font.family() != "Liza" || font.weight() != 700) return; auto size = font.glyph_height(); diff --git a/Userland/Games/2048/BoardView.h b/Userland/Games/2048/BoardView.h index 51c0430ee5..20db43b15b 100644 --- a/Userland/Games/2048/BoardView.h +++ b/Userland/Games/2048/BoardView.h @@ -14,12 +14,12 @@ class BoardView final : public GUI::Frame { public: virtual ~BoardView() override; - void set_board(const Game::Board* board); + void set_board(Game::Board const* board); Function<void(Game::Direction)> on_move; private: - explicit BoardView(const Game::Board*); + explicit BoardView(Game::Board const*); virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; @@ -37,5 +37,5 @@ private: float m_padding { 0 }; float m_cell_size { 0 }; - const Game::Board* m_board { nullptr }; + Game::Board const* m_board { nullptr }; }; diff --git a/Userland/Games/2048/Game.cpp b/Userland/Games/2048/Game.cpp index f5753d9b59..0a7be07b24 100644 --- a/Userland/Games/2048/Game.cpp +++ b/Userland/Games/2048/Game.cpp @@ -45,7 +45,7 @@ void Game::add_random_tile() m_board[row][column] = value; } -static Game::Board transpose(const Game::Board& board) +static Game::Board transpose(Game::Board const& board) { Vector<Vector<u32>> new_board; auto result_row_count = board[0].size(); @@ -65,7 +65,7 @@ static Game::Board transpose(const Game::Board& board) return new_board; } -static Game::Board reverse(const Game::Board& board) +static Game::Board reverse(Game::Board const& board) { auto new_board = board; for (auto& row : new_board) { @@ -76,7 +76,7 @@ static Game::Board reverse(const Game::Board& board) return new_board; } -static Vector<u32> slide_row(const Vector<u32>& row, size_t& successful_merge_score) +static Vector<u32> slide_row(Vector<u32> const& row, size_t& successful_merge_score) { if (row.size() < 2) return row; @@ -114,7 +114,7 @@ static Vector<u32> slide_row(const Vector<u32>& row, size_t& successful_merge_sc return result; } -static Game::Board slide_left(const Game::Board& board, size_t& successful_merge_score) +static Game::Board slide_left(Game::Board const& board, size_t& successful_merge_score) { Vector<Vector<u32>> new_board; for (auto& row : board) @@ -123,7 +123,7 @@ static Game::Board slide_left(const Game::Board& board, size_t& successful_merge return new_board; } -static bool is_complete(const Game::Board& board, size_t target) +static bool is_complete(Game::Board const& board, size_t target) { for (auto& row : board) { if (row.contains_slow(target)) @@ -133,7 +133,7 @@ static bool is_complete(const Game::Board& board, size_t target) return false; } -static bool has_no_neighbors(const Span<const u32>& row) +static bool has_no_neighbors(Span<u32 const> const& row) { if (row.size() < 2) return true; @@ -147,7 +147,7 @@ static bool has_no_neighbors(const Span<const u32>& row) return has_no_neighbors(row.slice(1, row.size() - 1)); }; -static bool is_stalled(const Game::Board& board) +static bool is_stalled(Game::Board const& board) { static auto stalled = [](auto& row) { return !row.contains_slow(0) && has_no_neighbors(row.span()); @@ -164,7 +164,7 @@ static bool is_stalled(const Game::Board& board) return true; } -static size_t get_number_of_free_cells(const Game::Board& board) +static size_t get_number_of_free_cells(Game::Board const& board) { size_t accumulator = 0; for (auto& row : board) { diff --git a/Userland/Games/2048/Game.h b/Userland/Games/2048/Game.h index 0c5ee5f039..213104c558 100644 --- a/Userland/Games/2048/Game.h +++ b/Userland/Games/2048/Game.h @@ -11,8 +11,8 @@ class Game final { public: Game(size_t grid_size, size_t target_tile, bool evil_ai); - Game(const Game&) = default; - Game& operator=(const Game&) = default; + Game(Game const&) = default; + Game& operator=(Game const&) = default; enum class MoveOutcome { OK, @@ -37,7 +37,7 @@ public: using Board = Vector<Vector<u32>>; - const Board& board() const { return m_board; } + Board const& board() const { return m_board; } static size_t max_power_for_board(size_t size) { |