The problem with picking up items under a dead body is fixed but now need to fix combat.
This commit is contained in:
parent
97fe02d99d
commit
f84b63f0e6
7 changed files with 93 additions and 43 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "dinkyecs.hpp"
|
||||
#include "rand.hpp"
|
||||
#include <limits>
|
||||
#include <fmt/core.h>
|
||||
|
||||
using DinkyECS::Entity;
|
||||
using namespace fmt;
|
||||
|
@ -157,6 +158,34 @@ TEST_CASE("SpatialMap::get", "[spatialmap]") {
|
|||
REQUIRE(entity == item);
|
||||
}
|
||||
|
||||
TEST_CASE("SpatialMap::find", "[spatialmap-find]") {
|
||||
DinkyECS::World world;
|
||||
SpatialMap map;
|
||||
Point at{101, 31};
|
||||
DinkyECS::Entity should_collide = DinkyECS::NONE;
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
auto ent = world.entity();
|
||||
map.insert(at, ent, i == 8);
|
||||
|
||||
if(i == 8) {
|
||||
should_collide = ent;
|
||||
}
|
||||
}
|
||||
|
||||
auto collision = map.find(at, [&](auto data) -> bool {
|
||||
return data.collision;
|
||||
});
|
||||
|
||||
REQUIRE(collision == should_collide);
|
||||
|
||||
auto no_collide = map.find(at, [&](auto data) -> bool {
|
||||
return !data.collision;
|
||||
});
|
||||
|
||||
REQUIRE(no_collide != should_collide);
|
||||
}
|
||||
|
||||
TEST_CASE("SpatialMap::neighbors", "[spatialmap]") {
|
||||
DinkyECS::World world;
|
||||
SpatialMap map;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue