diff options
Diffstat (limited to 'src/weapon.cc')
-rw-r--r-- | src/weapon.cc | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/weapon.cc b/src/weapon.cc index cdf4657..7ae597f 100644 --- a/src/weapon.cc +++ b/src/weapon.cc @@ -87,6 +87,8 @@ namespace entry { char first = w.Entry::getText()[0]; if('a' <= first and 'z' >= first) { text << ' '; + } else if('A' <= first and 'Z' >= first) { + text << ". "; } text << w.Entry::getText(); } @@ -124,7 +126,7 @@ namespace entry { stringstream text; vector<Damage> dmgsNoVersatile = rollDmg(w, false); vector<Damage> dmgsVersatile = rollDmg(w, true); - int abilityBonus = c.getBonus(creature::getBestAbility(getAbilityOptions(w), c)); + int abilityBonus = w.getDamageBonus(c); for(size_t i = 0; i < dmgsNoVersatile.size(); i++) { if(i == 0 and w.getType() == "weapons" and dmgsNoVersatile[0].dmg_die_sides != 1) { text << dmgsNoVersatile[i].rolled + abilityBonus; @@ -163,6 +165,27 @@ namespace entry { // Default to str return {rules::Ability::Str()}; } + + int getAbilityBonus(const creature::Creature& c, const Weapon& w, std::shared_ptr<weaponImpl> data) { + if(data->abilityOverride) { + return c.getBonus(*data->abilityOverride); + } + return c.getBonus(creature::getBestAbility(getAbilityOptions(w), c)); + } + + int Weapon::getToHitBonus(const creature::Creature& c) const { + if(data->toHitOverride) { + return *data->toHitOverride; + } + return getAbilityBonus(c, *this, data) + c.getProficiency(); + } + + int Weapon::getDamageBonus(const creature::Creature& c) const { + if(data->dmgBonusOverride) { + return *data->dmgBonusOverride; + } + return getAbilityBonus(c, *this, data); + } string Weapon::getText() const { auto abilities = getAbilityOptions(*this); @@ -184,16 +207,9 @@ namespace entry { string Weapon::getText(const creature::Creature& c) const { stringstream text; text << getName() << " (" << getType() << "): "; - // Determine best ability bonus - int abilityBonus = c.getBonus(creature::getBestAbility(getAbilityOptions(*this), c)); - if(data->abilityOverride) { - abilityBonus = c.getBonus(*data->abilityOverride); - } - string toHitString = data->toHitOverride ? to_string(*data->toHitOverride) : to_string(abilityBonus + c.getProficiency()); - if(data->dmgBonusOverride) { - abilityBonus = *data->dmgBonusOverride; - } - text << getTextHelper(*this, toHitString, to_string(abilityBonus)); + string toHitString = to_string(getToHitBonus(c)); + string dmgBonus = to_string(getDamageBonus(c)); + text << getTextHelper(*this, toHitString, dmgBonus); return text.str(); } } |