Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Skill.h

00001 /*
00002  * Skill.h -- class interface for skills
00003  * Copyright (C) 2002  Eric Lemings <elemings@users.sourceforge.net>
00004  *
00005  * This software is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This software is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA
00019  *
00020  * RCS: $Id: Skill.h,v 1.8 2003/04/18 01:41:02 elemings Exp $
00021  */
00022 
00023 #ifdef __cplusplus
00024 
00025 #  ifndef OGS_CORE_SKILL_H
00026 #    define OGS_CORE_SKILL_H
00027 
00028 #    include <ogs/Support.h>
00029 #    include <ogs/core/Ability.h>
00030 #    include <ogs/core/Experience.h>
00031 #    include <ogs/core/Modifier.h>
00032 #    include <ogs/core/Modifiers.h>
00033 #    include <ogs/core/Namespace.h>
00034 
00035 OGS_BEGIN_CORE_NAMESPACE
00036 
00057 class Skill: public ogs::support::Object {
00058   public:
00062     typedef int Type;
00063 
00068     typedef unsigned short int Points;
00069 
00074     typedef unsigned short int Ranks;
00075 
00076     static Points getMaximumPoints (XP::Level xpLevel);
00077     static XP::Level getMaximumPointsLevel (Points points);
00078 
00079     Skill (Type type, Ability::Type keyAbility,
00080            bool useUntrained, bool useArmorPenalty,
00081            Points cclassPoints = 0);
00082     virtual ~Skill () { }
00083 
00084     Type getType () const;
00085     Ability::Type getKeyAbility () const;
00086     bool useUntrained () const;
00087     bool useArmorPenalty () const;
00088 
00089     Points getMaximumPoints () const;
00090     void setMaximumPoints (Points points);
00091     Ranks getMaximumRanks () const;
00092     Points getCurrentPoints (bool cclassSkill = true) const;
00093     void setCurrentPoints (Points points, bool cclassSkill = true);
00094     Ranks getCurrentRanks () const;
00095     Modifiers& getModifiers ();
00096 
00097   protected:
00098     static Ranks getRanks (Points cclassPoints, Points xclassPoints);
00099     bool checkMaximumRanks (Points points, bool cclassSkill);
00100 
00101   private:
00102     Type _type;
00103     Ability::Type _keyAbility;
00104     bool _useUntrained;
00105     bool _useArmorPenalty;
00106     Points _cclassPoints;
00107     Points _xclassPoints;
00108     Points _maxPoints;
00109     Modifier _rankModifier;
00110     Modifiers _modifiers;
00111 };
00112 
00118 inline Skill::Type
00119 Skill::getType () const {
00120   return (this->_type);
00121 }
00122 
00129 inline Ability::Type
00130 Skill::getKeyAbility () const {
00131   return (this->_keyAbility);
00132 }
00133 
00140 inline bool
00141 Skill::useUntrained () const {
00142   return (this->_useUntrained);
00143 }
00144 
00150 inline bool
00151 Skill::useArmorPenalty () const {
00152   return (this->_useArmorPenalty);
00153 }
00154 
00165 inline Skill::Points
00166 Skill::getMaximumPoints (XP::Level xpLevel) {
00167   return (xpLevel < 1? 0: xpLevel + 3);
00168 }
00169 
00177 inline XP::Level
00178 Skill::getMaximumPointsLevel (Points points) {
00179   return (points < 4? 0: points - 3);
00180 }
00181 
00193 inline Skill::Points
00194 Skill::getMaximumPoints () const {
00195   return (this->_maxPoints);
00196 }
00197 
00206 inline Skill::Ranks
00207 Skill::getMaximumRanks () const {
00208   return (this->_cclassPoints > 0? this->_maxPoints:
00209           this->_maxPoints / 2);
00210 }
00211 
00222 inline Skill::Points
00223 Skill::getCurrentPoints (bool cclassSkill) const {
00224   return (cclassSkill? this->_cclassPoints: this->_xclassPoints);
00225 }
00226 
00234 inline Skill::Ranks
00235 Skill::getCurrentRanks () const {
00236   return (getRanks (this->_cclassPoints, this->_xclassPoints));
00237 }
00238 
00244 inline Modifiers&
00245 Skill::getModifiers () {
00246   return (this->_modifiers);
00247 }
00248 
00255 inline Skill::Ranks
00256 Skill::getRanks (Points cclassPoints, Points xclassPoints) {
00257   return (cclassPoints + (xclassPoints / 2));
00258 }
00259 
00260 OGS_END_CORE_NAMESPACE
00261 
00262 #  endif /* !defined OGS_CORE_SKILL_H */
00263 
00264 #endif /* defined __cplusplus */
00265 

Generated on Sun Apr 20 03:36:25 2003 for Open Gaming System (OGS) by doxygen1.3