From cd57ad6e208728bafcbc8c7d7b85d88603706978 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 20 Apr 2021 12:40:37 -0400 Subject: Updated natural armor and skills --- src/rules.h | 137 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 45 deletions(-) (limited to 'src/rules.h') diff --git a/src/rules.h b/src/rules.h index c1cc6e1..8b54e8d 100644 --- a/src/rules.h +++ b/src/rules.h @@ -1,57 +1,104 @@ #pragma once +#include "jsonable.h" #include #include +#include +#include using namespace std; namespace rules { - static vector abilities {"str", "dex", "con", "int", "wis", "cha"}; - - static map skill2ability { - {"Athletics", "str"}, - {"Acrobatics", "dex"}, - {"Sleight of Hand", "dex"}, - {"Stealth", "dex"}, - {"Arcana", "int"}, - {"History", "int"}, - {"Investigation", "int"}, - {"Nature", "int"}, - {"Religion", "int"}, - {"Animal Handling", "wis"}, - {"Insight", "wis"}, - {"Medicine", "wis"}, - {"Perception", "wis"}, - {"Survival", "wis"}, - {"Deception", "cha"}, - {"Intimidation", "cha"}, - {"Performance", "cha"}, - {"Persuasion", "cha"} - }; + class Ability : public Jsonable { + public: + string getFull() const {return abilities.at(getAbbrev());} + string getAbbrev() const {return abbrev;} + virtual nlohmann::json toJson(void) const { + return getAbbrev(); + } + bool operator<(const Ability& rhs) const {return getAbbrev() < rhs.getAbbrev();} + bool operator==(const Ability& rhs) const {return getAbbrev() == rhs.getAbbrev();} + + Ability() {} + explicit Ability(const nlohmann::json& data) : abbrev(data) {} + + virtual ~Ability() {} - static map> armor { - {"light", { - {"padded", 11}, - {"leather", 11}, - {"studded leather", 12} - }}, - {"medium", { - {"hide", 12}, - {"chain shirt", 13}, - {"scale mail", 14}, - {"breastplate", 14}, - {"half plate", 15} - }}, - {"heavy", { - {"ring mail", 14}, - {"chain mail", 16}, - {"splint", 17}, - {"plate", 18} - }}, - {"misc", { - {"shield", 2}, - {"ring of protection", 1} - }} + static Ability Str() {return Ability("str");} + static Ability Dex() {return Ability("dex");} + static Ability Con() {return Ability("con");} + static Ability Int() {return Ability("int");} + static Ability Wis() {return Ability("wis");} + static Ability Cha() {return Ability("cha");} + + private: + const string abbrev; + + const map abilities { + {"str", "Strength"}, + {"dex", "Dexterity"}, + {"con", "Constitution"}, + {"int", "Intelligence"}, + {"wis", "Wisdom"}, + {"cha", "Charisma"} + }; }; + class Skill : public Jsonable { + public: + string getName() const {return name;} + Ability getAbility() const {return Ability(skill2ability.at(getName()));} + virtual nlohmann::json toJson(void) const { + return getName(); + } + bool operator<(const Skill& rhs) const {return getName() < rhs.getName();} + bool operator==(const Skill& rhs) const {return getName() == rhs.getName();} + + virtual ~Skill() {} + + static Skill Athletics() {return Skill("Athletics");} + static Skill Acrobatics() {return Skill("Acrobatics");} + static Skill SleightOfHand() {return Skill("Sleight of Hand");} + static Skill Stealth() {return Skill("Stealth");} + static Skill Arcana() {return Skill("Arcana");} + static Skill History() {return Skill("History");} + static Skill Investigation() {return Skill("Investigation");} + static Skill Nature() {return Skill("Nature");} + static Skill Religion() {return Skill("Religion");} + static Skill AnimalHandling() {return Skill("Animal Handling");} + static Skill Insight() {return Skill("Insight");} + static Skill Medicine() {return Skill("Medicine");} + static Skill Perception() {return Skill("Perception");} + static Skill Survival() {return Skill("Survival");} + static Skill Deception() {return Skill("Deception");} + static Skill Intimidation() {return Skill("Intimidation");} + static Skill Performance() {return Skill("Performance");} + static Skill Persuasion() {return Skill("Persuasion");} + + explicit Skill(const nlohmann::json& data) : name(data) {} + + private: + const string name; + + const map skill2ability { + {"Athletics", "str"}, + {"Acrobatics", "dex"}, + {"Sleight of Hand", "dex"}, + {"Stealth", "dex"}, + {"Arcana", "int"}, + {"History", "int"}, + {"Investigation", "int"}, + {"Nature", "int"}, + {"Religion", "int"}, + {"Animal Handling", "wis"}, + {"Insight", "wis"}, + {"Medicine", "wis"}, + {"Perception", "wis"}, + {"Survival", "wis"}, + {"Deception", "cha"}, + {"Intimidation", "cha"}, + {"Performance", "cha"}, + {"Persuasion", "cha"} + }; + }; } -- cgit v1.2.3