From 3632c99f94b762da6c069da10f830f63017dd1c8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 22 Jul 2021 17:47:49 -0400 Subject: Fixed issue with edit command on a creature --- src/cmd_manipulate.cc | 2 +- src/cmd_query.cc | 3 +++ src/creature.cc | 1 + src/creature.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cmd_manipulate.cc b/src/cmd_manipulate.cc index 2dff5e1..b221c1f 100644 --- a/src/cmd_manipulate.cc +++ b/src/cmd_manipulate.cc @@ -201,7 +201,7 @@ namespace cmd { std::ifstream in(tmp); std::string newText(std::istreambuf_iterator{in}, {}); e->setText(newText); - utils::saveJson(*e, p); + utils::saveJson(e->serialize(), p); return ""; } diff --git a/src/cmd_query.cc b/src/cmd_query.cc index 7d4e6d6..deff049 100644 --- a/src/cmd_query.cc +++ b/src/cmd_query.cc @@ -26,6 +26,9 @@ namespace cmd { text << name << " " << type << ": " << rolled << " (d20) + " << bonus << " (" << name << " " << type << " bonus) = " << rolled + bonus << std::endl; }; // Search through skills, saves, and attacks to roll + if(rollName == "init" or rollName == "initiative") { + printResults("Initiative", "check", rolled, c->getInitiative()); + } rules::Skill skill = rules::tryGetAbilityOrSkill(rollName); rules::Ability ability = rules::tryGetAbilityOrSkill(rollName); if(skill) { diff --git a/src/creature.cc b/src/creature.cc index 6069285..f48888c 100644 --- a/src/creature.cc +++ b/src/creature.cc @@ -60,6 +60,7 @@ namespace creature { int Creature::getScore(const rules::Ability& ability) const {return data->stats.at(ability);} int Creature::getBonus(const rules::Ability& ability) const {return std::floor((getScore(ability) - 10) / 2.0);} int Creature::getProficiency(void) const {return data->prof;} + int Creature::getInitiative(void) const {return getBonus(rules::Ability::Dex());} std::vector> Creature::getFeatures(void) const {return data->features;} std::vector> Creature::getInventory(void) const {return data->inventory;} std::vector Creature::getDmgImmunities(void) const {return data->d_immunities;} diff --git a/src/creature.h b/src/creature.h index c343482..2424084 100644 --- a/src/creature.h +++ b/src/creature.h @@ -66,6 +66,7 @@ namespace creature { int getScore(const rules::Ability& ability) const; int getBonus(const rules::Ability& ability) const; int getProficiency(void) const; + int getInitiative(void) const; std::vector> getFeatures(void) const; std::shared_ptr getSpellcasting(void) const; std::vector> getInventory(void) const; -- cgit v1.2.3