Results of today's code review session.

This commit is contained in:
Zed A. Shaw 2025-01-05 15:07:30 -05:00
parent 14b3ea7676
commit f35b74f335
21 changed files with 64 additions and 59 deletions

View file

@ -6,7 +6,7 @@
#include "worldbuilder.hpp"
#include "save.hpp"
#include "systems.hpp"
#include "collider.hpp"
#include "spatialmap.hpp"
#include "components.hpp"
using namespace fmt;
@ -32,8 +32,8 @@ TEST_CASE("load a basic gui run but don't loop", "[gui]") {
world.set<Inventory>(player.entity, {5});
world.set<LightSource>(player.entity, {6,1});
spatial_map collider;
world.set_the<spatial_map>(collider);
SpatialMap collider;
world.set_the<SpatialMap>(collider);
System::init_positions(world);
GUI gui(world, game_map);

View file

@ -40,10 +40,20 @@ TEST_CASE("basic inventory test", "[inventory]") {
auto &item1 = inventory.get(0);
REQUIRE(item1.count == 1);
int item_at = inventory.item_index("SWORD_RUSTY");
REQUIRE(item_at == 0);
REQUIRE(inventory.item_index("SADFASFSADF") == -1);
System::pickup(world, player, sword);
REQUIRE(item1.count == 2);
System::pickup(world, player, sword);
REQUIRE(item1.count == 3);
System::pickup(world, player, sword);
REQUIRE(inventory.count() == 1);
REQUIRE(item1.count == 4);
inventory.decrease(0, 1);

View file

@ -48,8 +48,4 @@ TEST_CASE("random flood", "[pathing]") {
REQUIRE(pathing.INVARIANT());
pathing.compute_paths(walls);
pathing.random_flood({1, 2}, [&](Point at, int dnum) {
println("FLOOD: at={},{}, dnum={}", at.x, at.y, dnum);
});
}

View file

@ -1,13 +1,13 @@
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "collider.hpp"
#include "spatialmap.hpp"
#include "dinkyecs.hpp"
using DinkyECS::Entity;
using namespace fmt;
EntityList require_found(const spatial_map& collider, Point at, bool diag, size_t expect_size) {
EntityList require_found(const SpatialMap& collider, Point at, bool diag, size_t expect_size) {
println("TEST require_found at={},{}", at.x, at.y);
auto [found, nearby] = collider.neighbors(at, diag);
REQUIRE(found == true);
@ -21,7 +21,7 @@ TEST_CASE("confirm basic collision operations", "[collision]") {
Entity player = world.entity();
Entity enemy = world.entity();
spatial_map collider;
SpatialMap collider;
collider.insert({11,11}, player);
collider.insert({21,21}, enemy);
@ -70,7 +70,7 @@ TEST_CASE("confirm multiple entities moving", "[collision]") {
Entity e2 = world.entity();
Entity e3 = world.entity();
spatial_map collider;
SpatialMap collider;
collider.insert({11,11}, player);
collider.insert({10,10}, e2);
collider.insert({11,10}, e3);
@ -93,7 +93,7 @@ TEST_CASE("test edge cases that might crash", "[collision]") {
Entity player = world.entity();
Entity enemy = world.entity();
spatial_map collider;
SpatialMap collider;
collider.insert({0,0}, player);
Point enemy_at = {1, 0};
@ -115,7 +115,7 @@ TEST_CASE("check all diagonal works", "[collision]") {
Entity player = world.entity();
Entity enemy = world.entity();
spatial_map collider;
SpatialMap collider;
Point player_at = {1,1};
collider.insert(player_at, player);