aboutsummaryrefslogtreecommitdiff
path: root/src/weapon.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-16 11:23:27 -0400
committerYour Name <you@example.com>2021-04-16 11:23:27 -0400
commit4618763c0e3a723bf4bb43c7b9edbce87240e0af (patch)
treea18aa4bf7da05ac02b4e37b199aeeb82da977aea /src/weapon.cc
parentdfce4d0398a8bafbb7ad7a31345af181c0269c09 (diff)
downloaddmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.gz
dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.bz2
dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.zip
Rebased feature/item on entry
Diffstat (limited to 'src/weapon.cc')
-rw-r--r--src/weapon.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/weapon.cc b/src/weapon.cc
index 314b1be..3a42e80 100644
--- a/src/weapon.cc
+++ b/src/weapon.cc
@@ -1,4 +1,3 @@
-#include "json.hpp"
#include "weapon.h"
#include "creature.h"
#include <string>
@@ -7,7 +6,7 @@
using namespace std;
-namespace item {
+namespace entry {
int Weapon::getDamageDieSides(bool versatile) const {
if(versatile && getProperties().count("versatile")) {
return damageDieSides + 2;
@@ -15,14 +14,19 @@ namespace item {
return damageDieSides;
}
- std::string genActionText(const Weapon& w, const creature::Creature& c) {
+ string Weapon::getText(const creature::Creature& c) const {
+ return genText(*this, c);
+ }
+
+ string genText(const Weapon& w, const creature::Creature& c) {
stringstream text;
+ text << genText(static_cast<const Item&>(w), c);
// 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, ";
+ text << ": +" << abilityBonus + c.getProficiency() << " to hit, ";
if(w.getReach() > 0) {
text << "reach " << w.getReach() << " ft.";
if(w.getRange().second > 0) {
@@ -32,7 +36,7 @@ namespace item {
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";
+ text << " Hit: " << 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)";
}
@@ -42,11 +46,9 @@ namespace item {
props.erase("finesse");
props.erase("versatile");
if(! props.empty()) {
- text << "\nAdditional properties:\n";
- for(string prop : props) {
- text << "\t" << prop << "\n";
- }
+ text << " Additional properties: " << utils::join(props, ", ") << ".";
}
+ text << " " << genText(static_cast<const Substantial&>(w));
return text.str();
}
}