#include #include "components.hpp" #include "dinkyecs.hpp" #include "config.hpp" #include #include "easings.hpp" using namespace components; using namespace DinkyECS; TEST_CASE("confirm component loading works", "[components]") { std::vector test_list{ "assets/enemies.json", "assets/items.json", "assets/devices.json"}; components::init(); DinkyECS::World world; for(auto test_data : test_list) { auto config = settings::get(test_data); auto data_list = config.json(); for(auto& [key, data] : data_list.items()) { auto& components = data["components"]; fmt::println("TEST COMPONENT: {} from file {}", key, test_data); auto ent = world.entity(); components::configure_entity(world, ent, components); auto tile = components::get(components[0]); REQUIRE(tile.display != L' '); } } } TEST_CASE("make sure json_mods works", "[components]") { auto config = settings::get("bosses"); // this confirms that loading something with an optional // field works with the json conversions in json_mods.hpp for(auto& comp_data : config["RAT_KING"]["components"]) { if(comp_data["_type"] == "AnimatedScene") { auto comp = components::convert(comp_data); // the boss fight for the rat king doesn't have a stage so false=optional REQUIRE(comp.floor == std::nullopt); } } // this then confirms everything else about the json conversion components::init(); DinkyECS::World world; auto rat_king = world.entity(); components::configure_entity(world, rat_king, config["RAT_KING"]["components"]); auto boss = world.get(rat_king); REQUIRE(boss.floor == std::nullopt); }