[ogs-changes] dist/c++/ogs/core Abilities.cpp,1.3,1.4 Abilities.h,1.2,1.3 Ability.cpp,1.4,1.5 Abilit
Status: Alpha
Brought to you by:
elemings
Update of /cvsroot/ogs/dist/c++/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv9450/c++/ogs/core
Modified Files:
Abilities.cpp Abilities.h Ability.cpp Ability.h CClass.cpp
Feat.cpp Feat.h Feature.h Strength.h
Log Message:
See ChangeLog files (Apr 3-4) for details.
Index: Abilities.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Abilities.cpp 29 Mar 2003 02:10:28 -0000 1.3
--- Abilities.cpp 4 Apr 2003 20:22:43 -0000 1.4
***************
*** 30,46 ****
/**
! * Create a set of abilities. This constructor uses the standard method
! * by default to create a complete set of all six ability scores.
*
! * @return A set of six ability scores.
*/
Abilities::Abilities (Ability::Method& method) {
Map& map = *this;
! map [Ability::CHA] = Ability::createCharisma (method);
! map [Ability::CON] = Ability::createConstitution (method);
! map [Ability::DEX] = Ability::createDexterity (method);
! map [Ability::INT] = Ability::createIntelligence (method);
map [Ability::STR] = new Strength (method);
! map [Ability::WIS] = Ability::createWisdom (method);
}
--- 30,59 ----
/**
! * Create a complete set of abilities. The ability scores are generated
! * with the standard method.
! */
! Abilities::Abilities () {
! Map& map = *this;
! map [Ability::CHA] = new Ability (Ability::CHA);
! map [Ability::CON] = new Ability (Ability::CON);
! map [Ability::DEX] = new Ability (Ability::DEX);
! map [Ability::INT] = new Ability (Ability::INT);
! map [Ability::STR] = new Strength ();
! map [Ability::WIS] = new Ability (Ability::WIS);
! }
!
! /**
! * Create a complete set of abilities using a method.
*
! * @param method A method for generating ability scores.
*/
Abilities::Abilities (Ability::Method& method) {
Map& map = *this;
! map [Ability::CHA] = new Ability (Ability::CHA, method);
! map [Ability::CON] = new Ability (Ability::CON, method);
! map [Ability::DEX] = new Ability (Ability::DEX, method);
! map [Ability::INT] = new Ability (Ability::INT, method);
map [Ability::STR] = new Strength (method);
! map [Ability::WIS] = new Ability (Ability::WIS, method);
}
Index: Abilities.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Abilities.h 29 Mar 2003 02:10:28 -0000 1.2
--- Abilities.h 4 Apr 2003 20:22:43 -0000 1.3
***************
*** 44,48 ****
typedef std::map<Ability::Type, Ability*>::iterator Iterator;
! Abilities (Ability::Method& method = Ability::standardMethod);
~Abilities ();
--- 44,49 ----
typedef std::map<Ability::Type, Ability*>::iterator Iterator;
! Abilities ();
! Abilities (Ability::Method& method);
~Abilities ();
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Ability.cpp 29 Mar 2003 02:10:28 -0000 1.4
--- Ability.cpp 4 Apr 2003 20:22:43 -0000 1.5
***************
*** 21,25 ****
*/
! #include <algorithm>
#include "ogs/Support.h"
--- 21,26 ----
*/
! #include <sstream> // ostringstream
! #include <stdexcept> // invalid_argument
#include "ogs/Support.h"
***************
*** 33,38 ****
using ogs::core::Modifier;
- Ability::StandardMethod Ability::standardMethod;
-
/**
* Produce an ability score using the standard method. With
--- 34,37 ----
***************
*** 109,115 ****
/**
* Create a new ability. The ability score is rolled using the standard
! * method. The ability has no modifiers. This constructor is
! * protected: it is called only by constructors of classes derived from
! * the <code>Ability</code> class.
*/
Ability::Ability (Type type, Method& method):
--- 108,136 ----
/**
* 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.
! * @throws std::invalid_argument If type is not a valid ability type.
! */
! Ability::Ability (Type type):
! _type (type),
! _originalScore (rollStandard ()),
! _currentScore (_originalScore),
! _modifier (getModifier (_originalScore)) {
! if (! isValidType (type)) {
! std::ostringstream ostr;
! ostr << "ability type (" << (int) type;
! ostr << ") is not a valid type of ability";
! throw std::invalid_argument (ostr.str ());
! }
! }
!
! /**
! * Create a new ability using a method. The ability score has no
! * modifiers.
! *
! * @param type A type of ability.
! * @param method A method for generating ability scores.
! * @throws std::invalid_argument If type is not a valid ability type.
*/
Ability::Ability (Type type, Method& method):
***************
*** 118,122 ****
_currentScore (_originalScore),
_modifier (getModifier (_originalScore)) {
! // empty constructor body
}
--- 139,148 ----
_currentScore (_originalScore),
_modifier (getModifier (_originalScore)) {
! if (! isValidType (type)) {
! std::ostringstream ostr;
! ostr << "ability type (" << (int) type;
! ostr << ") is not a valid type of ability";
! throw std::invalid_argument (ostr.str ());
! }
}
Index: Ability.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Ability.h 29 Mar 2003 02:10:28 -0000 1.3
--- Ability.h 4 Apr 2003 20:22:43 -0000 1.4
***************
*** 45,50 ****
* unmodified, original score of the ability. The modified, current
* score is used to determine the ability modifier. Thus, an ability
! * has two kinds of modifiers: modifiers <I>to</I> the <I>original</I>
! * score and a modifier <I>from</I> the <I>current</I> score. <P>
*/
class Ability: public ogs::support::Object,
--- 45,51 ----
* unmodified, original score of the ability. The modified, current
* score is used to determine the ability modifier. Thus, an ability
! * has two kinds of modifiers: zero or more <I>score modifiers</I> that
! * are added to the original score and one <I>ability modifier</I>
! * resulting from the current score. <P>
*/
class Ability: public ogs::support::Object,
***************
*** 59,65 ****
enum Type {
/**
! * An ability that determines physical power and force. Strength
! * is a special ability that additional special operations for
! * determining carrying capacities.
*
* @see Strength
--- 60,64 ----
enum Type {
/**
! * An ability that determines physical power and force.
*
* @see Strength
***************
*** 68,74 ****
/**
! * An ability that determines agility and quickness. The
! * Dexterity modifier is added to all Reflex saving throws.
*
* @see Saves::ref
*/
--- 67,75 ----
/**
! * An ability that determines agility and quickness. A Dexterity
! * modifier is added to ranged attacks with thrown weapons and
! * projectile weapons, defense ratings, and Reflex saving throws.
*
+ * @see Defense
* @see Saves::ref
*/
***************
*** 76,81 ****
/**
! * An ability that determines fitness and vigor. The Constiution
! * modifier is added to all Fortitude saving throws.
*
* @see Saves::fort
--- 77,82 ----
/**
! * An ability that determines fitness and vigor. A Constiution
! * modifier is added to hit die rolls and Fortitude saving throws.
*
* @see Saves::fort
***************
*** 110,114 ****
*/
struct Method {
! virtual Score operator() (Ability::Type) = 0;
virtual ~Method () { }
};
--- 111,115 ----
*/
struct Method {
! virtual Score operator() (Type type) = 0;
virtual ~Method () { }
};
***************
*** 121,125 ****
*/
struct StandardMethod: public Method {
! Score operator() (Ability::Type) {
return (rollStandard ());
}
--- 122,132 ----
*/
struct StandardMethod: public Method {
! /**
! * Generate a score using the standard method. The type parameter
! * is not used.
! *
! * @return An ability score.
! */
! Score operator() (Type) {
return (rollStandard ());
}
***************
*** 133,137 ****
*/
struct AverageMethod: public Method {
! Score operator() (Ability::Type) {
return (rollAverage ());
}
--- 140,150 ----
*/
struct AverageMethod: public Method {
! /**
! * Generate a score using the average method. The type parameter
! * is not used.
! *
! * @return An ability score.
! */
! Score operator() (Type) {
return (rollAverage ());
}
***************
*** 145,163 ****
*/
struct HighPoweredMethod: public Method {
! Score operator() (Ability::Type) {
return (rollHighPowered ());
}
};
static Modifier::Value getModifier (Score score);
static unsigned getIncreaseCount (Experience::Level xpLevel);
static Experience::Level getIncreaseCountLevel (unsigned count);
! static StandardMethod standardMethod;
! static Ability* createDexterity (Method& method = standardMethod);
! static Ability* createConstitution (Method& method = standardMethod);
! static Ability* createIntelligence (Method& method = standardMethod);
! static Ability* createWisdom (Method& method = standardMethod);
! static Ability* createCharisma (Method& method = standardMethod);
Type getType () const;
--- 158,179 ----
*/
struct HighPoweredMethod: public Method {
! /**
! * Generate a score using the high-powered method. The type
! * parameter is not used.
! *
! * @return An ability score.
! */
! Score operator() (Type) {
return (rollHighPowered ());
}
};
+ static bool isValidType (int i);
static Modifier::Value getModifier (Score score);
static unsigned getIncreaseCount (Experience::Level xpLevel);
static Experience::Level getIncreaseCountLevel (unsigned count);
! Ability (Type type);
! Ability (Type type, Method& method);
Type getType () const;
***************
*** 169,175 ****
void handleEvent (ogs::support::Event& event);
- protected:
- Ability (Type type, Method& method = standardMethod);
-
private:
Type _type;
--- 185,188 ----
***************
*** 185,188 ****
--- 198,213 ----
/**
+ * Determine if an integer value is a valid ability type.
+ *
+ * @param i An integer value.
+ * @return True if integer value is a valid ability type.
+ */
+ inline bool
+ Ability::isValidType (int i) {
+ return (i == STR || i == DEX || i == CON ||
+ i == INT || i == WIS || i == CHA);
+ }
+
+ /**
* Produce an ability score using the average method. With
* the average method, three d6 die are rolled and added together.
***************
*** 220,283 ****
Ability::getIncreaseCount (Experience::Level xpLevel) {
return (xpLevel == 0? 0: xpLevel / 4);
- }
-
- /**
- * Create a new Dexterity ability using a method. The default method is
- * the standard method.
- *
- * @param method A method for generating an ability score.
- * @return A new Dexterity ability.
- */
- inline Ability*
- Ability::createDexterity (Method& method) {
- return (new Ability (DEX, method));
- }
-
- /**
- * Create a new Constitution ability using a method. The default method
- * is the standard method.
- *
- * @param method A method for generating an ability score.
- * @return A new Constutition ability.
- */
- inline Ability*
- Ability::createConstitution (Method& method) {
- return (new Ability (CON, method));
- }
-
- /**
- * Create a new Intelligence ability using a method. The default method
- * is the standard method.
- *
- * @param method A method for generating an ability score.
- * @return A new Intelligence ability.
- */
- inline Ability*
- Ability::createIntelligence (Method& method) {
- return (new Ability (INT, method));
- }
-
- /**
- * Create a new Wisdom ability using a method. The default method is
- * the standard method.
- *
- * @param method A method for generating an ability score.
- * @return A new Wisdom ability.
- */
- inline Ability*
- Ability::createWisdom (Method& method) {
- return (new Ability (WIS, method));
- }
-
- /**
- * Create a new Charisma ability using a method. The default method is
- * the standard method.
- *
- * @param method A method for generating an ability score.
- * @return A new Charisma ability.
- */
- inline Ability*
- Ability::createCharisma (Method& method) {
- return (new Ability (CHA, method));
}
--- 245,248 ----
Index: CClass.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/CClass.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CClass.cpp 23 Mar 2003 22:14:36 -0000 1.3
--- CClass.cpp 4 Apr 2003 20:22:44 -0000 1.4
***************
*** 103,107 ****
* Detach this cclass from a character.
*
! * @param True if this cclass is detached from character.
*/
bool CClass::detachObject () {
--- 103,107 ----
* Detach this cclass from a character.
*
! * @return True if this cclass is detached from character.
*/
bool CClass::detachObject () {
Index: Feat.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feat.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Feat.cpp 29 Mar 2003 02:10:29 -0000 1.4
--- Feat.cpp 4 Apr 2003 20:22:44 -0000 1.5
***************
*** 59,86 ****
}
- /**
- * Determine if a creature has a feat.
- *
- * @param creature Creature to check.
- * @return True if creature has an instance of FeatClass.
- */
- template <class FeatClass>
- bool Feat::findFeat (const Object& object) const {
- bool found = false;
- const Creature* creature = dynamic_cast<const Creature*> (&object);
-
- if (creature != NULL) {
- Creature::Feats feats = creature->getFeats ();
- Creature::Feats::iterator itor = feats.begin ();
-
- while (itor != feats.end ()) {
- FeatClass* feat = dynamic_cast <FeatClass*> (*itor++);
- if (feat != NULL) {
- found = true;
- }
- }
- }
-
- return (found);
- }
-
--- 59,60 ----
Index: Feat.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feat.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Feat.h 29 Mar 2003 02:10:29 -0000 1.7
--- Feat.h 4 Apr 2003 20:22:44 -0000 1.8
***************
*** 26,29 ****
--- 26,30 ----
# define OGS_CORE_FEAT_H
+ # include <ogs/core/Creature.h>
# include <ogs/core/Experience.h>
# include <ogs/core/Feature.h>
***************
*** 127,131 ****
virtual bool canAttach (const Object& object) const;
! template <class FeatClass>
bool findFeat (const Object& object) const;
};
--- 128,137 ----
virtual bool canAttach (const Object& object) const;
! template <class T>
! struct IsInstance {
! bool operator() (Feat* feat);
! };
!
! template <class T>
bool findFeat (const Object& object) const;
};
***************
*** 140,143 ****
--- 146,182 ----
inline unsigned Feat::getSlotCount (Experience::Level xpLevel) {
return (xpLevel < 2? xpLevel: xpLevel / 3 + 1);
+ }
+
+ /**
+ * Determine if a feat is an instance of a specific feat. The
+ * specific feat is specified by the template parameter T.
+ *
+ * @param feat An instance of a feat.
+ * @return True if feat is an instance of the specific feat.
+ */
+ template <class T>
+ bool Feat::IsInstance<T>::operator() (Feat* feat) {
+ return (dynamic_cast<T*> (feat) != NULL);
+ }
+
+ /**
+ * Determine if a creature has a feat. This function only checks for an
+ * instance of the template parameter T. If the object is not a
+ * creature, this function will return false.
+ *
+ * @param object Object (Creature) to check.
+ * @return True if creature has an instance of T.
+ */
+ template <class T>
+ bool Feat::findFeat (const Object& object) const {
+ const Creature* creature = dynamic_cast<const Creature*> (&object);
+
+ if (creature != NULL) {
+ Creature::Feats feats = creature->getFeats ();
+ Creature::Feats::iterator end = feats.end ();
+ return (end != std::find_if (feats.begin (), end, IsInstance<T> ()));
+ }
+
+ return (false);
}
Index: Feature.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feature.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Feature.h 29 Mar 2003 02:10:29 -0000 1.4
--- Feature.h 4 Apr 2003 20:22:44 -0000 1.5
***************
*** 58,61 ****
--- 58,68 ----
/**
+ * Create a new feature.
+ */
+ inline Feature::Feature (): _object (NULL) {
+ // empty constructor body
+ }
+
+ /**
* Determine the object that this feature is currently attached to.
*
***************
*** 90,96 ****
/**
! * Determine if this feature can be detached to an object.
*
- * @param object Object to detach this feature from.
* @return True if the feature is detached from the object.
*/
--- 97,102 ----
/**
! * Determine if this feature can be detached from an object.
*
* @return True if the feature is detached from the object.
*/
***************
*** 99,107 ****
return (true);
}
-
- /**
- * Create a new feature.
- */
- inline Feature::Feature (): _object (NULL) { }
inline Feature::~Feature () { }
--- 105,108 ----
Index: Strength.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Strength.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Strength.h 29 Mar 2003 02:10:31 -0000 1.1
--- Strength.h 4 Apr 2003 20:22:44 -0000 1.2
***************
*** 33,42 ****
/**
! * An ability that determines physical force, carrying capacities, and
! * other similar qualities.
*/
class Strength: public Ability {
public:
! Strength (Ability::Method& method = Ability::standardMethod);
float getLightLoad (Size::Type sizeType = Size::MEDIUM) const;
--- 33,42 ----
/**
! * An ability that determines physical power and force. A Strength * modifier is added to attack rolls with melee weapons and damage * rolls with melee weapons, thrown weapons, and specially designed * projectile weapons. Strength is a special ability that has * additional operations for determining carrying capacities.
*/
class Strength: public Ability {
public:
! Strength ();
! Strength (Ability::Method& method);
float getLightLoad (Size::Type sizeType = Size::MEDIUM) const;
***************
*** 50,57 ****
/**
! * Create a new Strength score using a method. The default method for
! * generating a Strength score is the standard method.
*
! * @param method Method used to generate score.
*/
inline
--- 50,65 ----
/**
! * Create a new Strength score. The Strength score is generated using
! * the standard method.
! */
! inline
! Strength::Strength (): Ability (Ability::STR) {
! // empty constructor body
! }
!
! /**
! * Create a new Strength score using a method.
*
! * @param method A method for generating ability scores.
*/
inline
***************
*** 64,68 ****
* Determine the limit of light loads for this ability.
*
! * @param size Size of creature.
* @return Weight in pounds.
*/
--- 72,76 ----
* Determine the limit of light loads for this ability.
*
! * @param sizeType Size type of creature.
* @return Weight in pounds.
*/
***************
*** 75,79 ****
* Determine the limit of medium loads for this ability.
*
! * @param size Size of creature.
* @return Weight in pounds.
*/
--- 83,87 ----
* Determine the limit of medium loads for this ability.
*
! * @param sizeType Size type of creature.
* @return Weight in pounds.
*/
***************
*** 86,90 ****
* Determine the limit of heavy loads for this ability.
*
! * @param size Size of creature.
* @return Weight in pounds.
*/
--- 94,98 ----
* Determine the limit of heavy loads for this ability.
*
! * @param sizeType Size type of creature.
* @return Weight in pounds.
*/
|