summaryrefslogtreecommitdiff
path: root/src/game-server/attributemanager.h
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-11-09 03:45:42 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-02 15:35:17 +0100
commit1e562bdd132c4166ca4de2bdb3f241adaa9a7149 (patch)
tree84bca9f39cfd3c05d3a315c8e9cd854b18cb4682 /src/game-server/attributemanager.h
parent4cd1957231605e976c5cf001eddea80d5e49272f (diff)
downloadmanaserv-1e562bdd132c4166ca4de2bdb3f241adaa9a7149.tar.gz
manaserv-1e562bdd132c4166ca4de2bdb3f241adaa9a7149.tar.bz2
manaserv-1e562bdd132c4166ca4de2bdb3f241adaa9a7149.tar.xz
manaserv-1e562bdd132c4166ca4de2bdb3f241adaa9a7149.zip
Added a way to specify the min and max attributes values.
This can now be done in attributes.xml through the minimum and maximum attribute parameters. I also changed the AttributeInfo struct as requested by bjorn. Reviewed-by: Erik Schilling, Thorbjørn Lindeijer
Diffstat (limited to 'src/game-server/attributemanager.h')
-rw-r--r--src/game-server/attributemanager.h62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/game-server/attributemanager.h b/src/game-server/attributemanager.h
index c4843c3a..63ebf643 100644
--- a/src/game-server/attributemanager.h
+++ b/src/game-server/attributemanager.h
@@ -24,6 +24,7 @@
#include <map>
#include <vector>
#include <string>
+#include <limits>
#include "utils/xml.h"
@@ -36,7 +37,36 @@ enum ScopeType
MaxScope
};
-typedef std::map<int, std::vector<struct AttributeInfoType> *> AttributeScope;
+/**
+ * Stackable types.
+ * @todo non-stackable malus layers
+ */
+enum StackableType
+{
+ Stackable,
+ NonStackable,
+ NonStackableBonus
+};
+
+/**
+ * Attribute augmentation methods.
+ */
+enum ModifierEffectType
+{
+ Multiplicative,
+ Additive
+};
+
+struct AttributeModifier
+{
+ AttributeModifier(StackableType s, ModifierEffectType effect) :
+ stackableType(s),
+ effectType(effect)
+ {}
+
+ StackableType stackableType;
+ ModifierEffectType effectType;
+};
/**
* Identifies a modifier by the attribute id that it applies to and its layer
@@ -59,6 +89,22 @@ struct ModifierLocation
class AttributeManager
{
public:
+ struct AttributeInfo {
+ AttributeInfo():
+ minimum(std::numeric_limits<double>::min()),
+ maximum(std::numeric_limits<double>::max()),
+ modifiable(false)
+ {}
+
+ /** The minimum and maximum permitted attribute values. */
+ double minimum;
+ double maximum;
+ /** Tells whether the base attribute is modifiable by the player */
+ bool modifiable;
+ /** Effect modifier type: stackability and modification type. */
+ std::vector<struct AttributeModifier> modifiers;
+ };
+
AttributeManager(const std::string &file) :
mAttributeReferenceFile(file)
{}
@@ -73,7 +119,10 @@ class AttributeManager
*/
void reload();
- const std::vector<struct AttributeInfoType> *getAttributeInfo(int id) const;
+ const std::vector<AttributeModifier> *getAttributeInfo(int id) const;
+
+ // being type id -> (*{ stackable type, effect type })[]
+ typedef std::map<int, AttributeInfo*> AttributeScope;
const AttributeScope &getAttributeScope(ScopeType) const;
@@ -88,17 +137,12 @@ class AttributeManager
void readAttributeNode(xmlNodePtr attributeNode);
void readModifierNode(xmlNodePtr modifierNode, int attributeId);
- // modifiable, { stackable type, effect type }[]
- typedef std::pair<bool,
- std::vector<struct AttributeInfoType> > AttributeInfoMap;
-
- // Attribute id -> { modifiable, { stackable type, effect type }[] }
- typedef std::map<int, AttributeInfoMap> AttributeMap;
+ // Attribute id -> { modifiable, min, max, { stackable type, effect type }[] }
+ typedef std::map<int, AttributeInfo> AttributeMap;
/** Maps tag names to specific modifiers. */
typedef std::map<std::string, ModifierLocation> TagMap;
- // being type id -> (*{ stackable type, effect type })[]
AttributeScope mAttributeScopes[MaxScope];
AttributeMap mAttributeMap;
TagMap mTagMap;