#define CHARACTER_H
#include <QObject>
+#include <QFile>
+#include <QXmlSimpleReader>
+#include <unordered_map>
+#include "definitions.h"
-class Character
+namespace sm::data
{
-public:
- Character();
-};
+ enum Skill {
+ acrobatics,
+ alchemy,
+ leadership,
+ arcanelore,
+ athletics,
+ performance,
+ diplomacy,
+ clscraft,
+ empathy,
+ determination,
+ dexterity,
+ history,
+ craftmanship,
+ heal,
+ stealth,
+ hunting,
+ countrylore,
+ nature,
+ eloquence,
+ locksntraps,
+ swim,
+ seafaring,
+ streetlore,
+ animals,
+ survival,
+ perception,
+ endurance,
+ antimagic,
+ controlmagic,
+ motionmagic,
+ insightmagic,
+ stonemagic,
+ firemagic,
+ healmagic,
+ illusionmagic,
+ combatmagic,
+ lightmagic,
+ naturemagic,
+ shadowmagic,
+ fatemagic,
+ protectionmagic,
+ enhancemagic,
+ deathmagic,
+ transformationmagic,
+ watermagic,
+ windmagic
+ };
+ enum Attribute {
+ charisma,
+ agility,
+ intuition,
+ constitution,
+ mystic,
+ strength,
+ mind,
+ willpower
+ };
+
+ static const std::unordered_map<Skill, std::pair<Attribute, Attribute>> skillAttributes{
+ {acrobatics, {agility, strength}},
+ {alchemy, {mystic, mind}},
+ {leadership, {charisma, willpower}},
+ {arcanelore, {mystic, mind}},
+ {athletics, {agility, strength}},
+ {performance, {charisma, willpower}},
+ {diplomacy, {charisma, mind}},
+ {clscraft, {intuition, mind}},
+ {empathy, {intuition, mind}},
+ {determination, {charisma, willpower}},
+ {dexterity, {charisma, agility}},
+ {history, {mystic, mind}},
+ {craftmanship, {constitution, mind}},
+ {heal, {intuition, mind}},
+ {stealth, {agility, intuition}},
+ {hunting, {constitution, mind}},
+ {countrylore, {intuition, mind}},
+ {nature, {intuition, mind}},
+ {eloquence, {charisma, willpower}},
+ {locksntraps, {intuition, agility}},
+ {swim, {strength, constitution}},
+ {seafaring, {agility, constitution}},
+ {streetlore, {charisma, intuition}},
+ {animals, {charisma, agility}},
+ {survival, {intuition, constitution}},
+ {perception, {intuition, willpower}},
+ {endurance, {constitution, willpower}},
+ {antimagic, {mystic, willpower}},
+ {controlmagic, {mystic, willpower}},
+ {motionmagic, {mystic, agility}},
+ {insightmagic, {mystic, mind}},
+ {stonemagic, {mystic, constitution}},
+ {firemagic, {mystic, charisma}},
+ {healmagic, {mystic, charisma}},
+ {illusionmagic, {mystic, charisma}},
+ {combatmagic, {mystic, strength}},
+ {lightmagic, {mystic, charisma}},
+ {naturemagic, {mystic, charisma}},
+ {shadowmagic, {mystic, intuition}},
+ {fatemagic, {mystic, charisma}},
+ {protectionmagic, {mystic, charisma}},
+ {enhancemagic, {mystic, strength}},
+ {deathmagic, {mystic, mind}},
+ {transformationmagic, {mystic, constitution}},
+ {watermagic, {mystic, intuition}},
+ {windmagic, {mystic, mind}}
+ };
+
+ class Character
+ {
+ public:
+ explicit Character(const QFile& file);
+ virtual ~Character() {}
+ unsigned int skill(Skill _skill) const {return skills.at(_skill);}
+ unsigned int attribute(Attribute _attribute) const {return attributes.at(_attribute);}
+
+ private:
+ const std::unordered_map<Skill, unsigned int> skills;
+ const std::unordered_map<Attribute, unsigned int> attributes;
+
+
+
+ class SkillTest
+ {
+ public:
+ SkillTest(const Character& hero, const Skill skill, const unsigned int against)
+ {
+ std::uniform_int_distribution<int> d10(1,10);
+ std::random_device generator;
+ this->d1 = d10(generator);
+ this->d2 = d10(generator);
+ this->accumulated = d1 + d2
+ + hero.skill(skill)
+ + hero.attribute(skillAttributes.at(skill).first)
+ + hero.attribute(skillAttributes.at(skill).second);
+ this->delta = accumulated - against;
+ passed = delta >= 0;
+ grade = std::abs(delta) / 3;
+ }
+
+ private:
+ unsigned int d1;
+ unsigned int d2;
+ unsigned int accumulated;
+ int delta;
+ bool passed;
+ unsigned int grade;
+ };
+ };
+}
#endif // CHARACTER_H