X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FCapsule.cpp;h=083931c5c0a6a2835e933b4134aa0a5c1149879d;hb=8f4cb4e8ad954ba73fb78a030c969c933a7ed60c;hp=6667068c3c8299dc11268faa889d4cba9a383a8e;hpb=e8283bf94624b2f184d50dc1401bf45225c529d6;p=l2e.git diff --git a/src/common/Capsule.cpp b/src/common/Capsule.cpp index 6667068..083931c 100644 --- a/src/common/Capsule.cpp +++ b/src/common/Capsule.cpp @@ -17,6 +17,7 @@ using graphics::Sprite; using loader::FieldDescription; using loader::Interpreter; using loader::TypeDescription; +using std::vector; namespace common { @@ -81,6 +82,30 @@ int Capsule::NextLevel() const { } } +void Capsule::AddExperience(int exp, vector &info) { + if (level > numLevels) { + // don't award any experience if at highest level + return; + } + int remain = exp; + while (remain >= NextLevel()) { + int added = NextLevel(); + experience += added; + remain -= added; + ++level; + + info.push_back(Hero::UpgradeInfo(Hero::UPGRADE_LVL, level)); + + // TODO: upgrade attributes and push info + + if (level > numLevels) { + return; + } + } + experience += remain; +} + + void Capsule::UpgradeClass() { ++maxClass; ++curClass;