aboutsummaryrefslogtreecommitdiff
path: root/src/weapon.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/weapon.cc')
-rw-r--r--src/weapon.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/weapon.cc b/src/weapon.cc
index 7ae597f..e5f04f2 100644
--- a/src/weapon.cc
+++ b/src/weapon.cc
@@ -110,27 +110,24 @@ namespace entry {
bool first = true;
for(Damage& d : dmgs) {
d.rolled = 0;
- int sides = d.dmg_die_sides;
if(first && versatile && w.getProperties().count("versatile")) {
- sides += 2;
+ d.dmg_die_sides += 2;
}
first = false;
for(int i = 0; i < d.dmg_die_count; i++) {
- d.rolled += dice::roll(sides);
+ d.rolled += dice::roll(d.dmg_die_sides);
}
}
return dmgs;
}
- string formatDmg(const Weapon& w, const creature::Creature& c) {
+ string formatDmgHelper(const Weapon& w, const creature::Creature& c, const std::vector<Damage>& dmgsNoVersatile, const std::vector<Damage>& dmgsVersatile) {
stringstream text;
- vector<Damage> dmgsNoVersatile = rollDmg(w, false);
- vector<Damage> dmgsVersatile = rollDmg(w, true);
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;
- if(w.getProperties().count("versatile")) {
+ if(w.getProperties().count("versatile") and ! dmgsVersatile.empty()) {
text << " (or " << dmgsVersatile[i].rolled + abilityBonus << " if two-handed)";
}
} else {
@@ -148,6 +145,16 @@ namespace entry {
return text.str();
}
+ string formatDmg(const Weapon& w, const creature::Creature& c) {
+ vector<Damage> dmgsNoVersatile = rollDmg(w, false);
+ vector<Damage> dmgsVersatile = rollDmg(w, true);
+ return formatDmgHelper(w, c, dmgsNoVersatile, dmgsVersatile);
+ }
+
+ string formatDmg(const Weapon& w, const creature::Creature& c, const std::vector<Damage>& dmgs) {
+ return formatDmgHelper(w, c, dmgs, {});
+ }
+
vector<rules::Ability> getAbilityOptions(const Weapon& w) {
// Do finesse
if(w.getProperties().count("finesse")) {