aboutsummaryrefslogtreecommitdiff
path: root/src/armor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/armor.cc')
-rw-r--r--src/armor.cc31
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();
+ }
}