#include #include #include "ai.hpp" #include "ai_debug.hpp" struct RitualAI { std::string script; ai::State start; ai::State original; ai::State goal; ai::ActionPlan plan; RitualAI(std::string script, ai::State start, ai::State goal) : script(script), start(start), original(start), goal(goal) { } RitualAI() {}; void reset() { start = original; } bool will_do(std::string name) { ai::check_valid_action(name, "RitualAI::is_able_to"); return plan.script[0].name == name; } void set_state(std::string name, bool setting) { ai::set(start, name, setting); } void update() { plan = ai::plan(script, start, goal); } void dump() { dump_script(script, start, plan.script); } }; TEST_CASE("prototype combat system ideas", "[combat]") { ai::reset(); ai::init("assets/rituals.json"); auto start = ai::load_state("initial"); auto goal = ai::load_state("final"); RitualAI ritual("actions", start, goal); ritual.set_state("has_spikes", true); ritual.update(); fmt::println("\n\n------------ TEST WILL DO PIERCE"); ritual.dump(); REQUIRE(ritual.will_do("pierce_type")); ritual.reset(); ritual.set_state("has_magick", true); ritual.set_state("has_spikes", true); ritual.update(); fmt::println("\n\n------------ TEST WILL DO MAGICK TOO"); ritual.dump(); REQUIRE(ritual.will_do("magick_type")); ritual.plan.script.pop_front(); REQUIRE(ritual.will_do("pierce_type")); ritual.reset(); ritual.set_state("has_magick", true); ritual.set_state("has_spikes", true); ritual.set_state("shiny_bauble", true); ritual.update(); fmt::println("\n\n------------ TEST WILL DO DAMAGE BOOST"); ritual.dump(); ritual.reset(); ritual.set_state("has_magick", true); ritual.set_state("cursed_item", true); ritual.set_state("shiny_bauble", true); ritual.update(); fmt::println("\n\n------------ TEST WILL DO LARGE DAMAGE BOOST"); ritual.dump(); }