X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2FCapsule.cpp;h=487958596fe767b94a75ad20d6e403a04a3f9b4c;hb=e518ac67cf94e244df16078dcbc536e6b659e758;hp=f886724515c3db11f9d5698f3d063f3eb306c45f;hpb=5cbe0ba11d6fe180f49101547f05e7fe586d55c0;p=l2e.git diff --git a/src/common/Capsule.cpp b/src/common/Capsule.cpp index f886724..4879585 100644 --- a/src/common/Capsule.cpp +++ b/src/common/Capsule.cpp @@ -142,6 +142,35 @@ const Capsule::Class &Capsule::GetClass() const { } +int Capsule::HungerEmpty() const { + return HungerTotal() - HungerFull(); +} + +int Capsule::HungerTotal() const { + return GetClass().hunger; +} + +int Capsule::HungerFull() const { + return GetClass().hungerFull; +} + +bool Capsule::IsHungry() const { + return HungerEmpty(); +} + +void Capsule::Feed(const common::Item *) { + // TODO: find out how to calculate an item's feed value + // TODO: an item the capsule favors (changes on every feed and after every + // battle) doubles the value + int value = 1; + GetClass().hungerFull += value; + if (GetClass().hungerFull >= GetClass().hunger) { + GetClass().hungerFull = GetClass().hunger; + UpgradeClass(); + } +} + + Capsule::Class::Class() : name(0) , tribe(0) @@ -150,6 +179,9 @@ Capsule::Class::Class() , attackAnimation(0) , spellAnimation(0) +, hunger(32) +, hungerFull(0) + , healthBoost(0) { attacks[0] = 0; attacks[1] = 0; @@ -210,6 +242,8 @@ void Capsule::Class::CreateTypeDescription() { td.AddField("attackAnimation", FieldDescription(((char *)&c.attackAnimation) - ((char *)&c), Animation::TYPE_ID).SetReferenced()); td.AddField("spellAnimation", FieldDescription(((char *)&c.spellAnimation) - ((char *)&c), Animation::TYPE_ID).SetReferenced()); + td.AddField("hunger", FieldDescription(((char *)&c.hunger) - ((char *)&c), Interpreter::NUMBER_ID)); + td.AddField("healthBoost", FieldDescription(((char *)&c.healthBoost) - ((char *)&c), Interpreter::NUMBER_ID)); td.AddField("statBoost", FieldDescription(((char *)&c.statBoost) - ((char *)&c), Stats::TYPE_ID)); }