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

Character.h

00001 /*
00002  * Character.h -- class interface for characters
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: Character.h,v 1.7 2003/04/13 05:25:51 elemings Exp $
00021  */
00022 
00023 #ifdef __cplusplus
00024 
00025 #  ifndef OGS_CORE_CHARACTER_H
00026 #    define OGS_CORE_CHARACTER_H
00027 
00028 #    include <vector>
00029 #    include <map>
00030 
00031 #    include <ogs/Support.h>
00032 #    include <ogs/core/Creature.h>
00033 #    include <ogs/core/Die.h>
00034 #    include <ogs/core/Experience.h>
00035 #    include <ogs/core/Skill.h>
00036 #    include <ogs/core/Namespace.h>
00037 
00038 OGS_BEGIN_CORE_NAMESPACE
00039 
00040 class CClass;
00041 class Feat;
00042 class Ability;
00043 
00050 class Character: public ogs::support::Object,
00051                  public ogs::support::Observer {
00052   public:
00053     class Advance;
00054 
00055     Character (Creature& creature, CClass& cclass);
00056 
00057     Creature& getCreature () const;
00058     XP::Points getPoints () const;
00059     void setPoints (XP::Points xpPoints);
00060     XP::Level getLevel () const;
00061 
00062     const Advance& getAdvance (XP::Level xpLevel) const;
00063     bool canAdvance () const;
00064     void advanceCClass (CClass& cclass);
00065     Skill::Points getSkillPoints () const;
00066     bool canIncreaseAbility () const;
00067 
00068   private:
00069     typedef std::vector<Advance> AdvanceOrder;
00070 
00071     Creature* _creature;
00072     XP::Points _xpPoints;
00073     AdvanceOrder _advanceOrder;
00074 };
00075 
00084 class Character::Advance {
00085   public:
00086     Advance ();
00087     Advance (CClass& cclass);
00088 
00089     CClass& getCClass () const;
00090     Die::Value getHitPoints () const;
00091     Skill::Points getSkillPoints () const;
00092     void addSkill (Skill* skill, Skill::Points skillPoints);
00093     Ability* getAbilityIncrease () const;
00094     void increaseAbility (Ability* ability);
00095 
00096   private:
00097     typedef std::map<Skill*, Skill::Points> Skills;
00098     typedef std::vector<Feat*> Feats;
00099 
00100     CClass* _cclass;
00101     Die::Value _hitPoints;
00102     Ability* _ability;
00103     Skills _skills;
00104     Feats _feats;
00105 };
00106 
00112 inline Creature&
00113 Character::getCreature () const {
00114   return (*(this->_creature));
00115 }
00116 
00122 inline XP::Points
00123 Character::getPoints () const {
00124   return (this->_xpPoints);
00125 }
00126 
00133 inline XP::Level
00134 Character::getLevel () const {
00135   return (XP::getLevel (this->_xpPoints));
00136 }
00137 
00143 inline bool
00144 Character::canAdvance () const {
00145   return (getLevel () > this->_advanceOrder.size ());
00146 }
00147 
00153 inline CClass&
00154 Character::Advance::getCClass () const {
00155   return (*(this->_cclass));
00156 }
00157 
00163 inline Ability*
00164 Character::Advance::getAbilityIncrease () const {
00165   return (this->_ability);
00166 }
00167 
00168 OGS_END_CORE_NAMESPACE
00169 
00170 #  endif /* !defined OGS_CORE_CHARACTER_H */
00171 
00172 #endif /* defined __cplusplus */
00173 

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