The player now has some starting items to craft a first weapon, and it is craftable in the UI.
This commit is contained in:
parent
c8a8d2b1af
commit
bc557652ba
11 changed files with 199 additions and 155 deletions
64
rituals.cpp
64
rituals.cpp
|
@ -2,8 +2,8 @@
|
|||
#include "ai_debug.hpp"
|
||||
#include "ai.hpp"
|
||||
|
||||
namespace combat {
|
||||
RitualEngine::RitualEngine(std::string config_path) :
|
||||
namespace ritual {
|
||||
Engine::Engine(std::string config_path) :
|
||||
$config(config_path)
|
||||
{
|
||||
$profile = $config["profile"];
|
||||
|
@ -31,21 +31,21 @@ namespace combat {
|
|||
}
|
||||
}
|
||||
|
||||
ai::State RitualEngine::load_state(std::string name) {
|
||||
ai::State Engine::load_state(std::string name) {
|
||||
return $states.at(name);
|
||||
}
|
||||
|
||||
ai::Action RitualEngine::load_action(std::string name) {
|
||||
ai::Action Engine::load_action(std::string name) {
|
||||
return $actions.at(name);
|
||||
}
|
||||
|
||||
RitualBlanket RitualEngine::start() {
|
||||
CraftingState Engine::start() {
|
||||
auto start = load_state("initial");
|
||||
auto goal = load_state("final");
|
||||
return {"actions", start, goal};
|
||||
}
|
||||
|
||||
void RitualEngine::set_state(RitualBlanket& ritual, std::string name, bool setting) {
|
||||
void Engine::set_state(CraftingState& ritual, std::string name, bool setting) {
|
||||
dbc::check($profile.contains(name),
|
||||
fmt::format("ritual action named {} is not in profile, look in {} config",
|
||||
name, $config.$src_path));
|
||||
|
@ -53,41 +53,41 @@ namespace combat {
|
|||
ritual.start.set($profile.at(name), setting);
|
||||
}
|
||||
|
||||
void RitualEngine::reset(RitualBlanket& ritual) {
|
||||
ritual.start = ritual.original;
|
||||
void CraftingState::reset() {
|
||||
start = original;
|
||||
}
|
||||
|
||||
void RitualEngine::plan(RitualBlanket& ritual) {
|
||||
void Engine::plan(CraftingState& ritual) {
|
||||
ritual.plan = ai::plan_actions($scripts.at(ritual.script), ritual.start, ritual.goal);
|
||||
}
|
||||
|
||||
bool RitualBlanket::will_do(std::string name) {
|
||||
bool CraftingState::will_do(std::string name) {
|
||||
if(plan.script.size() == 0) return false;
|
||||
|
||||
return plan.script[0].name == name;
|
||||
}
|
||||
|
||||
ai::Action RitualBlanket::pop() {
|
||||
ai::Action CraftingState::pop() {
|
||||
auto result = plan.script.front();
|
||||
plan.script.pop_front();
|
||||
return result;
|
||||
}
|
||||
|
||||
// BUG: maybe this should be called RitualBlanket instead?
|
||||
void RitualBlanket::dump() {
|
||||
// BUG: maybe this should be called CraftingState instead?
|
||||
void CraftingState::dump() {
|
||||
ai::dump_script(script, start, plan.script);
|
||||
}
|
||||
|
||||
bool RitualBlanket::is_combined() {
|
||||
bool CraftingState::is_combined() {
|
||||
dbc::check(!plan.script.empty(), "you are attempting to check an empty plan");
|
||||
auto& last = plan.script.back();
|
||||
return plan.script.size() > 1 && last.name == "combined";
|
||||
}
|
||||
|
||||
RitualAction RitualEngine::finalize(RitualBlanket& ritual) {
|
||||
Action Engine::finalize(CraftingState& ritual) {
|
||||
(void)ritual;
|
||||
|
||||
RitualAction result;
|
||||
Action result;
|
||||
auto effects = $config["effects"];
|
||||
|
||||
for(auto action : ritual.plan.script) {
|
||||
|
@ -95,15 +95,15 @@ namespace combat {
|
|||
auto& effect = effects[action.name];
|
||||
result.damage += int(effect["damage"]);
|
||||
result.probability *= float(effect["probability"]);
|
||||
if(effect.contains("kind")) result.kind = RitualKind(int(effect["kind"]));
|
||||
if(effect.contains("element")) result.element = RitualElement(int(effect["element"]));
|
||||
if(effect.contains("kind")) result.kind = Kind(int(effect["kind"]));
|
||||
if(effect.contains("element")) result.element = Element(int(effect["element"]));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void RitualAction::dump() {
|
||||
void Action::dump() {
|
||||
fmt::print("ritual has damage {}, prob: {}, kind: {}, element: {}; named: ",
|
||||
damage, probability, int(kind), int(element));
|
||||
|
||||
|
@ -114,19 +114,37 @@ namespace combat {
|
|||
fmt::println("\n");
|
||||
}
|
||||
|
||||
RitualAction& RitualBelt::get(int index) {
|
||||
Action& Belt::get(int index) {
|
||||
return equipped.at(index);
|
||||
}
|
||||
|
||||
void RitualBelt::equip(int index, RitualAction& action) {
|
||||
void Belt::equip(int index, Action& action) {
|
||||
equipped.insert_or_assign(index, action);
|
||||
}
|
||||
|
||||
bool RitualBelt::has(int index) {
|
||||
bool Belt::has(int index) {
|
||||
return equipped.contains(index);
|
||||
}
|
||||
|
||||
void RitualBelt::unequip(int index) {
|
||||
void Belt::unequip(int index) {
|
||||
equipped.erase(index);
|
||||
}
|
||||
|
||||
DinkyECS::Entity Blanket::add(JunkItem name) {
|
||||
auto ent = contents.entity();
|
||||
contents.set(ent, name);
|
||||
return ent;
|
||||
}
|
||||
|
||||
std::string& Blanket::get(DinkyECS::Entity ent) {
|
||||
return contents.get<JunkItem>(ent);
|
||||
}
|
||||
|
||||
bool Blanket::has(DinkyECS::Entity ent) {
|
||||
return contents.has<JunkItem>(ent);
|
||||
}
|
||||
|
||||
void Blanket::remove(DinkyECS::Entity ent) {
|
||||
contents.remove<JunkItem>(ent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue