[ogs-changes] dist/c++/ogs/core Types.h,NONE,1.1 Abilities.h,1.4,1.5 Ability.cpp,1.6,1.7 Ability.h,1
Status: Alpha
Brought to you by:
elemings
Update of /cvsroot/ogs/dist/c++/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv8930
Modified Files:
Abilities.h Ability.cpp Ability.h BodyPart.cpp BodyPart.h
CClass.cpp CClass.h Character.cpp Character.h Creature.cpp
Creature.h Defense.h Entity.cpp Entity.h Experience.cpp
Experience.h Feat.cpp Feat.h Item.cpp Makefile.am Modifier.h
Modifiers.cpp Modifiers.h Saves.h Skill.cpp Skill.h
Added Files:
Types.h
Removed Files:
Defense.cpp
Log Message:
See C++ ChangeLog (Apr 13) for details.
--- NEW FILE: Types.h ---
/*
* Types.h -- interface for common type definitions
* Copyright (C) 2003 Eric Lemings <ele...@us...>
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA
*
* RCS: $Id: Types.h,v 1.1 2003/04/13 05:25:51 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_TYPES_H
# define OGS_CORE_TYPES_H
# include <list>
# include <boost/shared_ptr.hpp>
# include <ogs/core/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
class Ability;
class Feature;
class Feat;
class Skill;
/** A smart pointer that holds an ability object. */
typedef boost::shared_ptr<Ability> AbilityPtr;
/** A smart pointer that holds a feature object. */
typedef boost::shared_ptr<Feature> FeaturePtr;
/** A list of features. */
typedef std::list<FeaturePtr> Features;
/** A smart pointer that holds a feat object. */
typedef boost::shared_ptr<Feat> FeatPtr;
/** A list of feat. */
typedef std::list<FeatPtr> Feats;
/** A smart pointer that holds a skill object. */
typedef boost::shared_ptr<Skill> SkillPtr;
/** A list of skill. */
typedef std::list<SkillPtr> Skills;
OGS_END_CORE_NAMESPACE
# endif /* !defined OGS_CORE_TYPES_H */
#endif /* defined __cplusplus */
Index: Abilities.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Abilities.h 8 Apr 2003 21:43:08 -0000 1.4
--- Abilities.h 13 Apr 2003 05:25:51 -0000 1.5
***************
*** 28,40 ****
# include <map>
- # include <boost/shared_ptr.hpp>
-
# include <ogs/core/Ability.h>
OGS_BEGIN_CORE_NAMESPACE
- /** A smart pointer that holds a dynamically allocated ability score. */
- typedef boost::shared_ptr<Ability> AbilityPtr;
-
/**
* A set of ability scores. Abilities are normally complete sets. A
--- 28,37 ----
# include <map>
# include <ogs/core/Ability.h>
+ # include <ogs/core/Namespace.h>
+ # include <ogs/core/Types.h>
OGS_BEGIN_CORE_NAMESPACE
/**
* A set of ability scores. Abilities are normally complete sets. A
***************
*** 59,63 ****
Abilities ();
Abilities (Ability::Method& method);
! Abilities (PartialMethod& directMethod);
Iterator getBegin ();
--- 56,60 ----
Abilities ();
Abilities (Ability::Method& method);
! Abilities (PartialMethod& partialMethod);
Iterator getBegin ();
***************
*** 76,82 ****
/**
* A method that directly maps ability types to ability scores. The
! * partial method can be used to directly create a set of abilities with
! * preset scores. It can also be used to create partial sets of
! * abilities.
*/
struct Abilities::PartialMethod: public Ability::Method,
--- 73,78 ----
/**
* A method that directly maps ability types to ability scores. The
! * partial method can be used to directly create a complete or partial
! * set of abilities with preset scores.
*/
struct Abilities::PartialMethod: public Ability::Method,
***************
*** 84,110 ****
/** A pair of ability type and ability score. */
typedef Abilities::ScoreMap::value_type Value;
- /** An iterator of values. */
- typedef Abilities::ScoreMap::iterator Iterator;
! PartialMethod (Iterator first, Iterator last);
bool hasAbility (Ability::Type type);
Ability::Score operator() (Ability::Type type);
};
-
- /**
- * Create a new direct method. A direct method is created from a
- * sequence of pairs of ability types and ability scores. The iterators
- * point to the first and last element of this sequence. The sequence
- * may describe a partial set of ability scores: all six ability pairs
- * need not be present.
- *
- * @param first Iterator to first pair of ability type and score.
- * @param first Iterator to last pair of ability type and score.
- */
- inline
- Abilities::PartialMethod::PartialMethod (Iterator first, Iterator last):
- ScoreMap (first, last) {
- // empty constructor body
- }
/**
--- 80,103 ----
/** A pair of ability type and ability score. */
typedef Abilities::ScoreMap::value_type Value;
! /**
! * Create a new partial method. A partial method is created from a
! * sequence of pairs of ability types and ability scores. The
! * iterators point to the first and just past the last element of this
! * sequence. The sequence may describe a partial set of ability
! * scores: all six ability pairs need not be present.
! *
! * @param first Iterator to first pair of ability type and score.
! * @param last Iterator to last pair of ability type and score.
! */
! template <class _InputIterator>
! PartialMethod (_InputIterator first, _InputIterator last):
! ScoreMap (first, last) {
! // empty constructor body
! }
!
bool hasAbility (Ability::Type type);
Ability::Score operator() (Ability::Type type);
};
/**
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Ability.cpp 8 Apr 2003 21:43:08 -0000 1.6
--- Ability.cpp 13 Apr 2003 05:25:51 -0000 1.7
***************
*** 31,35 ****
using ogs::core::Ability;
using ogs::core::Die;
! using ogs::core::Experience;
using ogs::core::Modifier;
--- 31,35 ----
using ogs::core::Ability;
using ogs::core::Die;
! using ogs::core::XP;
using ogs::core::Modifier;
***************
*** 89,101 ****
/**
* Determine experience level required for a given number of ability
! * increases. This method is the inverse of
! * {@link #getIncreaseCount(xpLevel)}.
*
* @param increaseCount Number of ability increases available.
* @return Required experience level of character.
*/
! Experience::Level
! Ability::getIncreaseCountLevel (unsigned increaseCount) {
! Experience::Level xpLevel = 0;
while (getIncreaseCount (xpLevel) < increaseCount) {
--- 89,100 ----
/**
* Determine experience level required for a given number of ability
! * increases. This method is the inverse of the getIncreaseCount()
! * function.
*
* @param increaseCount Number of ability increases available.
* @return Required experience level of character.
*/
! XP::Level Ability::getIncreaseCountLevel (unsigned increaseCount) {
! XP::Level xpLevel = 0;
while (getIncreaseCount (xpLevel) < increaseCount) {
***************
*** 108,112 ****
/**
* Create a new ability. The ability score is rolled using the standard
! * method. The ability score has no modifiers.
*
* @param type A type of ability.
--- 107,112 ----
/**
* Create a new ability. The ability score is rolled using the standard
! * method. The ability has no score modifiers and the ability modifier
! * is created with the proper value determined from the ability score.
*
* @param type A type of ability.
***************
*** 129,134 ****
/**
! * Create a new ability using a method. The ability score has no
! * modifiers.
*
* @param type A type of ability.
--- 129,135 ----
/**
! * Create a new ability using a method. The ability has no score
! * modifiers and the ability modifier is created with the proper value
! * determined from the ability score.
*
* @param type A type of ability.
***************
*** 157,177 ****
* @param event Event that occurred.
*/
! void Ability::handleEvent (Event& event) {
! try {
! //Modifiers::Event& realEvent = dynamic_cast<Modifiers::Event&> (event);
! Event event (*this);
! //Event event (*this, realEvent.getPreviousValue ());
// The current score may change without the modifier value needing
// to be updated. So update it only when neccessary.
! Score currentScore = getCurrentScore ();
! Modifier::Value value = getModifier (currentScore);
if (this->_modifier.getValue () != value) {
this->_modifier.setValue (value);
}
! notifyObservers (event);
! } catch (...) {
! // Observed object was not a modifiers list. Ignore it.
}
}
--- 158,176 ----
* @param event Event that occurred.
*/
! void Ability::handleEvent (ogs::support::Event& event) {
! Modifiers::Event* modifiersEvent = NULL;
!
! modifiersEvent = dynamic_cast<Modifiers::Event*> (&event);
! if (modifiersEvent != NULL) {
! Event abilityEvent (*this, *modifiersEvent);
// The current score may change without the modifier value needing
// to be updated. So update it only when neccessary.
! Modifier::Value value = getModifier (getCurrentScore ());
if (this->_modifier.getValue () != value) {
this->_modifier.setValue (value);
}
! notifyObservers (abilityEvent);
}
}
Index: Ability.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Ability.h 8 Apr 2003 21:43:08 -0000 1.5
--- Ability.h 13 Apr 2003 05:25:51 -0000 1.6
***************
*** 37,41 ****
* A basic characteristic of an entity. Abilities are most often
* associated with creatures although certain entities, such as powerful
! * magic items, can also have abilities.. The value of an ability is
* called an ability score. Ability scores are non-negative integer
* values that can range from 0 up to 20, 30, or even 50 but rarely if
--- 37,41 ----
* A basic characteristic of an entity. Abilities are most often
* associated with creatures although certain entities, such as powerful
! * magic items, can also have abilities. The value of an ability is
* called an ability score. Ability scores are non-negative integer
* values that can range from 0 up to 20, 30, or even 50 but rarely if
***************
*** 50,54 ****
*/
class Ability: public ogs::support::Object,
! public ogs::support::Observer {
public:
/**
--- 50,54 ----
*/
class Ability: public ogs::support::Object,
! private ogs::support::Observer {
public:
/**
***************
*** 72,76 ****
*
* @see Defense
! * @see Saves::ref
*/
DEX,
--- 72,76 ----
*
* @see Defense
! * @see Saves
*/
DEX,
***************
*** 80,84 ****
* modifier is added to hit die rolls and Fortitude saving throws.
*
! * @see Saves::fort
*/
CON,
--- 80,84 ----
* modifier is added to hit die rolls and Fortitude saving throws.
*
! * @see Saves
*/
CON,
***************
*** 91,95 ****
* modifier is added to all Will saving throws.
*
! * @see Saves::will
*/
WIS,
--- 91,95 ----
* modifier is added to all Will saving throws.
*
! * @see Saves
*/
WIS,
***************
*** 111,117 ****
struct DirectMethod;
static bool isValidType (int i);
! static unsigned getIncreaseCount (Experience::Level xpLevel);
! static Experience::Level getIncreaseCountLevel (unsigned count);
Ability (Type type);
--- 111,119 ----
struct DirectMethod;
+ class Event;
+
static bool isValidType (int i);
! static unsigned getIncreaseCount (XP::Level xpLevel);
! static XP::Level getIncreaseCountLevel (unsigned count);
Ability (Type type);
***************
*** 124,129 ****
Modifier& getModifier ();
- void handleEvent (ogs::support::Event& event);
-
private:
Type _type;
--- 126,129 ----
***************
*** 133,149 ****
static Score rollStandard ();
- static Score rollAverage ();
static Score rollHighPowered ();
static Modifier::Value getModifier (Score score);
};
/**
! * A function object that generates an ability score. The argument of a
! * method is the type of ability score to generate. A method may ignore
! * this parameter.
*/
struct Ability::Method {
virtual Ability::Score operator() (Ability::Type type) = 0;
virtual ~Method () { }
};
--- 133,160 ----
static Score rollStandard ();
static Score rollHighPowered ();
static Modifier::Value getModifier (Score score);
+
+ void handleEvent (ogs::support::Event& event);
};
/**
! * A function object that generates an ability score. Methods may be
! * random methods (methods that generate random scores by rolling dice)
! * or interactive methods (methods that require interaction with an
! * external agent).
*/
struct Ability::Method {
+ /**
+ * Generate an ability score for an ability type. The argument of a
+ * method is the type of ability score to generate. A method may
+ * ignore this parameter.
+ *
+ * @param type A type of ability.
+ * @return An ability score.
+ */
virtual Ability::Score operator() (Ability::Type type) = 0;
+
virtual ~Method () { }
};
***************
*** 180,184 ****
*/
Ability::Score operator() (Ability::Type) {
! return (Ability::rollAverage ());
}
};
--- 191,195 ----
*/
Ability::Score operator() (Ability::Type) {
! return (Score (Die::roll (Die::d6, 3)));
}
};
***************
*** 244,260 ****
/**
- * Produce an ability score using the average method. With
- * the average method, three d6 die are rolled and added together.
- * This method produces average ability scores and is normally used
- * for common non-player characters.
- *
- * @return An ability score.
- */
- inline Ability::Score
- Ability::rollAverage () {
- return (Score (Die::roll (Die::d6, 3)));
- }
-
- /**
* Calculate the ability score modifier for an ability score. The
* modifier of an ability score (M) is calculated from an ability
--- 255,258 ----
***************
*** 277,281 ****
*/
inline unsigned
! Ability::getIncreaseCount (Experience::Level xpLevel) {
return (xpLevel == 0? 0: xpLevel / 4);
}
--- 275,279 ----
*/
inline unsigned
! Ability::getIncreaseCount (XP::Level xpLevel) {
return (xpLevel == 0? 0: xpLevel / 4);
}
***************
*** 292,296 ****
/**
! * Determine the modifiers added to this ability score.
*
* @return A list of modifiers added to this ability score.
--- 290,296 ----
/**
! * Determine the modifiers added to this ability score. Changes made to
! * the object returned by this function will be directly reflected in
! * the current score and ability modifier.
*
* @return A list of modifiers added to this ability score.
***************
*** 312,322 ****
/**
! * Access the modifier from this ability.
*
! * @return Modifier from this ability.
*/
inline Modifier&
Ability::getModifier () {
return (this->_modifier);
}
--- 312,371 ----
/**
! * Determine the ability modifier for this ability. The ability
! * modifier can be added to other modifier lists (such as saving throws
! * and skill checks). <em>Do not change its value directly!</em>
*
! * @return Modifier for this ability.
*/
inline Modifier&
Ability::getModifier () {
return (this->_modifier);
+ }
+
+ /**
+ * An event that describes the change(s) made to this ability. An
+ * ability event is much like a modifiers list event except that it also
+ * provides the previous score of the ability. Note that an ability
+ * modifier does not always change when the current score of an ability
+ * changes. For this reason, ability modifiers have their own events
+ * and observers. An ability event does not describe changes to ability
+ * modiiers. <P>
+ *
+ * <em>Ability events must be created before any changes are made to the
+ * ability!</em>
+ */
+ class Ability::Event: public Modifiers::Event {
+ public:
+ Ability::Score getPreviousScore () const;
+
+ private:
+ Ability::Score _score;
+
+ Event (Ability& ability, Modifiers::Event& event);
+
+ friend void Ability::handleEvent (ogs::support::Event& event);
+ };
+
+ /**
+ * Create a new ability event.
+ *
+ * @param ability The ability producing this event.
+ * @param event An event from the modifiers list of the ability.
+ */
+ inline Ability::Event::Event (Ability& ability,
+ Modifiers::Event& event):
+ Modifiers::Event (event),
+ _score (ability.getCurrentScore ()) {
+ // empty constructor body
+ }
+
+ /**
+ * Determine the previous ability score described by this event.
+ *
+ * @return Previous ability score.
+ */
+ inline Ability::Score
+ Ability::Event::getPreviousScore () const {
+ return (this->_score);
}
Index: BodyPart.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/BodyPart.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BodyPart.cpp 29 Mar 2003 02:10:29 -0000 1.1
--- BodyPart.cpp 13 Apr 2003 05:25:51 -0000 1.2
***************
*** 21,43 ****
*/
- #include "ogs/core/Creature.h"
- #include "ogs/core/Item.h"
#include "ogs/core/BodyPart.h"
- using ogs::core::Creature;
- using ogs::core::Item;
using ogs::core::BodyPart;
-
- /**
- * Create a new body part. The type of body part does not have to be
- * one of the predefined humanoid body parts. It can be any body part
- * specific to a particular creature such as tails, wings, horns, or
- * whatever. The type value of the body part however must not conflict
- * with one of the predefined types.
- */
- BodyPart::BodyPart (Creature& creature, Type type):
- _creature (creature), _type (type), _items () {
- // empty constructor body
- }
/**
--- 21,27 ----
Index: BodyPart.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/BodyPart.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BodyPart.h 29 Mar 2003 02:10:29 -0000 1.1
--- BodyPart.h 13 Apr 2003 05:25:51 -0000 1.2
***************
*** 26,29 ****
--- 26,32 ----
# define OGS_CORE_BODY_PART_H
+ # include <cassert>
+
+ # include <ogs/support/Object.h>
# include <ogs/core/Namespace.h>
***************
*** 37,51 ****
* worn, held, or used somehow. The body part determines how many items
* can be equipped and how they are equipped. A normal human hand for
! * example can wear one glove, five rings, and hold one item.
*/
! class BodyPart: public Object {
public:
/**
* A type of body part. This enumeration defines the omnipresent
! * humanoid body parts. Body parts of other creatures (such as
! * tails, wings, horns, whatever) may be defined by other classes.
*/
enum Type {
! HEAD,
EYES,
LEFT_EYE,
--- 40,60 ----
* worn, held, or used somehow. The body part determines how many items
* can be equipped and how they are equipped. A normal human hand for
! * example can wear one glove, five rings, and hold one item. This
! * cclass predefines humanoid body parts. Body parts of other creatures
! * (such as tails, wings, horns, whatever) may be defined by other
! * classes.
*/
! class BodyPart: public ogs::support::Object {
public:
/**
* A type of body part. This enumeration defines the omnipresent
! * humanoid body parts. The type of body part does not have to be
! * one of the predefined humanoid body parts. It can be any body
! * part specific to a particular creature such as tails, wings,
! * horns, or whatever. The type value of the body part however must
! * not conflict with one of the predefined types
*/
enum Type {
! HEAD = 1,
EYES,
LEFT_EYE,
***************
*** 79,86 ****
private:
! Creature& _creature;
Type _type;
Items _items;
};
/**
--- 88,120 ----
private:
! Creature* _creature;
Type _type;
Items _items;
};
+
+ /**
+ * Create a new body part. The body part has no items when initially
+ * created.
+ *
+ * @param creature Creature that this body part belongs to.
+ * @param type Type of body part.
+ */
+ inline BodyPart::BodyPart (Creature& creature, Type type):
+ _creature (&creature),
+ _type (type),
+ _items () {
+ // empty constructor body
+ }
+
+ /**
+ * Determine the creature that this body part is part of.
+ *
+ * @return Creature that this body part is part of.
+ */
+ inline Creature&
+ BodyPart::getCreature () const {
+ assert (this->_creature != NULL);
+ return (*(this->_creature));
+ }
/**
Index: CClass.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/CClass.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CClass.cpp 4 Apr 2003 20:22:44 -0000 1.4
--- CClass.cpp 13 Apr 2003 05:25:51 -0000 1.5
***************
*** 32,47 ****
/**
! * Create a new character class. The experience level of this cclass
! * starts at one (1) by default. Attack and save bonuses must be
! * initialized by derived classes since the functions that determine the
! * values of these modifiers are pure virtual.
*
! * @param xpLevel Experience level of this cclass (default 1).
*/
! CClass::CClass (Experience::Level xpLevel):
! _xpLevel (xpLevel), _baseAttack (),
! _baseFortSave (), _baseRefSave (), _baseWillSave (),
_character (NULL) {
! updateModifiers ();
}
--- 32,62 ----
/**
! * Create a new character class. The experience level of the class is
! * taken from the number of hit dice. This value is used to initialize
! * the base attack and save bonuses. The average advancement rate is
! * used by default for the attack bonus and the weak advancement rates
! * are used by default for the save bonuses.
*
! * @param hitDie Hit die of this type of class.
! * @param skillRate Skill rate of this type of class.
! * @param xpLevel Experience level of this cclass.
! * @param baseAttack Value of base attack bonus.
! * @param baseFort Value of base Fortitude save bonus.
! * @param baseRef Value of base Reflex save bonus.
! * @param baseWill Value of base Will save bonus.
*/
! CClass::CClass (Die::Sides hitDie, Skill::Points skillRate,
! XP::Level xpLevel, Modifier::Value baseAttack,
! Modifier::Value baseFort, Modifier::Value baseRef,
! Modifier::Value baseWill):
! _hitDie (hitDie),
! _skillRate (skillRate),
! _xpLevel (xpLevel),
! _baseAttack (baseAttack),
! _baseFortSave (baseFort),
! _baseRefSave (baseRef),
! _baseWillSave (baseWill),
_character (NULL) {
! // empty constructor body
}
***************
*** 53,111 ****
* @param xpLevel An experience level.
*/
! void CClass::setLevel (Experience::Level xpLevel) {
Event event (*this);
-
this->_xpLevel = xpLevel;
notifyObservers (event);
-
- updateModifiers ();
}
/**
! * Update the modifiers associated with this class.
*/
! void CClass::updateModifiers () {
! Modifier::Value modifierValue = getBaseAttackValue ();
! _baseAttack.setValue (modifierValue);
! modifierValue = getBaseFortSaveValue ();
! _baseFortSave.setValue (modifierValue);
! modifierValue = getBaseRefSaveValue ();
! _baseRefSave.setValue (modifierValue);
! modifierValue = getBaseWillSaveValue ();
! _baseWillSave.setValue (modifierValue);
}
/**
! * Attach this cclass to a character.
*
! * @param object An object.
! * @return True if cclass is attached to object.
*/
bool CClass::attachObject (Object& object) {
! if (this == &object || // Can't attach this object to itself
! this->_character != NULL) { // Can't attach if already attached.
! return (false);
! }
! // Can only attach cclasses to characters.
! try {
! dynamic_cast<Character&> (object);
! } catch (std::bad_cast) {
! return (false);
}
! this->_character = dynamic_cast<Character*> (&object);
!
! return (true);
}
/**
! * Detach this cclass from a character.
*
* @return True if this cclass is detached from character.
*/
bool CClass::detachObject () {
! // TODO: Implement.
! return (true);
}
--- 68,139 ----
* @param xpLevel An experience level.
*/
! void CClass::setLevel (XP::Level xpLevel) {
Event event (*this);
this->_xpLevel = xpLevel;
+ updateCClass ();
notifyObservers (event);
}
/**
! * Update this cclass. This function is called when the experience
! * level of this cclass changes. By default, it only updates the
! * modifiers associated with this cclass using the average attack and
! * weak save bonuses. Derived classes should override this function to
! * use different bonuses and to add or remove specific cclass features.
*/
! void CClass::updateCClass () {
!
! Modifier::Value modifierValue = XP::getAverageAttack (this->_xpLevel);
! if (_baseAttack.getValue () != modifierValue) {
! _baseAttack.setValue (modifierValue);
! }
!
! modifierValue = Saves::getWeakBonus (this->_xpLevel);
! if (_baseFortSave.getValue () != modifierValue) {
! _baseFortSave.setValue (modifierValue);
! }
!
! if (_baseRefSave.getValue () != modifierValue) {
! _baseRefSave.setValue (modifierValue);
! }
!
! if (_baseWillSave.getValue () != modifierValue) {
! _baseWillSave.setValue (modifierValue);
! }
}
/**
! * Attach this cclass to an object. This method should always be called
! * first by derived classes that override this method.
*
! * @param object An object to attach this cclass to.
! * @return True if this cclass is attached to object.
*/
bool CClass::attachObject (Object& object) {
! bool attach = canAttach (object);
! if (attach) {
! this->_character = dynamic_cast<Character*> (&object);
}
! return (attach);
}
/**
! * Detach this cclass from an object. This function resets the
! * character pointer to null. Derived classes that override this
! * function should therefore call the getObject() function before
! * calling this function.
*
* @return True if this cclass is detached from character.
*/
bool CClass::detachObject () {
! bool detach = canDetach ();
!
! if (detach) {
! this->_character = NULL;
! }
!
! return (detach);
}
Index: CClass.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/CClass.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CClass.h 23 Mar 2003 22:14:36 -0000 1.5
--- CClass.h 13 Apr 2003 05:25:51 -0000 1.6
***************
*** 39,52 ****
/**
! * A character class is an occupation or vocation of a character.
! * Character class is abbreviated as @em cclass to differentiate the
! * word from the object-oriented concept of a class. Classes that are
! * derived from the @c CClass class represent specific player character
! * classes, non-player character classes, and prestige classes.
*/
class CClass: public ogs::support::Object,
public ogs::support::Attachable {
public:
! virtual ~CClass ();
virtual bool attachObject (ogs::support::Object& object);
--- 39,59 ----
/**
! * A career of a character. A character class represents a specific
! * career or role that a character assumes during their life of
! * adventure. Many characters focus on only one such character class
! * but a character can have more than one character class. Character
! * classes are designed to allow creatures increase their overall
! * potential and extend their inherent racial capabilities.
! *
! * Character class is abbreviated as <em>cclass</em> to differentiate
! * the term "class" from the object-oriented concept of a class.
! * CClasses that are derived from the @c CClass class represent specific
! * player character classes, nonplayer character classes, and prestige
! * classes. Prestige classes are cclasses that have prerequisites.
*/
class CClass: public ogs::support::Object,
public ogs::support::Attachable {
public:
! virtual ~CClass () = 0;
virtual bool attachObject (ogs::support::Object& object);
***************
*** 54,191 ****
ogs::support::Object* getObject () const;
! Experience::Level getLevel () const;
! virtual void setLevel (Experience::Level xpLevel);
!
! /**
! * Determine hit die for this cclass.
! *
! * @return Hit die for this class.
! */
! virtual Die::Sides getHitDie () const = 0;
!
! /**
! * Determine the skill points per experience level of this cclass.
! *
! * @return Skill points per experience level of this cclass.
! */
! virtual Skill::Points getSkillPoints () const = 0;
!
! const Modifier& getBaseAttack () const;
! const Modifier& getBaseFortSave () const;
! const Modifier& getBaseRefSave () const;
! const Modifier& getBaseWillSave () const;
protected:
! CClass (Experience::Level xpLevel = 1);
! virtual Modifier::Value getBaseAttackValue () const;
! virtual Modifier::Value getBaseFortSaveValue () const;
! virtual Modifier::Value getBaseRefSaveValue () const;
! virtual Modifier::Value getBaseWillSaveValue () const;
private:
! Experience::Level _xpLevel;
Modifier _baseAttack;
! Modifier _baseFortSave;;
Modifier _baseRefSave;
Modifier _baseWillSave;
Character* _character;
-
- void updateModifiers ();
};
/**
! * Determine the experience level of this class.
*
! * @return Experience level of this class.
*/
! inline Experience::Level CClass::getLevel () const {
! return (this->_xpLevel);
}
/**
! * Determine the base attack bonus of this cclass.
*
! * @return Base attack bonus of this cclass.
*/
! inline const Modifier& CClass::getBaseAttack () const {
! return (this->_baseAttack);
}
/**
! * Determine the base Fortitude save bonus of this cclass.
*
! * @return Base Fortitude save bonus of this cclass.
*/
! inline const Modifier& CClass::getBaseFortSave () const {
! return (this->_baseFortSave);
}
/**
! * Determine the base Reflex save bonus of this cclass.
*
! * @return Base Reflex save bonus of this cclass.
*/
! inline const Modifier& CClass::getBaseRefSave () const {
! return (this->_baseRefSave);
}
/**
! * Determine the base Will save bonus of this cclass.
*
! * @return Base Will save bonus of this cclass.
! */
! inline const Modifier& CClass::getBaseWillSave () const {
! return (this->_baseWillSave);
! }
!
! /**
! * Determine the value of the base attack bonus for this cclass. This
! * member function returns the average advancement rate for base attack
! * bonuses by default. Derived classes should override this function if
! * a different advvancement rate is required.
! */
! inline Modifier::Value CClass::getBaseAttackValue () const {
! return (Experience::getAverageAttack (getLevel ()));
! }
!
! /**
! * Determine the value of the base Fortitude save bonus for this
! * cclass. This member function returns the weak advancement rate for
! * base Fortitude save bonuses by default. Derived classes should
! * override this function if a different advancement rate is required.
! */
! inline Modifier::Value CClass::getBaseFortSaveValue () const {
! return (Saves::getWeakBonus (getLevel ()));
! }
!
! /**
! * Determine the value of the base Reflex save bonus for this cclass.
! * This member function returns the weak advancement rate for base
! * Reflex save bonuses by default. Derived classes should override this
! * function if a different advancement rate is required.
! */
! inline Modifier::Value CClass::getBaseRefSaveValue () const {
! return (Saves::getWeakBonus (getLevel ()));
! }
!
! /**
! * Determine the value of the base Will save bonus for this cclass.
! * This member function returns the weak advancement rate for base Will
! * save bonuses by default. Derived classes should override this
! * function if a different advancement rate is required.
*/
! inline Modifier::Value CClass::getBaseWillSaveValue () const {
! return (Saves::getWeakBonus (getLevel ()));
}
/**
! * Determine the character that this cclass is attached to (if any).
! * If this cclass is not attached, this function returns NULL.
*
! * @return Pointer to character object or NULL if not attached.
*/
! inline ogs::support::Object* CClass::getObject () const {
! return (this->_character);
}
--- 61,157 ----
ogs::support::Object* getObject () const;
! Die::Sides getHitDie () const;
! Skill::Points getSkillRate () const;
! XP::Level getLevel () const;
! void setLevel (XP::Level xpLevel);
protected:
! CClass (Die::Sides hitDie, Skill::Points skillRate,
! XP::Level xpLevel, Modifier::Value baseAttack,
! Modifier::Value baseFort, Modifier::Value baseRef,
! Modifier::Value baseWill);
! virtual bool canAttach (const Object& object) const;
! virtual bool canDetach () const;
!
! virtual void updateCClass ();
private:
! Die::Sides _hitDie;
! Skill::Points _skillRate;
! XP::Level _xpLevel;
Modifier _baseAttack;
! Modifier _baseFortSave;
Modifier _baseRefSave;
Modifier _baseWillSave;
Character* _character;
};
/**
! * Determine the character that this cclass is attached to. If this
! * cclass is not attached, this function returns NULL.
*
! * @return Pointer to character object or NULL if not attached.
*/
! inline ogs::support::Object*
! CClass::getObject () const {
! return (this->_character);
}
/**
! * Determine the hit die for this type of cclass.
*
! * @return Hit die of this type of cclass.
*/
! inline Die::Sides
! CClass::getHitDie () const {
! return (this->_hitDie);
}
/**
! * Determine the skill rate of this cclass. The skill rate is the
! * number of skill points that a character gains for each experience
! * level in this cclass.
*
! * @return Skill rate of this cclass.
*/
! inline Skill::Points
! CClass::getSkillRate () const {
! return (this->_skillRate);
}
/**
! * Determine the experience level of this cclass.
*
! * @return Experience level of this cclass.
*/
! inline XP::Level
! CClass::getLevel () const {
! return (this->_xpLevel);
}
/**
! * Determine if this cclass can be attached to an object. A cclass can
! * not be attached to itself or if it is already attached. A cclass can
! * only be attached to characters.
*
! * @param object Object to attach this feature to.
! * @return True if the feature is attached to the object.
*/
! inline bool
! CClass::canAttach (const Object& object) const {
! return (&object != this && _character == NULL &&
! dynamic_cast<const Character*> (&object) != NULL);
}
/**
! * Determine if this cclass can be detached from an object. A cclass
! * can not be detached from a character by default once it is attached.
*
! * @return True if this cclass is detached from character.
*/
! inline bool
! CClass::canDetach () const {
! return (false);
}
Index: Character.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Character.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Character.cpp 8 Apr 2003 21:43:09 -0000 1.6
--- Character.cpp 13 Apr 2003 05:25:51 -0000 1.7
***************
*** 39,43 ****
*/
Character::Character (Creature& creature, CClass& cclass):
! _creature (creature), _xpPoints (0), _advanceOrder () {
Advance advance (cclass);
--- 39,43 ----
*/
Character::Character (Creature& creature, CClass& cclass):
! _creature (&creature), _xpPoints (0), _advanceOrder () {
Advance advance (cclass);
***************
*** 60,64 ****
*/
const Character::Advance&
! Character::getAdvance (Experience::Level xpLevel) const {
return (_advanceOrder.at (xpLevel - 1));
}
--- 60,64 ----
*/
const Character::Advance&
! Character::getAdvance (XP::Level xpLevel) const {
return (_advanceOrder.at (xpLevel - 1));
}
***************
*** 70,80 ****
*/
Skill::Points Character::getSkillPoints () const {
! Experience::Level xpLevel = getLevel ();
const Advance& advance = getAdvance (xpLevel);
CClass& cclass = advance.getCClass ();
! Skill::Points total = cclass.getSkillPoints ();
// Add Ingelligence bonus if any.
! Abilities& abilities = _creature.getAbilities ();
AbilityPtr intl = abilities [Ability::INT];
if (intl) {
--- 70,80 ----
*/
Skill::Points Character::getSkillPoints () const {
! XP::Level xpLevel = getLevel ();
const Advance& advance = getAdvance (xpLevel);
CClass& cclass = advance.getCClass ();
! Skill::Points total = cclass.getSkillRate ();
// Add Ingelligence bonus if any.
! Abilities& abilities = _creature->getAbilities ();
AbilityPtr intl = abilities [Ability::INT];
if (intl) {
***************
*** 113,117 ****
*/
bool Character::canIncreaseAbility () const {
! Experience::Level xpLevel = getLevel ();
Advance advance = _advanceOrder [xpLevel];
unsigned totalIncreases = Ability::getIncreaseCount (xpLevel);
--- 113,117 ----
*/
bool Character::canIncreaseAbility () const {
! XP::Level xpLevel = getLevel ();
Advance advance = _advanceOrder [xpLevel];
unsigned totalIncreases = Ability::getIncreaseCount (xpLevel);
Index: Character.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Character.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Character.h 29 Mar 2003 02:10:29 -0000 1.6
--- Character.h 13 Apr 2003 05:25:51 -0000 1.7
***************
*** 56,64 ****
Creature& getCreature () const;
! Experience::Points getPoints () const;
! void setPoints (Experience::Points xpPoints);
! Experience::Level getLevel () const;
! const Advance& getAdvance (Experience::Level xpLevel) const;
bool canAdvance () const;
void advanceCClass (CClass& cclass);
--- 56,64 ----
Creature& getCreature () const;
! XP::Points getPoints () const;
! void setPoints (XP::Points xpPoints);
! XP::Level getLevel () const;
! const Advance& getAdvance (XP::Level xpLevel) const;
bool canAdvance () const;
void advanceCClass (CClass& cclass);
***************
*** 69,74 ****
typedef std::vector<Advance> AdvanceOrder;
! Creature& _creature;
! Experience::Points _xpPoints;
AdvanceOrder _advanceOrder;
};
--- 69,74 ----
typedef std::vector<Advance> AdvanceOrder;
! Creature* _creature;
! XP::Points _xpPoints;
AdvanceOrder _advanceOrder;
};
***************
*** 110,115 ****
* @return Reference to creature.object.
*/
! inline Creature& Character::getCreature () const {
! return (_creature);
}
--- 110,116 ----
* @return Reference to creature.object.
*/
! inline Creature&
! Character::getCreature () const {
! return (*(this->_creature));
}
***************
*** 119,124 ****
* @return Experience points.
*/
! inline Experience::Points Character::getPoints () const {
! return (_xpPoints);
}
--- 120,126 ----
* @return Experience points.
*/
! inline XP::Points
! Character::getPoints () const {
! return (this->_xpPoints);
}
***************
*** 129,134 ****
* @return Experience level of character.
*/
! inline Experience::Level Character::getLevel () const {
! return (Experience::getLevel (_xpPoints));
}
--- 131,137 ----
* @return Experience level of character.
*/
! inline XP::Level
! Character::getLevel () const {
! return (XP::getLevel (this->_xpPoints));
}
***************
*** 138,143 ****
* @return True if this character can advance.
*/
! inline bool Character::canAdvance () const {
! return (getLevel () > _advanceOrder.size ());
}
--- 141,147 ----
* @return True if this character can advance.
*/
! inline bool
! Character::canAdvance () const {
! return (getLevel () > this->_advanceOrder.size ());
}
***************
*** 147,152 ****
* @return Character class.
*/
! inline CClass& Character::Advance::getCClass () const {
! return (*_cclass);
}
--- 151,157 ----
* @return Character class.
*/
! inline CClass&
! Character::Advance::getCClass () const {
! return (*(this->_cclass));
}
***************
*** 156,161 ****
* @return Ability increased or NULL if not assigned.
*/
! inline Ability* Character::Advance::getAbilityIncrease () const {
! return (_ability);
}
--- 161,167 ----
* @return Ability increased or NULL if not assigned.
*/
! inline Ability*
! Character::Advance::getAbilityIncrease () const {
! return (this->_ability);
}
Index: Creature.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Creature.cpp 8 Apr 2003 21:43:09 -0000 1.9
--- Creature.cpp 13 Apr 2003 05:25:51 -0000 1.10
***************
*** 23,33 ****
#include <algorithm>
#include "ogs/core/Creature.h"
#include "ogs/core/Feat.h"
- using ogs::core::BodyPart;
using ogs::core::Creature;
- using ogs::core::Die;
- using ogs::core::Feat;
/**
--- 23,34 ----
#include <algorithm>
+ #include "ogs/core/Abilities.h"
+ #include "ogs/core/BodyPart.h"
#include "ogs/core/Creature.h"
+ #include "ogs/core/Die.h"
#include "ogs/core/Feat.h"
+ #include "ogs/core/Skill.h"
using ogs::core::Creature;
/**
***************
*** 36,43 ****
* no hit dice. Ability scores rolled using the standard method and no
* character is associated with the creature.
*/
! Creature::Creature (Body body):
! _hitDice (), _initiative (), _saves (), _abilities (),
! _skills (), _feats (), _body (body), _character (NULL) {
// Add Dexterity modifier to Reflex save, initiative, and defense.
AbilityPtr ability = this->_abilities [Ability::DEX];
--- 37,58 ----
* no hit dice. Ability scores rolled using the standard method and no
* character is associated with the creature.
+ *
+ * @param hitDice Hit dice of creature.
+ * @param abilities Ability scores of creature.
+ * @param size Size of creature.
+ * @param body Body of creature.
*/
! Creature::Creature (Die hitDice, Abilities abilities,
! Size::Type size, Parts parts):
! Entity (size),
! _hitDice (hitDice),
! _initiative (),
! _saves (),
! _abilities (abilities),
! _skills (),
! _feats (),
! _body (),
! _character (NULL) {
!
// Add Dexterity modifier to Reflex save, initiative, and defense.
AbilityPtr ability = this->_abilities [Ability::DEX];
***************
*** 48,64 ****
defense.addModifier (modifier);
! // Add other ability modifiers to saving throws.
ability = this->_abilities [Ability::CON];
this->_saves.fort.addModifier (ability->getModifier ());
ability = this->_abilities [Ability::WIS];
this->_saves.will.addModifier (ability->getModifier ());
- }
! struct Delete {
! void operator() (BodyPart* bodyPart) { delete bodyPart; }
! };
! Creature::~Creature () {
! std::for_each (this->_body.begin (), this->_body.end (), Delete ());
}
--- 63,80 ----
defense.addModifier (modifier);
! // Add ability modifiers to saving throws.
ability = this->_abilities [Ability::CON];
this->_saves.fort.addModifier (ability->getModifier ());
ability = this->_abilities [Ability::WIS];
this->_saves.will.addModifier (ability->getModifier ());
! // Add hit dice modifiers to saving throws.
! //this->_saves.fort.addModifier (this->_fortModifier);
! //this->_saves.ref.addModifier (this->_refModifier);
! //this->_saves.will.addModifier (this->_willModifier);
! for (Parts::size_type i = 0; i < parts.size (); ++i) {
! this->_body.push_back (BodyPart (*this, parts [i]));
! }
}
***************
*** 66,80 ****
* Add a skill to this creature.
*
! * @param skill A new skill.
*/
! bool Creature::addSkill (Skill& skill) {
bool added = false;
! // Make sure the skill isn't already in the list of skills.
! Skills::iterator end = _skills.end ();
! if (std::find (_skills.begin (), end, &skill) != end) {
! //if (skill is not an exclusive skill) {
! _skills.push_back (&skill);
! //}
}
--- 82,98 ----
* Add a skill to this creature.
*
! * @param skillPtr A smart pointer for a new skill.
! * @return True if the skill was added to this creature.
*/
! bool Creature::addSkill (SkillPtr skillPtr) {
bool added = false;
! if (skillPtr) {
! // Make sure the skill isn't already in the list of skills.
! Skills::iterator end = _skills.end ();
! if (std::find (_skills.begin (), end, skillPtr) != end) {
! _skills.push_back (skillPtr);
! added = true;
! }
}
***************
*** 85,110 ****
* Add a feat to this creature.
*
! * @param feat A new feat.
! * @return True if feat was successfully added.
*/
! bool Creature::addFeat (Feat& feat) {
! Feat::Compatibility compatibility = feat.getCompatibility ();
! bool attachFeat = false;
!
! if (compatibility == Feat::EXCLUSIVE) {
! //attachFeat = ! findExclusiveFeat (feat.getClass ());
! } else if (compatibility == Feat::REPEATABLE) {
! //attachFeat = ! findEquivalentFeat (feat);
! } else if (compatibility == Feat::CUMULATIVE) {
! attachFeat = true;
! }
! if (attachFeat) {
! if (attachFeat = feat.attachObject (*this)) {
! _feats.push_back (&feat);
! }
}
! return (attachFeat);
}
--- 103,118 ----
* Add a feat to this creature.
*
! * @param featPtr A smart pointer to a new feat.
! * @return True if the feat was added to this creature.
*/
! bool Creature::addFeat (FeatPtr featPtr) {
! Feat* feat = featPtr.get ();
! bool added = false;
! if (added = feat->attachObject (*this)) {
! _feats.push_back (featPtr);
}
! return (added);
}
***************
*** 112,124 ****
* Remove a feat from this creature.
*
! * @param feat Feat to be removed.
*/
! bool Creature::removeFeat (Feat& feat) {
bool removed = false;
Feats::iterator end = _feats.end ();
! Feats::iterator itor = std::find (_feats.begin (), end, &feat);
if (itor != end) {
! if (removed = feat.detachObject ()) {
_feats.erase (itor);
}
--- 120,134 ----
* Remove a feat from this creature.
*
! * @param featPtr A smart pointer to a feat.
! * @return True if the feat was removed from this creature.
*/
! bool Creature::removeFeat (FeatPtr featPtr) {
bool removed = false;
Feats::iterator end = _feats.end ();
! Feats::iterator itor = std::find (_feats.begin (), end, featPtr);
if (itor != end) {
! Feat* feat = featPtr.get ();
! if (removed = feat->detachObject ()) {
_feats.erase (itor);
}
Index: Creature.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Creature.h 29 Mar 2003 02:10:29 -0000 1.8
--- Creature.h 13 Apr 2003 05:25:51 -0000 1.9
***************
*** 29,39 ****
# include <vector>
# include <ogs/core/Abilities.h>
# include <ogs/core/Die.h>
# include <ogs/core/Entity.h>
# include <ogs/core/Modifiers.h>
# include <ogs/core/Namespace.h>
- # include <ogs/core/BodyPart.h>
# include <ogs/core/Saves.h>
OGS_BEGIN_CORE_NAMESPACE
--- 29,42 ----
# include <vector>
+ # include <boost/shared_ptr.hpp>
+
# include <ogs/core/Abilities.h>
+ # include <ogs/core/BodyPart.h>
# include <ogs/core/Die.h>
# include <ogs/core/Entity.h>
# include <ogs/core/Modifiers.h>
# include <ogs/core/Namespace.h>
# include <ogs/core/Saves.h>
+ # include <ogs/core/Types.h>
OGS_BEGIN_CORE_NAMESPACE
***************
*** 45,70 ****
/**
! * A creature is a sentient and/or animate entity.
*/
class Creature: public Entity {
public:
! typedef std::vector<Die*> Dice;
! typedef std::list<Skill*> Skills;
! typedef std::list<Feat*> Feats;
! typedef std::list<BodyPart*> Body;
! Dice& getHitDice ();
Modifiers& getInitiative ();
Die::Value rollInitiative () const;
Saves& getSaves ();
Abilities& getAbilities ();
Skills getSkills () const;
! bool addSkill (Skill& skill);
! bool removeSkill (Skill& skill);
Feats getFeats () const;
! bool addFeat (Feat& feat);
! bool removeFeat (Feat& feat);
Body getBody () const;
--- 48,84 ----
/**
! * A creature is a sentient and/or animate entity. Creatures could be
! * described as living entities but "living" some creatures such as
! * constructs and undead barely fit the definition of "living" entities.
! * But even these types of entities are considered creatures since they
! * have the same attributes that are common to all creatures; namely,
! * hit dice, ability scores, saving throws, inititiative, skills, feats,
! * and (usually) a body which can carry and equip items.
*/
class Creature: public Entity {
public:
! /** A list of body parts. */
! typedef std::list<BodyPart> Body;
! Die getHitDice () const;
! void setHitDice (const Die& hitDice);
!
! const Modifiers& getInitiative () const;
Modifiers& getInitiative ();
Die::Value rollInitiative () const;
+
+ const Saves& getSaves () const;
Saves& getSaves ();
+
+ const Abilities& getAbilities () const;
Abilities& getAbilities ();
Skills getSkills () const;
! bool addSkill (SkillPtr skillPtr);
! bool removeSkill (SkillPtr skillPtr);
Feats getFeats () const;
! bool addFeat (FeatPtr featPtr);
! bool removeFeat (FeatPtr featPtr);
Body getBody () const;
***************
*** 78,86 ****
protected:
! Creature (Body body = Body ());
! void setBody (Body body);
private:
! Dice _hitDice;
Modifiers _initiative;
//TODO: Add moves;
--- 92,111 ----
protected:
! /**
! * An array of body part types. This class does not know what sort
! * of bodies that derived classes may have and derived classes do
! * not have access to "this" creature in initializer lists. So
! * derived classes provide the Creature constructor with an array of
! * body part types which it can then turn into a body using "this"
! * creature.
! */
! typedef std::vector<BodyPart::Type> Parts;
!
! Creature (Die hitDice, Abilities abilities,
! Size::Type size = Size::MEDIUM,
! Parts parts = Parts ());
private:
! Die _hitDice;
Modifiers _initiative;
//TODO: Add moves;
***************
*** 91,112 ****
Body _body;
Character* _character;
};
/**
! * Determine the initiative modifiers for this creature. Initiative
! * modifiers are modifiers that are added to an intiative roll.
*
* @return Initiative modifiers.
*/
! inline Modifiers& Creature::getInitiative () {
return (this->_initiative);
}
/**
! * Roll initiative.
*
* @return Result of initiative roll.
*/
! inline Die::Value Creature::rollInitiative () const {
return (Die::roll () + _initiative.getValue ());
}
--- 116,166 ----
Body _body;
Character* _character;
+
+ Modifier _fortModifier;
+ Modifier _refModifier;
+ Modifier _willModifier;
};
/**
! * Determine the hit dice for this creature.
! *
! * @return Hit dice for this creature.
! */
! inline Die
! Creature::getHitDice () const {
! return (this->_hitDice);
! }
!
! /**
! * Determine the initiative modifiers for this creature.
*
* @return Initiative modifiers.
*/
! inline const Modifiers&
! Creature::getInitiative () const {
return (this->_initiative);
}
/**
! * Determine the initiative modifiers for this creature. This function
! * allows the caller to add and remove modifiers to intiative rolls for
! * this creature.
! *
! * @return Initiative modifiers.
! */
! inline Modifiers&
! Creature::getInitiative () {
! return (this->_initiative);
! }
!
! /**
! * Roll initiative. This function rolls 1d20 and adds the initiative
! * modifiers of this creature to the result to produce an initiative
! * roll.
*
* @return Result of initiative roll.
*/
! inline Die::Value
! Creature::rollInitiative () const {
return (Die::roll () + _initiative.getValue ());
}
***************
*** 117,121 ****
* @return Ability scores.
*/
! inline Abilities& Creature::getAbilities () {
return (this->_abilities);
}
--- 171,176 ----
* @return Ability scores.
*/
! inline Abilities&
! Creature::getAbilities () {
return (this->_abilities);
}
***************
*** 126,130 ****
* @return Saving throws for this creature.
*/
! inline Saves& Creature::getSaves () {
return (this->_saves);
}
--- 181,186 ----
* @return Saving throws for this creature.
*/
! inline Saves&
! Creature::getSaves () {
return (this->_saves);
}
***************
*** 135,139 ****
* @return A list of skills for this creature.
*/
! inline Creature::Skills
Creature::getSkills () const {
return (this->_skills);
--- 191,195 ----
* @return A list of skills for this creature.
*/
! inline Skills
Creature::getSkills () const {
return (this->_skills);
***************
*** 145,149 ****
* @return A list of feats for this creature.
*/
! inline Creature::Feats
Creature::getFeats () const {
return (this->_feats);
--- 201,205 ----
* @return A list of feats for this creature.
*/
! inline Feats
Creature::getFeats () const {
return (this->_feats);
***************
*** 167,183 ****
* @return Null pointer or a pointer to a Character object.
*/
! inline Character* Creature::getCharacter () const {
return (this->_character);
}
! /**
! * Change the body of this creature.
! *
! * @param body Body of this creature.
! */
! inline void
! Creature::setBody (Body body) {
! this->_body = body;
! }
OGS_END_CORE_NAMESPACE
--- 223,232 ----
* @return Null pointer or a pointer to a Character object.
*/
! inline Character*
! Creature::getCharacter () const {
return (this->_character);
}
! inline Creature::~Creature () { }
OGS_END_CORE_NAMESPACE
Index: Defense.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Defense.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Defense.h 7 Jan 2003 07:41:32 -0000 1.1
--- Defense.h 13 Apr 2003 05:25:51 -0000 1.2
***************
*** 26,53 ****
# define OGS_CORE_DEFENSE_H
! # include <list>
!
! # include <ogs/support/Object.h>
! # include <ogs/support/Observer.h>
! # include <ogs/core/Modifier.h>
# include <ogs/core/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
- using ogs::support::Event;
- using ogs::support::Object;
- using ogs::support::Observer;
- using ogs::core::Modifier;
-
- // Need to add code for determining defense when flat-footed and for
- // touch attacks.
-
/**
! * A value that determines effectiveness in avoiding attacks. Defense
! * is also known as "armor class" but armor is only one of many ways to
* enhance defense. Thus "defense" is used to indicate a more abstract
* concept.
*/
! class Defense: public Object, public Observer {
public:
/** Value of an unmodified defense. */
--- 26,41 ----
# define OGS_CORE_DEFENSE_H
! # include <ogs/core/Modifiers.h>
# include <ogs/core/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
/**
! * A value that determines effectiveness in avoiding damage. Defense is
! * also known as "armor class" but armor is only one of many ways to
* enhance defense. Thus "defense" is used to indicate a more abstract
* concept.
*/
! class Defense: public Modifiers {
public:
/** Value of an unmodified defense. */
***************
*** 55,78 ****
Defense (Modifier::Value baseValue = BASE_VALUE);
-
- void addModifier (Modifier& modifier);
- void removeModifier (Modifier& modifier);
Modifier::Value getValue () const;
- void handleEvent (Event& event);
-
private:
! typedef std::list<Modifier*> Modifiers;
! Modifiers modifiers;
! Modifier::Value value;
};
/**
* Determine the current value of this defense.
*
* @return Current value of this defense.
*/
! inline Modifier::Value Defense::getValue () const {
! return (this->value);
}
--- 43,69 ----
Defense (Modifier::Value baseValue = BASE_VALUE);
Modifier::Value getValue () const;
private:
! Modifier::Value _baseValue;
};
/**
+ * Create a new defense. The value is initialized to the base value
+ * and contains no modifiers.
+ */
+ inline Defense::Defense (Modifier::Value baseValue):
+ _baseValue (baseValue) {
+ // empty constructor body
+ }
+
+ /**
* Determine the current value of this defense.
*
* @return Current value of this defense.
*/
! inline Modifier::Value
! Defense::getValue () const {
! return (this->_baseValue + Modifiers::getValue ());
}
Index: Entity.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Entity.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Entity.cpp 29 Mar 2003 02:10:29 -0000 1.5
--- Entity.cpp 13 Apr 2003 05:25:51 -0000 1.6
***************
*** 23,26 ****
--- 23,27 ----
#include "ogs/support/Event.h"
#include "ogs/core/Entity.h"
+ #include "ogs/core/Feature.h"
using ogs::support::Event;
***************
*** 34,49 ****
* in size will automatically be reflected in the defense.
*
- * @param weight Weight of entity.
* @param size Size of entity.
*/
! Entity::Entity (Weight weight, Size::Type size):
! _weight (weight), _size (size), _defense (),
! _currentHealth (0), _maximumHealth (0) /*, _features ()*/ {
_defense.addModifier (_size.getDefenseModifier ());
}
/**
! * Change the current weight of this entity. Units for weight are
! * locale dependent.
*
* @param weight Weight of entity.
--- 35,53 ----
* in size will automatically be reflected in the defense.
*
* @param size Size of entity.
+ * @param weight Weight of entity.
*/
! Entity::Entity (Size::Type size, Weight weight):
! _size (size),
! _weight (weight),
! _defense (),
! _health (1, 1),
! _features () {
_defense.addModifier (_size.getDefenseModifier ());
}
/**
! * Change the weight of this entity. Units of measurement for weight
! * are locale dependent. Observers are notified of the change.
*
* @param weight Weight of entity.
***************
*** 56,76 ****
/**
! * Change the current health of this entity.
*
! * @p...
[truncated message content] |