#include #include "components.hpp" #include "dinkyecs.hpp" using namespace components; using namespace DinkyECS; TEST_CASE("all components can work in the world", "[components]") { World world; auto ent1 = world.entity(); world.set(ent1, {ent1}); world.set(ent1, {{10,1}}); world.set(ent1, {1,0}); world.set(ent1, {100}); world.set(ent1, {0}); world.set(ent1, {"Z"}); world.set(ent1, {4}); auto player = world.get(ent1); REQUIRE(player.entity == ent1); auto position = world.get(ent1); REQUIRE(position.location.x == 10); REQUIRE(position.location.y == 1); auto motion = world.get(ent1); REQUIRE(motion.dx == 1); REQUIRE(motion.dy == 0); auto loot = world.get(ent1); REQUIRE(loot.amount == 100); auto inv = world.get(ent1); REQUIRE(inv.gold == 0); auto tile = world.get(ent1); REQUIRE(tile.chr == "Z"); auto enemy = world.get(ent1); REQUIRE(enemy.HEARING_DISTANCE == 4); } TEST_CASE("all components can be facts", "[components]") { World world; auto ent1 = world.entity(); world.set_the({ent1}); world.set_the({{10,1}}); world.set_the({1,0}); world.set_the({100}); world.set_the({0}); world.set_the({"Z"}); world.set_the({4}); auto player = world.get_the(); REQUIRE(player.entity == ent1); auto position = world.get_the(); REQUIRE(position.location.x == 10); REQUIRE(position.location.y == 1); auto motion = world.get_the(); REQUIRE(motion.dx == 1); REQUIRE(motion.dy == 0); auto loot = world.get_the(); REQUIRE(loot.amount == 100); auto inv = world.get_the(); REQUIRE(inv.gold == 0); auto tile = world.get_the(); REQUIRE(tile.chr == "Z"); auto enemy = world.get_the(); REQUIRE(enemy.HEARING_DISTANCE == 4); } TEST_CASE("confirm combat works", "[components]") { World world; auto player = world.entity(); auto enemy = world.entity(); world.set(player, {100, 10}); world.set(enemy, {20, 10}); auto p_fight = world.get(player); REQUIRE(p_fight.hp == 100); REQUIRE(p_fight.damage == 10); REQUIRE(p_fight.dead == false); auto e_fight = world.get(enemy); REQUIRE(e_fight.hp == 20); REQUIRE(e_fight.damage == 10); REQUIRE(e_fight.dead == false); for(int i = 0; e_fight.hp > 0 && i < 100; i++) { p_fight.attack(e_fight); } } TEST_CASE("MapConfig loads from JSON", "[components]") { }