#include "json.hpp" #include "weapon.h" #include "creature.h" #include #include #include using namespace std; namespace item { int Weapon::getDamageDieSides(bool versatile) const { if(versatile && getProperties().count("versatile")) { return damageDieSides + 2; } return damageDieSides; } std::string genActionText(const Weapon& w, const creature::Creature& c) { stringstream text; // Determine best ability bonus int abilityBonus = c.getBonus("str"); if(w.getProperties().count("finesse")) { abilityBonus = max(abilityBonus, c.getBonus("dex")); } text << "+" << abilityBonus + c.getProficiency() << " to hit, "; if(w.getReach() > 0) { text << "reach " << w.getReach() << " ft."; if(w.getRange().second > 0) { text << " or "; } } if(w.getRange().second > 0) { text << "range " << w.getRange().first << "/" << w.getRange().second << " ft."; } text << "\nHit: " << w.getDamageDieCount() << "d" << w.getDamageDieSides() << " + " << abilityBonus << " " << w.getDamageType() << " damage"; if(w.getProperties().count("versatile")) { text << " (or " << w.getDamageDieCount() << "d" << w.getDamageDieSides(true) << " + " << abilityBonus << " " << w.getDamageType() << " damage if two-handed)"; } text << "."; auto props = w.getProperties(); // We don't care about finesse nor versatile because they're already handled props.erase("finesse"); props.erase("versatile"); if(! props.empty()) { text << "\nAdditional properties:\n"; for(string prop : props) { text << "\t" << prop << "\n"; } } return text.str(); } }