diff options
author | Your Name <you@example.com> | 2021-04-16 11:23:27 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-04-16 11:23:27 -0400 |
commit | 4618763c0e3a723bf4bb43c7b9edbce87240e0af (patch) | |
tree | a18aa4bf7da05ac02b4e37b199aeeb82da977aea /src/armor.cc | |
parent | dfce4d0398a8bafbb7ad7a31345af181c0269c09 (diff) | |
download | dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.gz dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.bz2 dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.zip |
Rebased feature/item on entry
Diffstat (limited to 'src/armor.cc')
-rw-r--r-- | src/armor.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/armor.cc b/src/armor.cc new file mode 100644 index 0000000..e7ed323 --- /dev/null +++ b/src/armor.cc @@ -0,0 +1,34 @@ +#include "armor.h" +#include "creature.h" +#include "entry.h" +#include <string> +#include <sstream> + +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) { + stringstream text; + text << genText(static_cast<const Item&>(a), c); + text << ": AC: " << a.getACBonus(); + if(a.getArmorType() == "light") { + text << " + dex (i.e., " << (a.getACBonus() + c.getBonus("dex")) << ")"; + } else if(a.getArmorType() == "medium") { + int actualBonus = a.getACBonus(); + actualBonus += (c.getBonus("dex") > 2)? 2 : c.getBonus("dex"); + text << " + dex max 2 (i.e., " << actualBonus << ")"; + } + if(a.getStrRequirement() > 0) { + text << ", Mininum str: " << a.getStrRequirement(); + } + if(a.stealthDisadvantage()) { + text << ", Imposes stealth disadvantage"; + } + text << ". " << genText(static_cast<const Substantial&>(a)); + return text.str(); + } +} |