diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-18 22:01:11 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-18 22:01:11 +0000 |
commit | 2ae3f3a3ef5caee193138a3e5c1613403302089c (patch) | |
tree | 7262439ae9099c76e558894e992f38199d9a5a2f /src/game-server/item.cpp | |
parent | ea118bf61623bcfae4b405d1bb2381b8d80d2837 (diff) | |
download | manaserv-2ae3f3a3ef5caee193138a3e5c1613403302089c.tar.gz manaserv-2ae3f3a3ef5caee193138a3e5c1613403302089c.tar.bz2 manaserv-2ae3f3a3ef5caee193138a3e5c1613403302089c.tar.xz manaserv-2ae3f3a3ef5caee193138a3e5c1613403302089c.zip |
First part of a patch for completing the RPG system (character attributes) of TMWserv.
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r-- | src/game-server/item.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp index e3934202..dc99511d 100644 --- a/src/game-server/item.cpp +++ b/src/game-server/item.cpp @@ -23,6 +23,37 @@ #include "game-server/item.hpp" +int ItemModifiers::getValue(int type) const +{ + for (std::vector< ItemModifier >::const_iterator i = mModifiers.begin(), + i_end = mModifiers.end(); i != i_end; ++i) + { + if (i->type == type) return i->value; + } + return 0; +} + +int ItemModifiers::getAttributeValue(int attr) const +{ + return getValue(MOD_ATTRIBUTE + attr); +} + +void ItemModifiers::setValue(int type, int value) +{ + if (value) + { + ItemModifier m; + m.type = type; + m.value = value; + mModifiers.push_back(m); + } +} + +void ItemModifiers::setAttributeValue(int attr, int value) +{ + setValue(MOD_ATTRIBUTE + attr, value); +} + bool ItemClass::use(Being *itemUser) { bool usedSuccessfully = true; |