[ogs-changes] dist/c++/ogs/magic AbsoluteRange.h,1.2,1.3 Component.h,1.2,1.3 Descriptors.h,1.1,1.2 L
Status: Alpha
Brought to you by:
elemings
|
From: <ele...@us...> - 2003-05-02 19:07:09
|
Update of /cvsroot/ogs/dist/c++/ogs/magic
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/magic
Modified Files:
AbsoluteRange.h Component.h Descriptors.h LevelRange.h
Makefile.am PhysicalComponent.h Range.h School.cpp School.h
Spell.cpp Spell.h Subschool.cpp Subschool.h Types.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: AbsoluteRange.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/AbsoluteRange.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AbsoluteRange.h 18 Apr 2003 01:41:06 -0000 1.2
--- AbsoluteRange.h 2 May 2003 19:06:32 -0000 1.3
***************
*** 37,48 ****
class AbsoluteRange: public Range {
public:
! AbsoluteRange (float distance);
! float getDistance () const;
protected:
/** Maximum distance of this spell range. */
! float distance;
! AbsoluteRange (Range::Type type, float distance);
};
--- 37,52 ----
class AbsoluteRange: public Range {
public:
! /** A floating-point type representing distance. */
! typedef double Distance;
!
! AbsoluteRange (Distance distance);
! Distance getDistance () const;
! virtual Range* createCopy () const;
protected:
/** Maximum distance of this spell range. */
! Distance _distance;
! AbsoluteRange (Range::Type type, Distance distance);
};
***************
*** 52,58 ****
* @param distance Maximum distance of absolute range.
*/
! inline AbsoluteRange::AbsoluteRange (float distance):
! Range (Range::ABSOLUTE) {
! this->distance = distance;
}
--- 56,64 ----
* @param distance Maximum distance of absolute range.
*/
! inline
! AbsoluteRange::AbsoluteRange (Distance distance):
! Range (Range::ABSOLUTE),
! _distance (distance) {
! // empty constructor body
}
***************
*** 60,69 ****
* Create a new absolute range based on caster level.
*
! * @param type Type of spell range: CLOSE, MEDIUM, or LONG.
* @param distance Maximum distance of absolute range.
*/
! inline AbsoluteRange::AbsoluteRange (Range::Type type, float distance):
! Range (type) {
! this->distance = distance;
}
--- 66,87 ----
* Create a new absolute range based on caster level.
*
! * @param type Type of spell range (CLOSE, MEDIUM, or LONG).
* @param distance Maximum distance of absolute range.
*/
! inline
! AbsoluteRange::AbsoluteRange (Range::Type type, Distance distance):
! Range (type),
! _distance (distance) {
! // empty constructor body
! }
!
! /**
! * Create a copy of this absolute range.
! *
! * @return A pointer to a copy of this absolute range.
! */
! inline Range*
! AbsoluteRange::createCopy () const {
! return (new AbsoluteRange (*this));
}
***************
*** 73,78 ****
* @return Distance of absolute range.
*/
! inline float AbsoluteRange::getDistance () const {
! return (this->distance);
}
--- 91,97 ----
* @return Distance of absolute range.
*/
! inline AbsoluteRange::Distance
! AbsoluteRange::getDistance () const {
! return (this->_distance);
}
Index: Component.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Component.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Component.h 27 Feb 2003 22:42:17 -0000 1.2
--- Component.h 2 May 2003 19:06:32 -0000 1.3
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_MAGIC_COMPONENT_H
+ # include <sstream>
+ # include <stdexcept>
# include <string>
***************
*** 104,108 ****
* @return Verbal spell component.
*/
! inline Component Component::Verbal () {
return (Component (Component::VERBAL));
}
--- 106,111 ----
* @return Verbal spell component.
*/
! inline Component
! Component::Verbal () {
return (Component (Component::VERBAL));
}
***************
*** 113,117 ****
* @return Somantic spell component.
*/
! inline Component Component::Somantic () {
return (Component (Component::SOMANTIC));
}
--- 116,121 ----
* @return Somantic spell component.
*/
! inline Component
! Component::Somantic () {
return (Component (Component::SOMANTIC));
}
***************
*** 122,126 ****
* @return Spell component with Divine Focus type.
*/
! inline Component Component::DivineFocus () {
return (Component (Component::DIVINE_FOCUS));
}
--- 126,131 ----
* @return Spell component with Divine Focus type.
*/
! inline Component
! Component::DivineFocus () {
return (Component (Component::DIVINE_FOCUS));
}
***************
*** 131,135 ****
* @return Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
*/
! inline Component::Type Component::getType () const {
return (this->_type);
}
--- 136,141 ----
* @return Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
*/
! inline Component::Type
! Component::getType () const {
return (this->_type);
}
***************
*** 140,144 ****
* @return Abbreviation for this type of component.
*/
! inline std::string Component::getAbbreviation () const {
return (this->_type == VERBAL? "V":
this->_type == SOMANTIC? "S":
--- 146,151 ----
* @return Abbreviation for this type of component.
*/
! inline std::string
! Component::getAbbreviation () const {
return (this->_type == VERBAL? "V":
this->_type == SOMANTIC? "S":
***************
*** 150,153 ****
--- 157,176 ----
/**
+ * Create a new component.
+ *
+ * @param type Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
+ * @throws std::invalid_argument If type is not a valid component type.
+ */
+ inline
+ Component::Component (Type type):
+ _type (type) {
+ if (! isValid (type)) {
+ std::ostringstream ostr;
+ ostr << "invalid component type (" << int (type) << ")";
+ throw std::invalid_argument (ostr.str ());
+ }
+ }
+
+ /**
* Determine if an integer value is a valid type of component.
*
***************
*** 155,159 ****
* @return True if integer value is a valid type of component.
*/
! inline bool Component::isValid (int value) {
return (value == VERBAL ||
value == SOMANTIC ||
--- 178,183 ----
* @return True if integer value is a valid type of component.
*/
! inline bool
! Component::isValid (int value) {
return (value == VERBAL ||
value == SOMANTIC ||
Index: Descriptors.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Descriptors.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Descriptors.h 7 Jan 2003 07:41:33 -0000 1.1
--- Descriptors.h 2 May 2003 19:06:32 -0000 1.2
***************
*** 48,53 ****
* type can be used as bit positions in the @c std::bitset class.
* If this class is extended, values ranging from 0 to 16 are
! * reserved. This type is explicitly named in case the underlying
! * type should changes in the future.
*/
typedef size_t Type;
--- 48,52 ----
* type can be used as bit positions in the @c std::bitset class.
* If this class is extended, values ranging from 0 to 16 are
! * reserved.
*/
typedef size_t Type;
Index: LevelRange.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/LevelRange.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LevelRange.h 13 Apr 2003 05:27:50 -0000 1.3
--- LevelRange.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 23,28 ****
#ifdef __cplusplus
! # ifndef OGS_MAGIC_LEVELRANGE_H
! # define OGS_MAGIC_LEVELRANGE_H
# include <ogs/core/Experience.h>
--- 23,28 ----
#ifdef __cplusplus
! # ifndef OGS_MAGIC_LEVEL_RANGE_H
! # define OGS_MAGIC_LEVEL_RANGE_H
# include <ogs/core/Experience.h>
***************
*** 32,37 ****
OGS_BEGIN_MAGIC_NAMESPACE
- using ogs::core::XP;
-
/**
* An absolute range that is based on caster level. Level-based spell
--- 32,35 ----
***************
*** 44,72 ****
class LevelRange: public AbsoluteRange {
public:
! static LevelRange Close (XP::Level casterLevel);
! static LevelRange Medium (XP::Level casterLevel);
! static LevelRange Long (XP::Level casterLevel);
! XP::Level getCasterLevel () const;
private:
! XP::Level casterLevel;
! LevelRange (Range::Type type, float distance,
! XP::Level casterLevel);
};
/**
* Determine the caster level for this level-based range.
*
* @return Caster level.
*/
! inline XP::Level LevelRange::getCasterLevel () const {
! return (this->casterLevel);
}
OGS_END_MAGIC_NAMESPACE
! # endif /* !defined OGS_MAGIC_LEVELRANGE_H */
#endif /* defined __cplusplus */
--- 42,136 ----
class LevelRange: public AbsoluteRange {
public:
! static LevelRange Close (ogs::core::XP::Level casterLevel);
! static LevelRange Medium (ogs::core::XP::Level casterLevel);
! static LevelRange Long (ogs::core::XP::Level casterLevel);
! ogs::core::XP::Level getCasterLevel () const;
!
! Range* createCopy () const;
private:
! ogs::core::XP::Level _casterLevel;
! LevelRange (Range::Type type,
! Distance distance,
! ogs::core::XP::Level casterLevel);
};
/**
+ * Create a close spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Close (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 25.0 + (5.0 * (casterLevel / 2));
+ return (LevelRange (Range::CLOSE, distance, casterLevel));
+ }
+
+ /**
+ * Create a medium spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Medium (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 100.0 + (10.0 * casterLevel);
+ return (LevelRange (Range::MEDIUM, distance, casterLevel));
+ }
+
+ /**
+ * Create a long spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Long (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 400.0 + (40.0 * casterLevel);
+ return (LevelRange (Range::LONG, distance, casterLevel));
+ }
+
+ /**
* Determine the caster level for this level-based range.
*
* @return Caster level.
*/
! inline ogs::core::XP::Level
! LevelRange::getCasterLevel () const {
! return (this->_casterLevel);
! }
!
! /**
! * Create a copy of this level-based range.
! *
! * @return A pointer to a copy of this level-based range.
! */
! inline Range*
! LevelRange::createCopy () const {
! return (new LevelRange (*this));
! }
!
! /**
! * Create a new level-based range.
! *
! * @param type Type of spell range (CLOSE, MEDIUM, or LONG).
! * @param distance Maximum distance of range.
! * @param casterLevel Experience level of spell caster.
! */
! inline
! LevelRange::LevelRange (Range::Type type,
! Distance distance,
! ogs::core::XP::Level casterLevel):
! AbsoluteRange (type, distance),
! _casterLevel (casterLevel) {
! // empty constructor body
}
OGS_END_MAGIC_NAMESPACE
! # endif /* !defined OGS_MAGIC_LEVEL_RANGE_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Makefile.am 18 Apr 2003 03:24:42 -0000 1.8
--- Makefile.am 2 May 2003 19:06:32 -0000 1.9
***************
*** 58,63 ****
libogs_magic_la_SOURCES = \
Ability.cpp \
- Component.cpp \
- LevelRange.cpp \
MetamagicFeat.cpp \
School.cpp \
--- 58,61 ----
Index: PhysicalComponent.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/PhysicalComponent.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PhysicalComponent.h 28 Feb 2003 11:11:25 -0000 1.3
--- PhysicalComponent.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 41,55 ****
class PhysicalComponent: public Component {
public:
static PhysicalComponent
Material (const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
static PhysicalComponent
Focus (const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
const std::string& getDetails () const;
! float getCost () const;
bool useDivineFocus () const;
--- 41,61 ----
class PhysicalComponent: public Component {
public:
+ /**
+ * A floating-point type representing the monetary cost of a
+ * physical component.
+ */
+ typedef double Cost;
+
static PhysicalComponent
Material (const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
static PhysicalComponent
Focus (const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
const std::string& getDetails () const;
! Cost getCost () const;
bool useDivineFocus () const;
***************
*** 57,66 ****
PhysicalComponent (Component::Type type,
const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
private:
std::string _details;
! float _cost;
bool _useDivineFocus;
};
--- 63,72 ----
PhysicalComponent (Component::Type type,
const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
private:
std::string _details;
! Cost _cost;
bool _useDivineFocus;
};
***************
*** 77,81 ****
inline PhysicalComponent
PhysicalComponent::Material (const std::string& details,
! float cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::MATERIAL, details,
--- 83,87 ----
inline PhysicalComponent
PhysicalComponent::Material (const std::string& details,
! Cost cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::MATERIAL, details,
***************
*** 94,98 ****
inline PhysicalComponent
PhysicalComponent::Focus (const std::string& details,
! float cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::FOCUS, details,
--- 100,104 ----
inline PhysicalComponent
PhysicalComponent::Focus (const std::string& details,
! Cost cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::FOCUS, details,
***************
*** 105,109 ****
* @return Details of component.
*/
! inline const std::string& PhysicalComponent::getDetails () const {
return (this->_details);
}
--- 111,116 ----
* @return Details of component.
*/
! inline const std::string&
! PhysicalComponent::getDetails () const {
return (this->_details);
}
***************
*** 114,118 ****
* @return Cost in standard monetary units.
*/
! inline float PhysicalComponent::getCost () const {
return (this->_cost);
}
--- 121,126 ----
* @return Cost in standard monetary units.
*/
! inline PhysicalComponent::Cost
! PhysicalComponent::getCost () const {
return (this->_cost);
}
***************
*** 124,128 ****
* @return True if divine fcous is required for divine spell.
*/
! inline bool PhysicalComponent::useDivineFocus () const {
return (this->_useDivineFocus);
}
--- 132,137 ----
* @return True if divine fcous is required for divine spell.
*/
! inline bool
! PhysicalComponent::useDivineFocus () const {
return (this->_useDivineFocus);
}
***************
*** 140,146 ****
PhysicalComponent::PhysicalComponent (Component::Type type,
const std::string& details,
! float cost,
bool useDivineFocus):
! Component (type), _details (details), _cost (cost),
_useDivineFocus (useDivineFocus) {
// empty body
--- 149,157 ----
PhysicalComponent::PhysicalComponent (Component::Type type,
const std::string& details,
! Cost cost,
bool useDivineFocus):
! Component (type),
! _details (details),
! _cost (cost),
_useDivineFocus (useDivineFocus) {
// empty body
Index: Range.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Range.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Range.h 29 Mar 2003 02:10:39 -0000 1.3
--- Range.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 74,77 ****
--- 74,78 ----
Type getType () const;
+ virtual Range* createCopy () const;
protected:
***************
*** 87,91 ****
* @return Spell range with Personal type.
*/
! inline Range Range::Personal () {
return (Range (Range::PERSONAL));
}
--- 88,93 ----
* @return Spell range with Personal type.
*/
! inline Range
! Range::Personal () {
return (Range (Range::PERSONAL));
}
***************
*** 96,100 ****
* @return Spell range with Touch type.
*/
! inline Range Range::Touch () {
return (Range (Range::TOUCH));
}
--- 98,103 ----
* @return Spell range with Touch type.
*/
! inline Range
! Range::Touch () {
return (Range (Range::TOUCH));
}
***************
*** 105,109 ****
* @return Spell range with Unlimited type.
*/
! inline Range Range::Unlimited () {
return (Range (Range::UNLIMITED));
}
--- 108,113 ----
* @return Spell range with Unlimited type.
*/
! inline Range
! Range::Unlimited () {
return (Range (Range::UNLIMITED));
}
***************
*** 114,118 ****
* @param type Type of range.
*/
! inline Range::Range (Type type): _type (type) {
// empty constructor body
}
--- 118,123 ----
* @param type Type of range.
*/
! inline Range::Range (Type type):
! _type (type) {
// empty constructor body
}
***************
*** 123,129 ****
* @return Type of spell range.
*/
! inline Range::Type Range::getType () const {
return (this->_type);
};
OGS_END_MAGIC_NAMESPACE
--- 128,145 ----
* @return Type of spell range.
*/
! inline
! Range::Type Range::getType () const {
return (this->_type);
};
+
+ /**
+ * Create a copy of this range.
+ *
+ * @return A pointer to a copy of this range.
+ */
+ inline Range*
+ Range::createCopy () const {
+ return (new Range (*this));
+ }
OGS_END_MAGIC_NAMESPACE
Index: School.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/School.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** School.cpp 25 Mar 2003 06:13:13 -0000 1.2
--- School.cpp 2 May 2003 19:06:32 -0000 1.3
***************
*** 1,4 ****
/*
! * School.cpp -- class implementation for School magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * School.cpp -- class implementation for arcane magic schools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 34,43 ****
* @throw invalid_argument If type is invalid.
*/
! inline School::School (Type type) {
! if (isValid (type)) {
! this->type = type;
! } else {
std::ostringstream ostr;
! ostr << "Invalid subschool type: " << type;
throw std::invalid_argument (ostr.str ());
}
--- 34,42 ----
* @throw invalid_argument If type is invalid.
*/
! School::School (Type type):
! _type (type) {
! if (! isValid (type)) {
std::ostringstream ostr;
! ostr << "invalid school type (" << int (type) << ")";
throw std::invalid_argument (ostr.str ());
}
***************
*** 47,62 ****
* Determine name of this school.
*
! * @return "Universal", "Abjuration", ...
*/
std::string School::getName () const {
! return (type == UNIVERSAL? "Universal":
! type == ABJURATION? "Abjuration":
! type == CONJURATION? "Conjuration":
! type == DIVINATION? "Divination":
! type == ENCHANTMENT? "Enchantment":
! type == EVOCATION? "Evocation":
! type == ILLUSION? "Illusion":
! type == NECROMANCY? "Necromancy":
! type == TRANSMUTATION? "Transmutation": "");
}
--- 46,61 ----
* Determine name of this school.
*
! * @return Name of school ("Universal", "Abjuration", etc.)
*/
std::string School::getName () const {
! return (this->_type == UNIVERSAL? "Universal":
! this->_type == ABJURATION? "Abjuration":
! this->_type == CONJURATION? "Conjuration":
! this->_type == DIVINATION? "Divination":
! this->_type == ENCHANTMENT? "Enchantment":
! this->_type == EVOCATION? "Evocation":
! this->_type == ILLUSION? "Illusion":
! this->_type == NECROMANCY? "Necromancy":
! this->_type == TRANSMUTATION? "Transmutation": "");
}
Index: School.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/School.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** School.h 23 Mar 2003 22:14:36 -0000 1.3
--- School.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 1,4 ****
/*
! * School.h -- class interface for schools of arcane magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * School.h -- class interface for arcane magic schools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 29,32 ****
--- 29,33 ----
# include <ogs/magic/Namespace.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
***************
*** 34,38 ****
/**
* A school of arcance magic. Each type of spell belongs to exactly one
! * school. The Wizard cclass may specialize in one of these schools.
*/
class School {
--- 35,40 ----
/**
* A school of arcance magic. Each type of spell belongs to exactly one
! * school. The Wizard cclass may specialize in one of these schools
! * (except the Universal school).
*/
class School {
***************
*** 43,47 ****
* Spells that deal with magic in general.
*/
! UNIVERSAL = 0,
/**
--- 45,49 ----
* Spells that deal with magic in general.
*/
! UNIVERSAL = 1,
/**
***************
*** 51,55 ****
* Transmutation; or both Divination and Necromancy.
*/
! ABJURATION = 1,
/**
--- 53,57 ----
* Transmutation; or both Divination and Necromancy.
*/
! ABJURATION,
/**
***************
*** 60,64 ****
* schools.
*/
! CONJURATION = 2,
/**
--- 62,66 ----
* schools.
*/
! CONJURATION,
/**
***************
*** 67,71 ****
* the wizard's choice.
*/
! DIVINATION = 3,
/**
--- 69,73 ----
* the wizard's choice.
*/
! DIVINATION,
/**
***************
*** 75,79 ****
* Divination and Necromancy.
*/
! ENCHANTMENT = 4,
/**
--- 77,81 ----
* Divination and Necromancy.
*/
! ENCHANTMENT,
/**
***************
*** 84,88 ****
* schools.
*/
! EVOCATION = 5,
/**
--- 86,90 ----
* schools.
*/
! EVOCATION,
/**
***************
*** 92,96 ****
* Transmutation; or both Divination and Necromancy.
*/
! ILLUSION = 6,
/**
--- 94,98 ----
* Transmutation; or both Divination and Necromancy.
*/
! ILLUSION,
/**
***************
*** 99,103 ****
* the wizard's choice.
*/
! NECROMANCY = 7,
/**
--- 101,105 ----
* the wizard's choice.
*/
! NECROMANCY,
/**
***************
*** 107,120 ****
* Enchantment, and Illusion; or (d) any three schools.
*/
! TRANSMUTATION = 8
};
School (Type type);
Type getType () const;
! std::string getName () const;
private:
! Type type;
! static bool isValid (Type type);
};
--- 109,124 ----
* Enchantment, and Illusion; or (d) any three schools.
*/
! TRANSMUTATION
};
School (Type type);
Type getType () const;
! virtual std::string getName () const;
! virtual School* createCopy () const;
private:
! Type _type;
!
! static bool isValid (int i);
};
***************
*** 124,147 ****
* @return Type of school.
*/
! inline School::Type School::getType () const {
! return (this->type);
}
/**
! * Determine if type is a valid school of magic.
*
! * @param type
! * @return True if type is a valid school of magic.
*/
! inline bool School::isValid (Type type) {
! return (type == UNIVERSAL ||
! type == ABJURATION ||
! type == CONJURATION ||
! type == DIVINATION ||
! type == ENCHANTMENT ||
! type == EVOCATION ||
! type == ILLUSION ||
! type == NECROMANCY ||
! type == TRANSMUTATION);
}
--- 128,163 ----
* @return Type of school.
*/
! inline School::Type
! School::getType () const {
! return (this->_type);
}
/**
! * Determine if an integer value is a valid school of magic.
*
! * @param i An integer value.
! * @return True if integer value is a valid school of magic.
*/
! inline bool
! School::isValid (int i) {
! return (i == UNIVERSAL ||
! i == ABJURATION ||
! i == CONJURATION ||
! i == DIVINATION ||
! i == ENCHANTMENT ||
! i == EVOCATION ||
! i == ILLUSION ||
! i == NECROMANCY ||
! i == TRANSMUTATION);
! }
!
! /**
! * Create a new copy of this school.
! *
! * @return A pointer to a copy of this school.
! */
! inline School*
! School::createCopy () const {
! return (new School (*this));
}
Index: Spell.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Spell.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Spell.cpp 4 Apr 2003 20:22:46 -0000 1.4
--- Spell.cpp 2 May 2003 19:06:32 -0000 1.5
***************
*** 30,45 ****
* Attach a metamagic feat to this spell.
*
! * @param metamagicFeat A metamagic feat.
* @return True if metamagic feat is attached to this spell.
*/
bool Spell::attachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool success = false;
! if (metamagicFeat.attachObject (*this)) {
! this->_metamagicFeats.push_back (&metamagicFeat);
! success = true;
}
! return (success);
}
--- 30,60 ----
* Attach a metamagic feat to this spell.
*
! * @param metamagicFeat A metamagic feat to attach to this spell.
* @return True if metamagic feat is attached to this spell.
*/
bool Spell::attachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool attached = metamagicFeat.attachSpell (*this);
! if (attached) {
! this->_metamagicFeats.push_back (MetamagicFeatPtr (&metamagicFeat));
}
! return (attached);
! }
!
! /**
! * Detach a metamgaic feat from this spell.
! *
! * @param metamagicFeat A metamagic feat to detach from this spell.
! * @param True if metamagic feat is detached from this spell.
! */
! bool Spell::detachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool detached = metamagicFeat.detachSpell ();
!
! if (detached) {
! this->_metamagicFeats.remove (MetamagicFeatPtr (&metamagicFeat));
! }
!
! return (detached);
}
Index: Spell.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Spell.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Spell.h 4 Apr 2003 20:22:47 -0000 1.5
--- Spell.h 2 May 2003 19:06:32 -0000 1.6
***************
*** 27,38 ****
# include <list>
- # include <vector>
# include <ogs/support/Object.h>
- # include <ogs/magic/Component.h>
# include <ogs/magic/Descriptors.h>
# include <ogs/magic/Namespace.h>
# include <ogs/magic/Range.h>
# include <ogs/magic/School.h>
OGS_BEGIN_MAGIC_NAMESPACE
--- 27,37 ----
# include <list>
# include <ogs/support/Object.h>
# include <ogs/magic/Descriptors.h>
# include <ogs/magic/Namespace.h>
# include <ogs/magic/Range.h>
# include <ogs/magic/School.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
***************
*** 45,109 ****
class Spell: public ogs::support::Object {
public:
! /** A list of spell components. */
! typedef std::list<Component> Components;
!
! /**
! * Determine the school (and subschool if applicable) that this
! * spell belongs to.
! *
! * @return School (and subschool) of this spell.
! */
! virtual const School& getSchool () const = 0;
!
! virtual Descriptors getDescriptors () const;
!
! /**
! * Determine the components needed to cast this spell. The
! * components of a spell may vary from plain versions of the spell
! * due to metamagic feats.
! *
! * @return Array of components for this spell.
! */
! virtual Components getComponents () const = 0;
!
! /**
! * Determine the range of this spell. The range of a spell may vary
! * from normal versions of the spell due to metamagic feats.
! *
! * @return Range of this spell.
! */
! virtual Range getRange () const = 0;
virtual bool attachMetamagicFeat (MetamagicFeat& metamagicFeat);
virtual ~Spell () { }
protected:
! Spell ();
private:
! typedef std::vector<MetamagicFeat*> MetamagicFeats;
MetamagicFeats _metamagicFeats;
};
/**
! * Determine descriptors for this spell. Many spells have no
! * descriptors. Therefore, this function returns an empty set of
! * descriptors by default. Derived classes must override this function
! * if the spell has @em any descriptors.
*
* @return Descriptors for this spell.
*/
! inline Descriptors Spell::getDescriptors () const {
! Descriptors descriptors;
! return (descriptors);
}
/**
! * Create a new spell. This constructor is protected so only this class
! * and derived classes can use it. All it does is create an empty array
! * of metamagic feats.
*/
! inline Spell::Spell (): _metamagicFeats () { }
OGS_END_MAGIC_NAMESPACE
--- 44,134 ----
class Spell: public ogs::support::Object {
public:
! const School& getSchool () const;
! Descriptors getDescriptors () const;
! Components getComponents () const;
! const Range& getRange () const;
+ MetamagicFeats getMetamagicFeats () const;
virtual bool attachMetamagicFeat (MetamagicFeat& metamagicFeat);
+ virtual bool detachMetamagicFeat (MetamagicFeat& metamagicFeat);
+
+ virtual void castSpell () = 0;
virtual ~Spell () { }
protected:
! Spell (const School& school,
! Components components,
! const Range& range,
! Descriptors descriptors = Descriptors ());
private:
! SchoolPtr _school;
! Components _components;
! RangePtr _range;
! Descriptors _descriptors;
MetamagicFeats _metamagicFeats;
};
/**
! * Determine the school or subschool of this spell.
! *
! * @return School or subschool of this spell.
! */
! inline const School&
! Spell::getSchool () const {
! return (*(this->_school));
! }
!
! /**
! * Determine the descriptors for this spell.
*
* @return Descriptors for this spell.
*/
! inline Descriptors
! Spell::getDescriptors () const {
! return (this->_descriptors);
}
/**
! * Determine the components needed to cast this spell. The components
! * of a spell may vary from normal versions of the spell due to
! * metamagic feats.
! *
! * @return Array of components needed for this spell.
*/
! inline Components
! Spell::getComponents () const {
! return (this->_components);
! }
!
! /**
! * Determine the range of this spell. The range of a spell may vary
! * from normal versions of the spell due to metamagic feats.
! *
! * @return Range of this spell.
! */
! inline const Range&
! Spell::getRange () const {
! return (*(this->_range));
! }
!
! /**
! * Create a new spell. This constructor creates a spell with the given
! * values. Most spells have no descriptors so this is the default value
! * The new spell has no metamagic feats when initially created.
! */
! inline
! Spell::Spell (const School& school,
! Components components,
! const Range& range,
! Descriptors descriptors):
! _school (school.createCopy ()),
! _components (components),
! _range (range.createCopy ()),
! _descriptors (descriptors),
! _metamagicFeats () {
! // empty constructor body
! }
OGS_END_MAGIC_NAMESPACE
Index: Subschool.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Subschool.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Subschool.cpp 25 Mar 2003 06:13:13 -0000 1.2
--- Subschool.cpp 2 May 2003 19:06:32 -0000 1.3
***************
*** 1,4 ****
/*
! * Subschool.cpp -- class implementation for subschools of arcane magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * Subschool.cpp -- class implementation for arcane magic subschools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 24,45 ****
#include <stdexcept>
#include "ogs/magic/Subschool.h"
using ogs::magic::Subschool;
/**
! * Create a new subschool.
*
* @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @throw invalid_argument If type is invalid.
*/
! inline Subschool::Subschool (Type type): School (getSchool (type)) {
! if (isValid (type)) {
! this->type = type;
! } else {
std::ostringstream ostr;
! ostr << "Invalid subschool type: " << type;
throw std::invalid_argument (ostr.str ());
}
}
--- 24,106 ----
#include <stdexcept>
+ #include "ogs/magic/School.h"
#include "ogs/magic/Subschool.h"
+ using ogs::magic::School;
using ogs::magic::Subschool;
/**
! * Determine the name of this subschool.
! *
! * @return Name of this subschool (e.g., "Illusion (Glamer)")
! */
! std::string Subschool::getName () const {
! std::string s (School::getName ());
!
! switch (this->_type) {
! case CALLING:
! s += " (Calling)";
! break;
! case CREATION:
! s += " (Creation)";
! break;
! case HEALING:
! s += " (Healing)";
! break;
! case SUMMONING:
! s += " (Summoning)";
! break;
! case CHARM:
! s += " (Charm)";
! break;
! case COMPULSION:
! s += " (Compulsion)";
! break;
! case FIGMENT:
! s += " (Figment)";
! break;
! case GLAMER:
! s += " (Glamer)";
! break;
! case PATTERN:
! s += " (Pattern)";
! break;
! case PHANTASM:
! s += " (Phantasm)";
! break;
! case SHADOW:
! s += " (Shadow)";
! break;
! }
!
! return (s);
! }
!
!
! /**
! * Determine the school that a subschool belongs to.
*
* @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @return Type of school that subschool belongs to.
! * @throw std::invalid_argument If type is an invalid subschool.
*/
! School::Type Subschool::getSchool (Type type) {
! if (! isValid (type)) {
std::ostringstream ostr;
! ostr << "invalid subschool type (" << int (type) << ")";
throw std::invalid_argument (ostr.str ());
}
+
+ return (type == CALLING ||
+ type == CREATION ||
+ type == HEALING ||
+ type == SUMMONING? CONJURATION:
+ type == CHARM ||
+ type == COMPULSION? ENCHANTMENT:
+ type == FIGMENT ||
+ type == GLAMER ||
+ type == PATTERN ||
+ type == PHANTASM ||
+ type == SHADOW? ILLUSION: School::Type (0));
}
Index: Subschool.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Subschool.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Subschool.h 25 Feb 2003 19:40:27 -0000 1.3
--- Subschool.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 30,38 ****
# include <ogs/magic/Namespace.h>
# include <ogs/magic/School.h>
OGS_BEGIN_MAGIC_NAMESPACE
/**
! * A subschool of arcance magic.
*/
class Subschool: public School {
--- 30,40 ----
# include <ogs/magic/Namespace.h>
# include <ogs/magic/School.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
/**
! * A subschool of arcance magic. Each subschool belongs to exactly one
! * school. Not all schools have subschools.
*/
class Subschool: public School {
***************
*** 45,76 ****
/** The Creation subschool of the Conjuration school. */
! CREATION = 2,
/** The Healing subschool of the Conjuration school. */
! HEALING = 3,
/** The Summoning subschool of the Conjuration school. */
! SUMMONING = 4,
/** The Charm subschool of the Enchantment school. */
! CHARM = 5,
/** The Compulsion subschool of the Enchantment school. */
! COMPULSION = 6,
/** The Figment subschool of the Illusion school. */
! FIGMENT = 7,
/** The Glamer subschool of the Illusion school. */
! GLAMER = 8,
/** The Pattern subschool of the Illusion school. */
! PATTERN = 9,
/** The Phantasm subschool of the Illusion school. */
! PHANTASM = 10,
/** The Shadow subschool of the Illusion school. */
! SHADOW = 11
};
--- 47,78 ----
/** The Creation subschool of the Conjuration school. */
! CREATION,
/** The Healing subschool of the Conjuration school. */
! HEALING,
/** The Summoning subschool of the Conjuration school. */
! SUMMONING,
/** The Charm subschool of the Enchantment school. */
! CHARM,
/** The Compulsion subschool of the Enchantment school. */
! COMPULSION,
/** The Figment subschool of the Illusion school. */
! FIGMENT,
/** The Glamer subschool of the Illusion school. */
! GLAMER,
/** The Pattern subschool of the Illusion school. */
! PATTERN,
/** The Phantasm subschool of the Illusion school. */
! PHANTASM,
/** The Shadow subschool of the Illusion school. */
! SHADOW
};
***************
*** 78,116 ****
Type getType () const;
std::string getName () const;
private:
! Type type;
! static bool isValid (Type type);
static School::Type getSchool (Type type);
};
/**
* Determine type of this subschool.
*
* @return Type of subschool ((CALLING, CHARM, FIGMENT, ...).
*/
! inline Subschool::Type Subschool::getType () const {
! return (this->type);
}
/**
! * Determine school for this subschool.
*
! * @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @return School::Type or 0 if type is invalid.
*/
! inline School::Type Subschool::getSchool (Type type) {
! return (type == CALLING ||
! type == CREATION ||
! type == HEALING ||
! type == SUMMONING? School::CONJURATION:
! type == CHARM ||
! type == COMPULSION? School::ENCHANTMENT:
! type == FIGMENT ||
! type == GLAMER ||
! type == PATTERN ||
! type == PHANTASM ||
! type == SHADOW? School::ILLUSION: School::Type (0));
}
--- 80,144 ----
Type getType () const;
std::string getName () const;
+ School* createCopy () const;
private:
! Type _type;
! static bool isValid (int i);
static School::Type getSchool (Type type);
};
/**
+ * Create a new subschool.
+ *
+ * @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
+ * @throw std::invalid_argument If type is an invalid subschool.
+ */
+ inline
+ Subschool::Subschool (Type type):
+ School (getSchool (type)),
+ _type (type) {
+ // empty constructor body
+ }
+
+ /**
* Determine type of this subschool.
*
* @return Type of subschool ((CALLING, CHARM, FIGMENT, ...).
*/
! inline Subschool::Type
! Subschool::getType () const {
! return (this->_type);
}
/**
! * Create a copy of this subschool.
*
! * @return A pointer to a copy of this subschool.
*/
! inline School*
! Subschool::createCopy () const {
! return (new Subschool (*this));
! }
!
! /**
! * Determine if an integer value is a valid subschool type.
! *
! * @param i An integer value.
! * @return True if integer value is a valid subschool type.
! */
! inline bool
! Subschool::isValid (int i) {
! return (i == CALLING ||
! i == CREATION ||
! i == HEALING ||
! i == SUMMONING ||
! i == CHARM ||
! i == COMPULSION ||
! i == FIGMENT ||
! i == GLAMER ||
! i == PATTERN ||
! i == PHANTASM ||
! i == SHADOW);
}
Index: Types.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Types.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Types.h 18 Apr 2003 03:40:09 -0000 1.1
--- Types.h 2 May 2003 19:06:32 -0000 1.2
***************
*** 26,35 ****
--- 26,43 ----
# define OGS_MAGIC_TYPES_H
+ # include <list>
# include <vector>
+ # include <boost/shared_ptr.hpp>
+
# include <ogs/magic/Namespace.h>
OGS_BEGIN_MAGIC_NAMESPACE
+ class Component;
+ class MetamagicFeat;
+ class Range;
+ class School;
+
/** An unsigned integer type that represents spell level. */
typedef unsigned short SpellLevel;
***************
*** 44,47 ****
--- 52,73 ----
*/
typedef std::vector<unsigned> SpellCounts;
+
+ /** A smart pointer to a school or subshcool. */
+ typedef boost::shared_ptr<School> SchoolPtr;
+
+ /** A smart pointer that holds a spell component. */
+ typedef boost::shared_ptr<Component> ComponentPtr;
+
+ /** A list of spell components. */
+ typedef std::list<ComponentPtr> Components;
+
+ /** A smart pointer to a spell range. */
+ typedef boost::shared_ptr<Range> RangePtr;
+
+ /** A smart pointer that holds a metamagic feat. */
+ typedef boost::shared_ptr<MetamagicFeat> MetamagicFeatPtr;
+
+ /** A list of spell components. */
+ typedef std::list<MetamagicFeatPtr> MetamagicFeats;
OGS_END_MAGIC_NAMESPACE
|