diff options
author | Your Name <you@example.com> | 2021-04-29 14:17:08 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-04-29 14:17:08 -0400 |
commit | 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (patch) | |
tree | 75c5466d459c793430a6481cd276a624cd843794 /src/armor.cc | |
parent | cd57ad6e208728bafcbc8c7d7b85d88603706978 (diff) | |
download | dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.gz dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.bz2 dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.zip |
Removed data files from repo
Diffstat (limited to 'src/armor.cc')
-rw-r--r-- | src/armor.cc | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/armor.cc b/src/armor.cc index 54284c7..85c5bc2 100644 --- a/src/armor.cc +++ b/src/armor.cc @@ -8,21 +8,13 @@ using namespace std; namespace entry{ - string Armor::getText(const creature::Creature& c) const { - return genText(*this, c); - } - - string genText(const Armor& a, const creature::Creature& c) { + string getTextHelper(const Armor& a, string dexBonusLight, string dexBonusMedium) { stringstream text; - text << genText(static_cast<const Item&>(a), c); - text << ": AC: " << a.getACBonus(); + text << "AC: " << a.getACBonus(); if(a.getArmorType() == "light") { - text << " + dex (i.e., " << (a.getACBonus() + c.getBonus(rules::Ability::Dex())) << ")"; + text << " + dex" << dexBonusLight; } else if(a.getArmorType() == "medium") { - int actualBonus = a.getACBonus(); - int dex = c.getBonus(rules::Ability::Dex()); - actualBonus += (dex > 2)? 2 : dex; - text << " + dex max 2 (i.e., " << actualBonus << ")"; + text << " + dex max 2" << dexBonusMedium; } if(a.getStrRequirement() > 0) { text << ", Mininum str: " << a.getStrRequirement(); @@ -33,4 +25,19 @@ namespace entry{ text << ". " << genText(static_cast<const Substantial&>(a)); return text.str(); } + + string Armor::getText() const { + return getTextHelper(*this, "", ""); + } + + + string genText(const Armor& a, const creature::Creature& c) { + stringstream text; + text << genText(static_cast<const Item&>(a), c); + int dex = c.getBonus(rules::Ability::Dex()); + string dexBonusLight = " (i.e., " + to_string(a.getACBonus() + dex) + ")"; + string dexBonusMedium = " (i.e., " + to_string(a.getACBonus() + ((dex > 2)? 2 : dex)) + ")"; + text << ": " << getTextHelper(a, dexBonusLight, dexBonusMedium); + return text.str(); + } } |