Maze scripts now work reliably.
This commit is contained in:
parent
c615f4fc1e
commit
9001af214a
3 changed files with 27 additions and 22 deletions
4
Makefile
4
Makefile
|
|
@ -37,7 +37,7 @@ tracy_build:
|
|||
meson compile -j 10 -C builddir
|
||||
|
||||
test: build
|
||||
./builddir/runtests -d yes "[mazes]"
|
||||
./builddir/runtests -d yes
|
||||
|
||||
run: build test
|
||||
ifeq '$(OS)' 'Windows_NT'
|
||||
|
|
@ -60,7 +60,7 @@ clean:
|
|||
meson compile --clean -C builddir
|
||||
|
||||
debug_test: build
|
||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests "[mazes]"
|
||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests
|
||||
|
||||
win_installer:
|
||||
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ namespace maze {
|
|||
matrix::perimeter it{room.x - 1, room.y - 1, room.width + 2, room.height + 2};
|
||||
|
||||
while(it.next()) {
|
||||
if($walls[it.y][it.x] == SPACE_VALUE) {
|
||||
if(matrix::inbounds($walls, it.x, it.y) && $walls[it.y][it.x] == SPACE_VALUE) {
|
||||
last_door = {it.x, it.y};
|
||||
possible_doors++;
|
||||
}
|
||||
|
|
@ -458,7 +458,6 @@ namespace maze {
|
|||
|
||||
for(auto& action : config) {
|
||||
std::string aname = action["action"];
|
||||
fmt::println("ACTION {}", aname);
|
||||
|
||||
if(aname == "hunt_and_kill") {
|
||||
maze.hunt_and_kill();
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ TEST_CASE("hunt-and-kill validator", "[mazes]") {
|
|||
TEST_CASE("hunt-and-kill scripting", "[mazes]") {
|
||||
using namespace nlohmann::literals;
|
||||
|
||||
// go up by 2 to keep odd
|
||||
for(int i = 0; i < 20; i+=2) {
|
||||
auto script = R"(
|
||||
[
|
||||
{"action": "hunt_and_kill"},
|
||||
|
|
@ -167,9 +169,13 @@ TEST_CASE("hunt-and-kill scripting", "[mazes]") {
|
|||
]
|
||||
)"_json;
|
||||
|
||||
|
||||
Map map(33, 33);
|
||||
Map map(23+i, 23+i);
|
||||
auto [maze, valid] = maze::script(map, script);
|
||||
maze.dump("SCRIPTED");
|
||||
REQUIRE(valid == true);
|
||||
|
||||
if(valid) {
|
||||
REQUIRE(maze.validate() == true);
|
||||
}
|
||||
|
||||
if(DUMP) maze.dump(valid ? "SCRIPTED" : "SCRIPTED FAIL!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue