aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-07-22 17:47:49 -0400
committerYour Name <you@example.com>2021-07-22 17:47:49 -0400
commit3632c99f94b762da6c069da10f830f63017dd1c8 (patch)
tree9be0604c3d8b2d5e7d6531ef772ae25b4700118d
parent01293baa64fa905c5763020bd6c0b4903d41fc78 (diff)
downloaddmtool-3632c99f94b762da6c069da10f830f63017dd1c8.tar.gz
dmtool-3632c99f94b762da6c069da10f830f63017dd1c8.tar.bz2
dmtool-3632c99f94b762da6c069da10f830f63017dd1c8.zip
Fixed issue with edit command on a creature
-rw-r--r--src/cmd_manipulate.cc2
-rw-r--r--src/cmd_query.cc3
-rw-r--r--src/creature.cc1
-rw-r--r--src/creature.h1
4 files changed, 6 insertions, 1 deletions
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<char>{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<rules::Skill>(rollName);
rules::Ability ability = rules::tryGetAbilityOrSkill<rules::Ability>(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<std::shared_ptr<entry::Feature>> Creature::getFeatures(void) const {return data->features;}
std::vector<std::shared_ptr<entry::Item>> Creature::getInventory(void) const {return data->inventory;}
std::vector<dmgType> 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<std::shared_ptr<entry::Feature>> getFeatures(void) const;
std::shared_ptr<entry::Spellcasting> getSpellcasting(void) const;
std::vector<std::shared_ptr<entry::Item>> getInventory(void) const;