summaryrefslogtreecommitdiffstats
path: root/src/game-server/item.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-19 08:05:45 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-19 08:05:45 +0000
commit31232e3a5702a7618fe40dc74f5d987a662cb081 (patch)
tree170b799b14dc950201eb7eec63c957e542e4c96d /src/game-server/item.cpp
parent2ae3f3a3ef5caee193138a3e5c1613403302089c (diff)
downloadmanaserv-31232e3a5702a7618fe40dc74f5d987a662cb081.tar.gz
manaserv-31232e3a5702a7618fe40dc74f5d987a662cb081.tar.xz
manaserv-31232e3a5702a7618fe40dc74f5d987a662cb081.zip
Added support for protective equipment.
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r--src/game-server/item.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index dc99511..1b32cdf 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -23,6 +23,8 @@
#include "game-server/item.hpp"
+#include "game-server/being.hpp"
+
int ItemModifiers::getValue(int type) const
{
for (std::vector< ItemModifier >::const_iterator i = mModifiers.begin(),
@@ -54,6 +56,34 @@ void ItemModifiers::setAttributeValue(int attr, int value)
setValue(MOD_ATTRIBUTE + attr, value);
}
+void ItemModifiers::applyAttributes(Being *b) const
+{
+ int lifetime = getValue(MOD_LIFETIME);
+ for (std::vector< ItemModifier >::const_iterator i = mModifiers.begin(),
+ i_end = mModifiers.end(); i != i_end; ++i)
+ {
+ if (i->type < MOD_ATTRIBUTE) continue;
+
+ AttributeModifier am;
+ am.attr = i->type - MOD_ATTRIBUTE;
+ am.duration = lifetime;
+ am.value = i->value;
+ // TODO: No spell currently.
+ am.level = 0;
+ b->addModifier(am);
+ }
+}
+
+void ItemModifiers::cancelAttributes(Being *b) const
+{
+ for (std::vector< ItemModifier >::const_iterator i = mModifiers.begin(),
+ i_end = mModifiers.end(); i != i_end; ++i)
+ {
+ if (i->type < MOD_ATTRIBUTE) continue;
+ b->removeEquipmentModifier(i->type - MOD_ATTRIBUTE, i->value);
+ }
+}
+
bool ItemClass::use(Being *itemUser)
{
bool usedSuccessfully = true;