From 1d2968f826f15068fab3e1d2f666ec92e9380193 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 16 Mar 2025 13:46:40 -0400 Subject: [PATCH] Move the ritual stuff to the combat namespace. --- rituals.cpp | 32 +++++++++++++++++--------------- rituals.hpp | 36 +++++++++++++++++++----------------- tests/ai.cpp | 2 +- tests/rituals.cpp | 1 + 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/rituals.cpp b/rituals.cpp index dcc1321..99dd335 100644 --- a/rituals.cpp +++ b/rituals.cpp @@ -1,23 +1,25 @@ #include "rituals.hpp" #include "ai_debug.hpp" -void RitualAI::reset() { - start = original; -} +namespace combat { + void RitualAI::reset() { + start = original; + } -bool RitualAI::will_do(std::string name) { - ai::check_valid_action(name, "RitualAI::is_able_to"); - return plan.script[0].name == name; -} + bool RitualAI::will_do(std::string name) { + ai::check_valid_action(name, "RitualAI::is_able_to"); + return plan.script[0].name == name; + } -void RitualAI::set_state(std::string name, bool setting) { - ai::set(start, name, setting); -} + void RitualAI::set_state(std::string name, bool setting) { + ai::set(start, name, setting); + } -void RitualAI::update() { - plan = ai::plan(script, start, goal); -} + void RitualAI::update() { + plan = ai::plan(script, start, goal); + } -void RitualAI::dump() { - ai::dump_script(script, start, plan.script); + void RitualAI::dump() { + ai::dump_script(script, start, plan.script); + } } diff --git a/rituals.hpp b/rituals.hpp index 90eeaa7..2706efe 100644 --- a/rituals.hpp +++ b/rituals.hpp @@ -1,23 +1,25 @@ #pragma once #include "ai.hpp" -struct RitualAI { - std::string script; - ai::State start; - ai::State original; - ai::State goal; - ai::ActionPlan plan; +namespace combat { + 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(std::string script, ai::State start, ai::State goal) : + script(script), start(start), original(start), goal(goal) + { + } - RitualAI() {}; + RitualAI() {}; - void reset(); - bool will_do(std::string name); - void set_state(std::string name, bool setting); - void update(); - void dump(); -}; + void reset(); + bool will_do(std::string name); + void set_state(std::string name, bool setting); + void update(); + void dump(); + }; +} diff --git a/tests/ai.cpp b/tests/ai.cpp index 87db0c8..52ab15e 100644 --- a/tests/ai.cpp +++ b/tests/ai.cpp @@ -217,7 +217,7 @@ TEST_CASE("confirm that cycles are avoided/detected", "[ai]") { auto start = ai::load_state("initial"); auto goal = ai::load_state("final"); - RitualAI ritual("actions", start, goal); + combat::RitualAI ritual("actions", start, goal); ritual.reset(); ritual.set_state("has_magick", true); ritual.set_state("cursed_item", true); diff --git a/tests/rituals.cpp b/tests/rituals.cpp index a6cdba1..b1164d3 100644 --- a/tests/rituals.cpp +++ b/tests/rituals.cpp @@ -2,6 +2,7 @@ #include #include "rituals.hpp" +using namespace combat; TEST_CASE("prototype combat system ideas", "[combat]") { ai::reset();