From e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 9 May 2021 19:01:59 -0400 Subject: Code refactoring --- src/weapon.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/weapon.cc') diff --git a/src/weapon.cc b/src/weapon.cc index fe50eaf..0c4dc29 100644 --- a/src/weapon.cc +++ b/src/weapon.cc @@ -25,16 +25,16 @@ namespace entry { auto dmgs = w.getDamage(); for(size_t i = 0; i < dmgs.size(); i++) { const Damage& d = dmgs[i]; - text << d.count << "d" << d.sides; + text << d.dmg_die_count << "d" << d.dmg_die_sides; if(i == 0) { if(w.getProperties().count("versatile")) { - text << " (or " << d.count << "d" << d.sides + 2 << " if two-handed)"; + text << " (or " << d.dmg_die_count << "d" << d.dmg_die_sides + 2 << " if two-handed)"; } text << " + " << damageBonus; } - text << " " << d.type << " damage"; + text << " " << d.dmg_type << " damage"; if(i < dmgs.size()-1) { - if(d.isOr) { + if(d.is_or) { text << " or "; } else { text << " plus "; @@ -52,7 +52,7 @@ namespace entry { if(! w.Entry::getText().empty()) { text << " " << w.Entry::getText(); } - text << " " << genText(static_cast(w)); + text << " " << w.Substantial::getText(); return text.str(); } @@ -61,12 +61,12 @@ namespace entry { bool first = true; for(Damage& d : dmgs) { d.rolled = 0; - int sides = d.sides; + int sides = d.dmg_die_sides; if(first && versatile && w.getProperties().count("versatile")) { sides += 2; } first = false; - for(int i = 0; i < d.count; i++) { + for(int i = 0; i < d.dmg_die_count; i++) { d.rolled += dice::roll(sides); } } @@ -87,9 +87,9 @@ namespace entry { } else { text << dmgsNoVersatile[i].rolled; } - text << " " << dmgsNoVersatile[i].type << " damage"; + text << " " << dmgsNoVersatile[i].dmg_type << " damage"; if(i < dmgsNoVersatile.size()-1) { - if(dmgsNoVersatile[i].isOr) { + if(dmgsNoVersatile[i].is_or) { text << " or "; } else { text << " plus "; @@ -128,12 +128,12 @@ namespace entry { } - string genText(const Weapon& w, const creature::Creature& c) { + string Weapon::getText(const creature::Creature& c) const { stringstream text; - text << w.getName() << " (" << w.getType() << "): "; + text << getName() << " (" << getType() << "): "; // Determine best ability bonus - int abilityBonus = c.getBonus(creature::getBestAbility(getAbilityOptions(w), c)); - text << getTextHelper(w, to_string(abilityBonus + c.getProficiency()), to_string(abilityBonus)); + int abilityBonus = c.getBonus(creature::getBestAbility(getAbilityOptions(*this), c)); + text << getTextHelper(*this, to_string(abilityBonus + c.getProficiency()), to_string(abilityBonus)); return text.str(); } } -- cgit v1.2.3