Abilities.hpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #ifndef Abilities_hpp
00023 #define Abilities_hpp
00024 
00025 #include "util/config/util_config.hpp"
00026 
00027 #ifndef SE_OWN_ABILITIES
00028 
00029 namespace se_core {
00030     class _SeCoreExport Abilities {
00031     public:
00032         enum AbilityType { SPEED, ATTACK, DEFENSE, XP_LEVEL, ABILITY_COUNT };
00033 
00034         Abilities();
00035         virtual ~Abilities();
00036         void setLevel(short level);
00037         short modified(enum AbilityType type) const { return bases_[ type ] + modifiers_[ type ]; }
00038         void addModifier(enum AbilityType type, short modifier) { modifiers_[ type ] += modifier; }
00039         void subtractModifier(enum AbilityType type, short modifier) { modifiers_[ type ] -= modifier; }
00040 
00041         void addModifier(Abilities& abilities) {
00042             for(int i = 0; i < ABILITY_COUNT; ++i)
00043                 modifiers_[ i ] += abilities.bases_[ i ] + abilities.modifiers_[ i ];
00044         }
00045         void subtractModifier(Abilities& abilities) {
00046             for(int i = 0; i < ABILITY_COUNT; ++i)
00047                 modifiers_[ i ] -= abilities.bases_[ i ] + abilities.modifiers_[ i ];
00048         }
00049         void setBases(short* bases);
00050         void setBases(const Abilities* src);
00051 
00052     private:
00053         short bases_[ ABILITY_COUNT ];
00054         short modifiers_[ ABILITY_COUNT ];
00055         const static short autoBases_[][ABILITY_COUNT];
00056     };
00057 #endif // SE_OWN_ABILITIES
00058 
00059 }
00060 
00061 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:11 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo