X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FHero.cpp;h=79581569c4002335402d9e3117069221de5714c8;hb=b9e715649b41cb69ea1b2d2a588522541eb87b46;hp=beeab8305844b8a9b2cccb95a98a66d73c8153ee;hpb=3d69f521b593457304b282e5f23e36ab165288b6;p=l2e.git diff --git a/src/common/Hero.cpp b/src/common/Hero.cpp index beeab83..7958156 100644 --- a/src/common/Hero.cpp +++ b/src/common/Hero.cpp @@ -1,6 +1,7 @@ #include "Hero.h" #include "Item.h" +#include "LevelUp.h" #include "Spell.h" #include "Upgrade.h" #include "../graphics/Animation.h" @@ -65,7 +66,7 @@ void Hero::SubtractHealth(int amount) { int Hero::NextLevel() const { int levelOffset(Level() - 1); if (levelOffset < numLevels) { - return levelLadder[levelOffset] - Experience(); + return levelLadder[levelOffset].Experience() - Experience(); } else { return 0; } @@ -80,14 +81,44 @@ void Hero::AddExperience(int exp, vector &info) { } int remain = exp; while (remain >= NextLevel()) { + const LevelUp &lup = levelLadder[level - 1]; int added = NextLevel(); experience += added; remain -= added; ++level; + maxHealth += lup.MaxHealth(); + maxMana += lup.MaxMagic(); + stats += lup; info.push_back(Upgrade(name, Upgrade::LEVEL_UP, level)); - // TODO: upgrade attributes and push info + if (lup.MaxHealth() > 0) { + info.push_back(Upgrade(name, Upgrade::MAX_HEALTH, lup.MaxHealth())); + } + if (lup.MaxMagic() > 0) { + info.push_back(Upgrade(name, Upgrade::MAX_MAGIC, lup.MaxMagic())); + } + if (lup.Attack() > 0) { + info.push_back(Upgrade(name, Upgrade::ATTACK, lup.Attack())); + } + if (lup.Defense() > 0) { + info.push_back(Upgrade(name, Upgrade::DEFENSE, lup.Defense())); + } + if (lup.Strength() > 0) { + info.push_back(Upgrade(name, Upgrade::STRENGTH, lup.Strength())); + } + if (lup.Agility() > 0) { + info.push_back(Upgrade(name, Upgrade::AGILITY, lup.Agility())); + } + if (lup.Intelligence() > 0) { + info.push_back(Upgrade(name, Upgrade::INTELLIGENCE, lup.Intelligence())); + } + if (lup.Gut() > 0) { + info.push_back(Upgrade(name, Upgrade::GUT, lup.Gut())); + } + if (lup.MagicResistance() > 0) { + info.push_back(Upgrade(name, Upgrade::MAGIC_RESISTANCE, lup.MagicResistance())); + } if (level > numLevels) { info.push_back(Upgrade( @@ -128,7 +159,7 @@ void Hero::CreateTypeDescription() { td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), Stats::TYPE_ID)); td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), Interpreter::NUMBER_ID)); - td.AddField("ladder", FieldDescription(((char *)&h.levelLadder) - ((char *)&h), Interpreter::NUMBER_ID).SetAggregate()); + td.AddField("ladder", FieldDescription(((char *)&h.levelLadder) - ((char *)&h), LevelUp::TYPE_ID).SetAggregate()); td.AddField("useMask", FieldDescription(((char *)&h.useMask) - ((char *)&h), Interpreter::NUMBER_ID));