From 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 29 Apr 2021 14:17:08 -0400 Subject: Removed data files from repo --- src/armor.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/armor.cc') 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(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(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(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(); + } } -- cgit v1.2.3