[ogs-changes] dist/c++/ogs/core Abilities.cpp,1.1,1.2 Ability.cpp,1.2,1.3 Creature.cpp,1.6,1.7 Creat
Status: Alpha
Brought to you by:
elemings
Update of /cvsroot/ogs/dist/c++/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv1939/c++/ogs/core
Modified Files:
Abilities.cpp Ability.cpp Creature.cpp Creature.h Defense.cpp
Details.h Die.cpp Entity.cpp Entity.h Experience.cpp Feat.cpp
Feat.h Feature.cpp Feature.h Item.h Makefile.am Modifier.cpp
Modifiers.cpp Skill.cpp
Removed Files:
Size.cpp
Log Message:
See C++ ChangeLog file (Mar 24) for details.
Index: Abilities.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Abilities.cpp 7 Jan 2003 07:41:32 -0000 1.1
--- Abilities.cpp 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 23,27 ****
#include <stdexcept>
! #include "Abilities.h"
using ogs::core::Abilities;
--- 23,27 ----
#include <stdexcept>
! #include "ogs/core/Abilities.h"
using ogs::core::Abilities;
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Ability.cpp 13 Jan 2003 05:22:15 -0000 1.2
--- Ability.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 25,29 ****
#include <ogs/Support.h>
! #include "Ability.h"
using namespace ogs::support;
--- 25,29 ----
#include <ogs/Support.h>
! #include "ogs/core/Ability.h"
using namespace ogs::support;
Index: Creature.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Creature.cpp 23 Mar 2003 22:14:36 -0000 1.6
--- Creature.cpp 25 Mar 2003 06:13:11 -0000 1.7
***************
*** 23,30 ****
#include <algorithm>
! #include "Creature.h"
using ogs::core::Creature;
using ogs::core::Die;
/**
--- 23,32 ----
#include <algorithm>
! #include "ogs/core/Creature.h"
! #include "ogs/core/Feat.h"
using ogs::core::Creature;
using ogs::core::Die;
+ using ogs::core::Feat;
/**
Index: Creature.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Creature.h 23 Mar 2003 22:14:36 -0000 1.6
--- Creature.h 25 Mar 2003 06:13:11 -0000 1.7
***************
*** 32,44 ****
# include <ogs/core/Die.h>
# include <ogs/core/Entity.h>
- # include <ogs/core/Feat.h>
# include <ogs/core/Modifiers.h>
# include <ogs/core/Namespace.h>
# include <ogs/core/Saves.h>
- # include <ogs/core/Skill.h>
OGS_BEGIN_CORE_NAMESPACE
class Character;
/**
--- 32,44 ----
# 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>
OGS_BEGIN_CORE_NAMESPACE
class Character;
+ class Feat;
+ class Skill;
/**
Index: Defense.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Defense.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Defense.cpp 7 Jan 2003 07:41:32 -0000 1.1
--- Defense.cpp 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 23,28 ****
#include <ogs/support/Event.h>
! #include "Defense.h"
! #include "Modifier.h"
using ogs::support::Event;
--- 23,28 ----
#include <ogs/support/Event.h>
! #include "ogs/core/Defense.h"
! #include "ogs/core/Modifier.h"
using ogs::support::Event;
Index: Details.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Details.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Details.h 5 Feb 2003 06:01:28 -0000 1.1
--- Details.h 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 21,36 ****
*/
! #ifdef __cplusplus
!
! # ifndef OGS_DETAILS_H
! # define OGS_DETAILS_H
!
! # include <ogs/core/details/Alignment.h>
! # include <ogs/core/details/Description.h>
! # include <ogs/core/details/Gender.h>
! # include <ogs/core/details/Quantity.h>
! # endif /* !defined OGS_DETAILS_H */
! #endif /* defined __cplusplus */
--- 21,32 ----
*/
! #ifndef OGS_DETAILS_H
! # define OGS_DETAILS_H
! # include <ogs/core/details/Alignment.h>
! # include <ogs/core/details/Description.h>
! # include <ogs/core/details/Gender.h>
! # include <ogs/core/details/Quantity.h>
! #endif /* !defined OGS_DETAILS_H */
Index: Die.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Die.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Die.cpp 23 Mar 2003 22:14:36 -0000 1.2
--- Die.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 24,30 ****
#include <cstdlib>
! #include <ogs/support/Event.h>
!
! #include "Die.h"
using ogs::core::Die;
--- 24,29 ----
#include <cstdlib>
! #include "ogs/support/Event.h"
! #include "ogs/core/Die.h"
using ogs::core::Die;
Index: Entity.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Entity.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Entity.cpp 23 Mar 2003 22:14:36 -0000 1.3
--- Entity.cpp 25 Mar 2003 06:13:11 -0000 1.4
***************
*** 21,27 ****
*/
! #include <ogs/support/Event.h>
!
! #include "Entity.h"
using ogs::support::Event;
--- 21,26 ----
*/
! #include "ogs/support/Event.h"
! #include "ogs/core/Entity.h"
using ogs::support::Event;
***************
*** 47,51 ****
* @param weight Weight of entity.
*/
! void Entity::setWeight (float weight) {
Event event (*this);
this->_weight = weight;
--- 46,50 ----
* @param weight Weight of entity.
*/
! void Entity::setWeight (Weight weight) {
Event event (*this);
this->_weight = weight;
***************
*** 58,62 ****
* @param currentHealth Current health of this entity.
*/
! void Entity::setCurrentHealth (int currentHealth) {
// TODO: Make this a little more robust.
this->_currentHealth = currentHealth;
--- 57,61 ----
* @param currentHealth Current health of this entity.
*/
! void Entity::setCurrentHealth (Health currentHealth) {
// TODO: Make this a little more robust.
this->_currentHealth = currentHealth;
***************
*** 68,72 ****
* @param maximumHealth Maximum health of this entity.
*/
! void Entity::setMaximumHealth (int maximumHealth) {
// TODO: Make this a little more robust.
this->_maximumHealth = maximumHealth;
--- 67,71 ----
* @param maximumHealth Maximum health of this entity.
*/
! void Entity::setMaximumHealth (Health maximumHealth) {
// TODO: Make this a little more robust.
this->_maximumHealth = maximumHealth;
Index: Entity.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Entity.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Entity.h 23 Mar 2003 22:14:36 -0000 1.3
--- Entity.h 25 Mar 2003 06:13:11 -0000 1.4
***************
*** 26,30 ****
# define OGS_CORE_ENTITY_H
! # include <vector>
# include <ogs/support/Object.h>
--- 26,30 ----
# define OGS_CORE_ENTITY_H
! //# include <vector>
# include <ogs/support/Object.h>
***************
*** 37,57 ****
/**
! * An object in the game world. The @c Entity class is an abstract
! * class that contains attributes and operations common to all entities.
*/
class Entity: public ogs::support::Object {
public:
! virtual ~Entity () = 0;
! typedef std::vector<Feature*> Features;
! float getWeight () const;
! void setWeight (float weight);
Size& getSize ();
Defense& getDefense ();
! int getCurrentHealth () const;
! void setCurrentHealth (int currentHealth);
! int getMaximumHealth () const;
! void setMaximumHealth (int maximumHealth);
protected:
--- 37,64 ----
/**
! * An object in the game world. Entities are typically living creatures
! * or nonliving items. The @c Entity class is an abstract class that
! * contains attributes and operations common to all entities.
*/
class Entity: public ogs::support::Object {
public:
! /** Measures weight of entity. */
! typedef double Weight;
! /** Measures health or condition of entity. */
! typedef int Health;
! //typedef std::vector<Feature*> Features;
!
! Weight getWeight () const;
! void setWeight (Weight weight);
Size& getSize ();
Defense& getDefense ();
! Health getCurrentHealth () const;
! void setCurrentHealth (Health currentHealth);
! Health getMaximumHealth () const;
! void setMaximumHealth (Health maximumHealth);
!
! virtual ~Entity () = 0;
protected:
***************
*** 59,67 ****
private:
! float _weight;
Size _size;
Defense _defense;
! int _currentHealth;
! int _maximumHealth;
//Features _features;
};
--- 66,74 ----
private:
! Weight _weight;
Size _size;
Defense _defense;
! Health _currentHealth;
! Health _maximumHealth;
//Features _features;
};
***************
*** 73,77 ****
* @return current weight
*/
! inline float Entity::getWeight () const {
return (this->_weight);
}
--- 80,84 ----
* @return current weight
*/
! inline Entity::Weight Entity::getWeight () const {
return (this->_weight);
}
***************
*** 101,105 ****
* @return current health
*/
! inline int Entity::getCurrentHealth () const {
return (this->_currentHealth);
}
--- 108,112 ----
* @return current health
*/
! inline Entity::Health Entity::getCurrentHealth () const {
return (this->_currentHealth);
}
***************
*** 110,114 ****
* @return maximum health
*/
! inline int Entity::getMaximumHealth () const {
return (this->_maximumHealth);
}
--- 117,121 ----
* @return maximum health
*/
! inline Entity::Health Entity::getMaximumHealth () const {
return (this->_maximumHealth);
}
Index: Experience.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Experience.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Experience.cpp 13 Jan 2003 05:22:15 -0000 1.2
--- Experience.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 21,25 ****
*/
! #include "Experience.h"
using ogs::core::Experience;
--- 21,25 ----
*/
! #include "ogs/core/Experience.h"
using ogs::core::Experience;
Index: Feat.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feat.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Feat.cpp 13 Jan 2003 05:22:15 -0000 1.2
--- Feat.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 21,27 ****
*/
! #include <stdexcept>
!
! #include "Feat.h"
using ogs::core::Experience;
--- 21,26 ----
*/
! #include "ogs/core/Creature.h"
! #include "ogs/core/Feat.h"
using ogs::core::Experience;
***************
*** 45,48 ****
--- 44,88 ----
return (xpLevel);
+ }
+
+ /**
+ * Determine if this feat can be attached to an object. Feats can only
+ * be attached to creatures. If the object is not a creature, this
+ * function will return false.
+ *
+ * @param object Object to attach this feature to.
+ * @return True if the feature is attached to the object.
+ */
+ bool Feat::canAttach (Object& object) const {
+ return (Feature::canAttach (object) &&
+ dynamic_cast<Creature*> (&object) != NULL);
+ }
+
+ /**
+ * 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 (Object& object) const {
+ bool found = false;
+ Creature* creature = dynamic_cast<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;
+ }
+
+ ++itor;
+ }
+ }
+
+ return (found);
}
Index: Feat.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feat.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Feat.h 23 Mar 2003 22:14:36 -0000 1.4
--- Feat.h 25 Mar 2003 06:13:11 -0000 1.5
***************
*** 69,72 ****
--- 69,105 ----
};
+ /**
+ * The group that a feat belongs to. Feats can be classified into
+ * several different groups.
+ */
+ enum Group {
+
+ /**
+ * A general-purpose feat. General feats are feats that do not
+ * fall into one of the other groups.
+ */
+ GENERAL = 0,
+
+ /**
+ * A combat-use feat. Combat feats are feats that are
+ * specifically designed for use in combat. The bonus feats
+ * granted to fighters are limited to combat feats.
+ */
+ COMBAT = 1,
+
+ /**
+ * A magic-related feat. Magic feats include metamagic feats for
+ * enhancing spells and item creation feats for creating magic
+ * items. The bonus feats granted to wizards are limited to magic
+ * feats.
+ */
+ MAGIC = 2,
+
+ /**
+ * A feat that does not belong to one of the other groups.
+ */
+ SPECIAL = 3,
+ };
+
static unsigned getSlotCount (Experience::Level xpLevel);
static Experience::Level getSlotCountLevel (unsigned slotCount);
***************
*** 78,81 ****
--- 111,129 ----
*/
virtual Compatibility getCompatibility () const = 0;
+
+ /**
+ * Determine the group that this feat belongs to.
+ *
+ * @return Group that this feat belongs to.
+ */
+ virtual Group getGroup () const = 0;
+
+ virtual ~Feat ();
+
+ protected:
+ virtual bool canAttach (ogs::support::Object& object) const;
+
+ template <class FeatClass>
+ bool findFeat (ogs::support::Object& object) const;
};
***************
*** 90,93 ****
--- 138,143 ----
return (xpLevel < 2? xpLevel: xpLevel / 3 + 1);
}
+
+ inline Feat::~Feat () { }
OGS_END_CORE_NAMESPACE
Index: Feature.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feature.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Feature.cpp 25 Feb 2003 19:40:18 -0000 1.2
--- Feature.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 21,25 ****
*/
! #include "Feature.h"
using ogs::core::Feature;
--- 21,25 ----
*/
! #include "ogs/core/Feature.h"
using ogs::core::Feature;
***************
*** 33,45 ****
*/
bool Feature::attachObject (Object& object) {
! bool success = false;
! // A feature can not be attached to itself.
! if (&object != this) {
this->_object = &object;
- success = true;
}
! return (success);
}
--- 33,59 ----
*/
bool Feature::attachObject (Object& object) {
! bool attached = canAttach (object);
! if (attached) {
this->_object = &object;
}
! return (attached);
! }
!
! /**
! * Detach this feature from an object. This method should always be
! * called last by derived classes that override this method.
! *
! * @return True if the feature is detached from the object.
! */
! bool Feature::detachObject () {
! bool detached = canDetach ();
!
! if (detached) {
! this->_object = NULL;
! }
!
! return (detached);
}
Index: Feature.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Feature.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Feature.h 25 Feb 2003 19:40:18 -0000 1.2
--- Feature.h 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 31,36 ****
OGS_BEGIN_CORE_NAMESPACE
- using ogs::support::Object;
-
/**
* A feature is an object that can be attached to another object. While
--- 31,34 ----
***************
*** 39,65 ****
* detached from the object.
*/
! class Feature: public Object {
public:
! virtual bool attachObject (Object& object);
virtual bool detachObject ();
! const Object* getObject () const;
! Object* getObject ();
virtual ~Feature ();
private:
! Object* _object;
};
/**
! * Detach this feature from an object. This method should always be
! * called last by derived classes that override this method.
*
! * @return True if the feature is detached from the object.
*/
! inline bool Feature::detachObject () {
! this->_object = NULL;
! return (true);
}
--- 37,66 ----
* detached from the object.
*/
! class Feature: public ogs::support::Object {
public:
! virtual bool attachObject (ogs::support::Object& object);
virtual bool detachObject ();
! const ogs::support::Object* getObject () const;
! ogs::support::Object* getObject ();
virtual ~Feature ();
+ protected:
+ virtual bool canAttach (ogs::support::Object& object) const;
+ virtual bool canDetach () const;
+
private:
! ogs::support::Object* _object;
};
/**
! * Determine the object that this feature is currently attached to.
*
! * @return Attached object or NULL if not attached.
*/
! inline const ogs::support::Object*
! Feature::getObject () const {
! return (this->_object);
}
***************
*** 69,83 ****
* @return Attached object or NULL if not attached.
*/
! inline const Object* Feature::getObject () const {
return (this->_object);
}
/**
! * Determine the object that this feature is currently attached to.
*
! * @return Attached object or NULL if not attached.
*/
! inline Object* Feature::getObject () {
! return (this->_object);
}
--- 70,99 ----
* @return Attached object or NULL if not attached.
*/
! inline ogs::support::Object*
! Feature::getObject () {
return (this->_object);
}
/**
! * Determine if this feature can be attached to an object. A feature
! * can not be attached to itself or if it is already attached.
*
! * @param object Object to attach this feature to.
! * @return True if the feature is attached to the object.
*/
! inline bool
! Feature::canAttach (Object& object) const {
! return (&object != this && _object == NULL);
! }
!
! /**
! * 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.
! */
! inline bool
! Feature::canDetach () const {
! return (true);
}
Index: Item.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Item.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Item.h 7 Jan 2003 07:41:33 -0000 1.1
--- Item.h 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 35,40 ****
--- 35,82 ----
*/
class Item: public Entity {
+ public:
+ /**
+ * Measures how hard the material is that the item is made of.
+ * Higher values indicate harder items that are harder to break.
+ */
+ typedef unsigned Hardness;
+
+ /**
+ * Measures how thick the item is. Thickness is used to calculate
+ * health of the item. Units of measure are locale-dependent.
+ */
+ typedef double Thickness;
+
+ /**
+ * Number of health points per unit of thickness. Density is also
+ * used to calculate health of the item.
+ */
+ typedef Entity::Health Density;
+
+ /**
+ * Measures how much the item is worth. Units of measure are
+ * locale-dependent.
+ */
+ typedef double Worth;
+
+ Worth getWorth () const;
+ void setWorth (Worth worth);
+ protected:
+ Item ();
+
+ private:
+ Worth _worth;
};
+
+ /**
+ * Determine the worth of this item.
+ *
+ * @return Worth of this item.
+ */
+ inline Item::Worth
+ Item::getWorth () const {
+ return (this->_worth);
+ }
OGS_END_CORE_NAMESPACE
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 4 Mar 2003 03:24:41 -0000 1.5
--- Makefile.am 25 Mar 2003 06:13:11 -0000 1.6
***************
*** 74,78 ****
Modifier.cpp \
Modifiers.cpp \
- Size.cpp \
Skill.cpp
libogs_core_la_LIBADD = \
--- 74,77 ----
Index: Modifier.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifier.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifier.cpp 7 Jan 2003 07:41:33 -0000 1.1
--- Modifier.cpp 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 25,31 ****
#include <typeinfo>
! #include <ogs/Support.h>
!
! #include "Modifier.h"
using namespace ogs::support;
--- 25,30 ----
#include <typeinfo>
! #include "ogs/Support.h"
! #include "ogs/core/Modifier.h"
using namespace ogs::support;
Index: Modifiers.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifiers.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifiers.cpp 7 Jan 2003 07:41:33 -0000 1.1
--- Modifiers.cpp 25 Mar 2003 06:13:11 -0000 1.2
***************
*** 21,25 ****
*/
! #include "Modifiers.h"
using ogs::support::Event;
--- 21,25 ----
*/
! #include "ogs/core/Modifiers.h"
using ogs::support::Event;
Index: Skill.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Skill.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Skill.cpp 24 Feb 2003 11:14:21 -0000 1.2
--- Skill.cpp 25 Mar 2003 06:13:11 -0000 1.3
***************
*** 23,29 ****
#include <stdexcept>
! //#include <ogs/support/Event.h>
!
! #include "Skill.h"
using ogs::support::Event;
--- 23,28 ----
#include <stdexcept>
! //#include "ogs/support/Event.h"
! #include "ogs/core/Skill.h"
using ogs::support::Event;
--- Size.cpp DELETED ---
|