#define CHARACTER_H
#include <QObject>
-#include <QFile>
-#include <QXmlSimpleReader>
-#include <unordered_map>
-#include "definitions.h"
+#include <QSharedDataPointer>
namespace sm::data
{
- 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 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
- };
+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}}
- };
+enum Damage {
+ canalised,
+ exhausted,
+ used
+};
- 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);}
+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}}
+};
- private:
- const std::unordered_map<Skill, unsigned int> skills;
- const std::unordered_map<Attribute, unsigned int> attributes;
+class Character
+{
+public:
+ explicit Character ();
+ virtual ~Character();
+ unsigned int skill (Skill skill) const;
+ unsigned int attribute (Attribute attribute) const;
+ unsigned int life () const;
+ struct SkillTest {
+ SkillTest (bool _passed, unsigned int _grades, unsigned int _sv, unsigned int _a1v, unsigned int _a2v, unsigned int _d1,
+ unsigned int _d2)
+ : passed (_passed)
+ , grades (_grades)
+ , skillValue (_sv)
+ , attribute1Value (_a1v)
+ , attribute2Value (_a2v)
+ , d1 (_d1)
+ , d2 (_d2)
+ {}
+ const bool passed;
+ const unsigned int grades;
+ const unsigned int skillValue;
+ const unsigned int attribute1Value;
+ const unsigned int attribute2Value;
+ const unsigned int d1;
+ const unsigned int d2;
+ };
+ SkillTest testSkill (Skill skill, unsigned int against) const;
- 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:
+ class CharacterData;
+ QSharedDataPointer<CharacterData> d;
- private:
- unsigned int d1;
- unsigned int d2;
- unsigned int accumulated;
- int delta;
- bool passed;
- unsigned int grade;
- };
- };
+};
}
#endif // CHARACTER_H