diff options
author | Your Name <you@example.com> | 2021-05-09 19:01:59 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-09 19:01:59 -0400 |
commit | e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd (patch) | |
tree | 344c09421c5839a764a132fe9166f0e6e3f90e45 /src/weapon.cc | |
parent | d13358b71ec15085f2638fd9c3fc634df62dfc94 (diff) | |
download | dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.gz dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.bz2 dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.zip |
Code refactoring
Diffstat (limited to 'src/weapon.cc')
-rw-r--r-- | src/weapon.cc | 26 |
1 files changed, 13 insertions, 13 deletions
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<const Substantial&>(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(); } } |