From 71e1dd4f3221be4b5bec8b86e3988accf8febe50 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 20 Feb 2026 02:15:13 +0100 Subject: [PATCH] fix state representation not being updated when toggling restricted movement --- include/klotski.hpp | 2 ++ src/klotski.cpp | 5 +++++ src/main.cpp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/klotski.hpp b/include/klotski.hpp index 8d723f8..5017751 100644 --- a/include/klotski.hpp +++ b/include/klotski.hpp @@ -272,6 +272,8 @@ public: auto ToggleTarget(int x, int y) -> bool; + auto ToggleRestricted() -> void; + auto MoveBlockAt(int x, int y, Direction dir) -> bool; auto GetNextStates() const -> std::vector; diff --git a/src/klotski.cpp b/src/klotski.cpp index 03cf807..bd0e722 100644 --- a/src/klotski.cpp +++ b/src/klotski.cpp @@ -162,6 +162,11 @@ auto State::ToggleTarget(int x, int y) -> bool { return true; } +auto State::ToggleRestricted() -> void { + restricted = !restricted; + state.replace(0, 1, restricted ? "R" : "F"); +} + auto State::MoveBlockAt(int x, int y, Direction dir) -> bool { Block block = GetBlock(x, y); if (!block.IsValid()) { diff --git a/src/main.cpp b/src/main.cpp index cafdd02..70532a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -266,7 +266,7 @@ auto main(int argc, char *argv[]) -> int { } else if (IsKeyPressed(KEY_O)) { renderer.connect_solutions = !renderer.connect_solutions; } else if (IsKeyPressed(KEY_F)) { - current_state.restricted = !current_state.restricted; + current_state.ToggleRestricted(); previous_state = clear_masssprings(masssprings, current_state); edited = true; } else if (IsKeyPressed(KEY_T)) {