1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#pragma once
#include "item.h"
#include "json.hpp"
#include <set>
namespace creature {
class Creature;
}
namespace item {
class Weapon : public Item {
public:
Weapon(const nlohmann::json& data, const nlohmann::json& base) : Item(base), damageType(data["damage"]["dmg_type"]), damageDieCount(data["damage"]["dmg_die_count"]), damageDieSides(data["damage"]["dmg_die_sides"]), properties(data["properties"]), weaponType(data["type"]), range(data["range"][0], data["range"][1]), reach(data["reach"]), cost(data["cost"]), weight(data["weight"]) {}
std::string getDamageType(void) const {return damageType;}
int getDamageDieCount(void) const {return damageDieCount;}
int getDamageDieSides(bool versatile=false) const;
std::set<std::string> getProperties(void) const {return properties;}
std::string getWeaponType(void) const {return weaponType;}
std::pair<int, int> getRange(void) const {return range;}
int getReach(void) const {return reach;}
int getCost(void) const {return cost;}
double getWeight(void) const {return weight;}
/*virtual nlohmann::json toJson(void) const {
auto data = Item::toJson();
data["damage"]["dmg_type"] = damageType;
data["damage"]["dmg_die_count"] = damageDieCount;
data["damage"]["dmg_die_sides"] = damageDieSides;
data["properties"] = properties;
data["type"] = weaponType;
data["range"] = range;
data["reach"] = reach;
data["cost"] = cost;
data["weight"] = weight;
return data;
}*/
private:
const std::string damageType;
const int damageDieCount;
const int damageDieSides;
const std::set<std::string> properties;
const std::string weaponType;
const std::pair<const int, const int> range;
const int reach;
const int cost;
const double weight;
};
std::string genActionText(const Weapon& w, const creature::Creature& c);
}
|