ogs-changes Mailing List for Open Gaming System (Page 4)
Status: Alpha
Brought to you by:
elemings
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(35) |
Apr
(96) |
May
(22) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
|---|
|
From: <ele...@us...> - 2003-04-13 05:31:59
|
Update of /cvsroot/ogs/dist/c++/doc In directory sc8-pr-cvs1:/tmp/cvs-serv10789 Added Files: Doxyfile.in Makefile.am Log Message: See C++ ChangeLog (Apr 13) for details. --- NEW FILE: Doxyfile.in --- # Doxyfile 1.2.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. [...972 lines suppressed...] # documentation, with file:// prepended to it, will be used. DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. BIN_ABSPATH = /usr/local/bin/ # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. EXT_DOC_PATHS = --- NEW FILE: Makefile.am --- ## ## Makefile.am -- Automake file for Open Gaming System (OGS) ## 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: Makefile.am,v 1.1 2003/04/13 05:31:56 elemings Exp $ ## EXTRA_DIST = \ Doxyfile.in \ stylesheet.css docdir = $(top_builddir)/doc if HAVE_DOXYGEN doc: Doxyfile rm -rf $(docdir)/html $(docdir)/latex $(DOXYGEN) else doc: @echo "Doxygen (www.doxygen.org) is required to build documantation." endif .PHONY: doc |
|
From: <ele...@us...> - 2003-04-13 05:31:17
|
Update of /cvsroot/ogs/dist/c++/test
In directory sc8-pr-cvs1:/tmp/cvs-serv10658
Modified Files:
AbilitiesTest.cpp CombatTest01.cpp ModifiersTest.cpp
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: AbilitiesTest.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/test/AbilitiesTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AbilitiesTest.cpp 8 Apr 2003 21:43:15 -0000 1.1
--- AbilitiesTest.cpp 13 Apr 2003 05:31:13 -0000 1.2
***************
*** 199,204 ****
Abilities::PartialMethod::Value cha (Ability::CHA, 15);
Abilities::PartialMethod::Value values [] = { dex, intl, wis, cha };
! /*
! Abilities::PartialMethod partialMethod (& values [0], & values [3]);
Abilities wraithAbilities (partialMethod);
--- 199,203 ----
Abilities::PartialMethod::Value cha (Ability::CHA, 15);
Abilities::PartialMethod::Value values [] = { dex, intl, wis, cha };
! Abilities::PartialMethod partialMethod (& values [0], & values [4]);
Abilities wraithAbilities (partialMethod);
***************
*** 213,217 ****
assert (wraithAbilities [Ability::CHA]);
assert (wraithAbilities [Ability::CHA]->getCurrentScore () == 15);
! */
cout << endl;
}
--- 212,228 ----
assert (wraithAbilities [Ability::CHA]);
assert (wraithAbilities [Ability::CHA]->getCurrentScore () == 15);
!
! Abilities abilitiesCopy (wraithAbilities);
! assert (! abilitiesCopy [Ability::STR]);
! assert (abilitiesCopy [Ability::DEX]);
! assert (abilitiesCopy [Ability::DEX]->getCurrentScore () == 16);
! assert (! abilitiesCopy [Ability::CON]);
! assert (abilitiesCopy [Ability::INT]);
! assert (abilitiesCopy [Ability::INT]->getCurrentScore () == 14);
! assert (abilitiesCopy [Ability::WIS]);
! assert (abilitiesCopy [Ability::WIS]->getCurrentScore () == 14);
! assert (abilitiesCopy [Ability::CHA]);
! assert (abilitiesCopy [Ability::CHA]->getCurrentScore () == 15);
!
cout << endl;
}
Index: CombatTest01.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/test/CombatTest01.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CombatTest01.cpp 29 Mar 2003 02:31:34 -0000 1.3
--- CombatTest01.cpp 13 Apr 2003 05:31:14 -0000 1.4
***************
*** 31,35 ****
#include <ogs/creatures/humanoids/Human.h>
#include <ogs/cclasses/Fighter.h>
! //#include <ogs/items/Dagger.h>
#include <ogs/core/Character.h>
--- 31,35 ----
#include <ogs/creatures/humanoids/Human.h>
#include <ogs/cclasses/Fighter.h>
! //#include <ogs/items/weapons/Dagger.h>
#include <ogs/core/Character.h>
***************
*** 137,142 ****
*/
void revive (Creature& c1, Creature& c2) {
! c1.setCurrentHealth (c1.getMaximumHealth ());
! c2.setCurrentHealth (c2.getMaximumHealth ());
}
--- 137,147 ----
*/
void revive (Creature& c1, Creature& c2) {
! Entity::Health health = c1.getHealth ();
! health.first = health.second;
! c1.setHealth (health);
!
! health = c2.getHealth ();
! health.first = health.second;
! c2.setHealth (health);
}
Index: ModifiersTest.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/test/ModifiersTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ModifiersTest.cpp 8 Apr 2003 21:43:18 -0000 1.1
--- ModifiersTest.cpp 13 Apr 2003 05:31:14 -0000 1.2
***************
*** 166,169 ****
--- 166,173 ----
}
+ void testDefense () {
+ // TODO: Add some Defense tests.
+ }
+
/**
* Run various tests on modifiers.
***************
*** 176,179 ****
--- 180,184 ----
testModifier ();
testModifiers ();
+ testDefense ();
cout << "END: " TEST_DRIVER "\n";
|
|
From: <ele...@us...> - 2003-04-13 05:28:49
|
Update of /cvsroot/ogs/dist/c++/ogs/support
In directory sc8-pr-cvs1:/tmp/cvs-serv9867/support
Modified Files:
Makefile.am Observer.h
Added Files:
Utility.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
--- NEW FILE: Utility.h ---
/*
* Utility.h -- class interface for utilities
* 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: Utility.h,v 1.1 2003/04/13 05:28:46 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SUPPORT_UTILITY_H
# define OGS_SUPPORT_UTILITY_H
# include <ogs/support/Namespace.h>
OGS_BEGIN_SUPPORT_NAMESPACE
/**
* A function object that destroys allocated memory. A Destroy object
* destroys allocated memory by calling the delete operator on pointers.
* These objects can be used conveniently with standard containers and
* algorithms.
*/
struct Destroy {
template <typename T>
void operator() (const T* t) const;
};
/**
* Destroy allocated memory. The allocated memory is destroyed by
* calling the delete operator on a pointer of type T. The type T is
* specified by the template parameter.
*
* @param t A pointer to allocated memory of type T.
*/
template <typename T>
void Destroy::operator() (const T* t) const {
delete t;
}
OGS_END_SUPPORT_NAMESPACE
# endif /* !defined OGS_SUPPORT_UTILITY_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile.am 29 Mar 2003 02:10:40 -0000 1.4
--- Makefile.am 13 Apr 2003 05:28:46 -0000 1.5
***************
*** 29,33 ****
Namespace.h \
Object.h \
! Observer.h
INCLUDES = \
--- 29,34 ----
Namespace.h \
Object.h \
! Observer.h \
! Utility.h
INCLUDES = \
Index: Observer.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Observer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Observer.h 7 Jan 2003 07:41:34 -0000 1.1
--- Observer.h 13 Apr 2003 05:28:46 -0000 1.2
***************
*** 31,34 ****
--- 31,35 ----
class Event;
+ //class Object;
/**
***************
*** 41,45 ****
--- 42,56 ----
public:
virtual ~Observer () { }
+
+ protected:
+ /**
+ * Handle an event. Observers must implement this function. No
+ * default event handler is provided by the Observer class.
+ *
+ * @param event An event from an observed object.
+ */
virtual void handleEvent (Event& event) = 0;
+
+ friend void Object::notifyObservers (Event& event);
};
|
|
From: <ele...@us...> - 2003-04-13 05:28:49
|
Update of /cvsroot/ogs/dist/c++/ogs/spells/conjurations
In directory sc8-pr-cvs1:/tmp/cvs-serv9867/spells/conjurations
Modified Files:
CureWounds.cpp CureWounds.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: CureWounds.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/conjurations/CureWounds.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CureWounds.cpp 25 Mar 2003 06:13:14 -0000 1.2
--- CureWounds.cpp 13 Apr 2003 05:28:46 -0000 1.3
***************
*** 105,114 ****
if (!checkTargetWillSave () &&
!checkTargetSpellResistance ()) {
! int currentHealth = _target->getCurrentHealth ();
! _target->setCurrentHealth (currentHealth - hitPoints);
}
} else {
! int currentHealth = _target->getCurrentHealth ();
! _target->setCurrentHealth (currentHealth + hitPoints);
}
}
--- 105,116 ----
if (!checkTargetWillSave () &&
!checkTargetSpellResistance ()) {
! Entity::Health health = _target->getHealth ();
! health.first -= hitPoints;
! _target->setHealth (health);
}
} else {
! Entity::Health health = _target->getHealth ();
! health.first += hitPoints;
! _target->setHealth (health);
}
}
Index: CureWounds.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/conjurations/CureWounds.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CureWounds.h 23 Mar 2003 22:14:36 -0000 1.1
--- CureWounds.h 13 Apr 2003 05:28:46 -0000 1.2
***************
*** 48,52 ****
public:
/** Level of caster. */
! typedef ogs::core::Experience::Level CasterLevel;
/** Target of cure wounds spell. */
--- 48,52 ----
public:
/** Level of caster. */
! typedef ogs::core::XP::Level CasterLevel;
/** Target of cure wounds spell. */
|
|
From: <ele...@us...> - 2003-04-13 05:28:49
|
Update of /cvsroot/ogs/dist/c++/ogs In directory sc8-pr-cvs1:/tmp/cvs-serv9867 Modified Files: Core.h Magic.h Makefile.am Skills.h Removed Files: Doxyfile.in Log Message: See C++ ChangeLog (Apr 13) for details. Index: Core.h =================================================================== RCS file: /cvsroot/ogs/dist/c++/ogs/Core.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Core.h 25 Mar 2003 06:13:10 -0000 1.3 --- Core.h 13 Apr 2003 05:28:46 -0000 1.4 *************** *** 40,48 **** # include <ogs/core/Modifier.h> # include <ogs/core/Modifiers.h> - # include <ogs/core/Namespace.h> # include <ogs/core/Saves.h> # include <ogs/core/Size.h> # include <ogs/core/Skill.h> ! # include <ogs/core/Task.h> #endif /* !defined OGS_CORE_H */ --- 40,47 ---- # include <ogs/core/Modifier.h> # include <ogs/core/Modifiers.h> # include <ogs/core/Saves.h> # include <ogs/core/Size.h> # include <ogs/core/Skill.h> ! # include <ogs/core/Types.h> #endif /* !defined OGS_CORE_H */ Index: Magic.h =================================================================== RCS file: /cvsroot/ogs/dist/c++/ogs/Magic.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Magic.h 25 Mar 2003 06:13:10 -0000 1.5 --- Magic.h 13 Apr 2003 05:28:46 -0000 1.6 *************** *** 32,36 **** # include <ogs/magic/Feats.h> # include <ogs/magic/LevelRange.h> - # include <ogs/magic/Namespace.h> # include <ogs/magic/PhysicalComponent.h> # include <ogs/magic/Range.h> --- 32,35 ---- Index: Makefile.am =================================================================== RCS file: /cvsroot/ogs/dist/c++/ogs/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile.am 4 Apr 2003 20:22:41 -0000 1.9 --- Makefile.am 13 Apr 2003 05:28:46 -0000 1.10 *************** *** 33,38 **** spells - EXTRA_DIST = Doxyfile.in - pkgincludedir = $(includedir)/ogs --- 33,36 ---- *************** *** 81,96 **** skills/libogs-skills.la \ spells/libogs-spells.la - - docdir = $(top_builddir)/doc - - if HAVE_DOXYGEN - doc: Doxyfile - rm -rf $(docdir)/html $(docdir)/latex - $(DOXYGEN) - else - doc: - @echo "Doxygen (www.doxygen.org) is required to build documantation." - endif - - .PHONY: doc --- 79,81 ---- Index: Skills.h =================================================================== RCS file: /cvsroot/ogs/dist/c++/ogs/Skills.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Skills.h 25 Mar 2003 06:13:10 -0000 1.2 --- Skills.h 13 Apr 2003 05:28:46 -0000 1.3 *************** *** 41,45 **** //# include <ogs/skills/Listen.h> //# include <ogs/skills/MoveSilently.h> - //# include <ogs/skills/Namespace.h> //# include <ogs/skills/Profession.h> //# include <ogs/skills/Ride.h> --- 41,44 ---- --- Doxyfile.in DELETED --- |
|
From: <ele...@us...> - 2003-04-13 05:27:53
|
Update of /cvsroot/ogs/dist/c++/ogs/magic
In directory sc8-pr-cvs1:/tmp/cvs-serv9596
Modified Files:
Ability.cpp ExperienceCost.h LevelRange.cpp LevelRange.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Ability.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Ability.cpp 8 Apr 2003 21:43:10 -0000 1.4
--- Ability.cpp 13 Apr 2003 05:27:50 -0000 1.5
***************
*** 29,33 ****
* Determine bonus spells for an ability score.
*
! * @param score An ability score.
* @return Number of bonus spells per spell level.
*/
--- 29,33 ----
* Determine bonus spells for an ability score.
*
! * @param modifier The value of an ability score modifier.
* @return Number of bonus spells per spell level.
*/
Index: ExperienceCost.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/ExperienceCost.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ExperienceCost.h 28 Feb 2003 11:11:25 -0000 1.2
--- ExperienceCost.h 13 Apr 2003 05:27:50 -0000 1.3
***************
*** 32,37 ****
OGS_BEGIN_MAGIC_NAMESPACE
- using ogs::core::Experience;
-
/**
* A spell component that costs experience points to cast. A spell
--- 32,35 ----
***************
*** 41,51 ****
class ExperienceCost: public Component {
public:
! ExperienceCost (Experience::Points xpCost);
! Experience::Points getCost () const;
private:
! Experience::Points _xpCost;
};
/**
* Create an experience cost component.
--- 39,52 ----
class ExperienceCost: public Component {
public:
! ExperienceCost (XP::Points xpCost);
! XP::Points getCost () const;
private:
! XP::Points _xpCost;
};
+ /** A shorter name to use for experience cost. */
+ typedef ExperienceCost XPCost;
+
/**
* Create an experience cost component.
***************
*** 53,57 ****
* @param xpCost Cost of casting spell in experience points.
*/
! inline ExperienceCost::ExperienceCost (Experience::Points xpCost):
Component (Component::EXPERIENCE_COST) {
this->_xpCost = xpCost;
--- 54,58 ----
* @param xpCost Cost of casting spell in experience points.
*/
! inline ExperienceCost::ExperienceCost (XP::Points xpCost):
Component (Component::EXPERIENCE_COST) {
this->_xpCost = xpCost;
***************
*** 63,67 ****
* @return Cost in experience points.
*/
! inline Experience::Points ExperienceCost::getCost () const {
return (this->_xpCost);
}
--- 64,68 ----
* @return Cost in experience points.
*/
! inline XP::Points ExperienceCost::getCost () const {
return (this->_xpCost);
}
Index: LevelRange.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/LevelRange.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LevelRange.cpp 25 Mar 2003 06:13:13 -0000 1.2
--- LevelRange.cpp 13 Apr 2003 05:27:50 -0000 1.3
***************
*** 30,34 ****
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Close (Experience::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 25.0 + (5.0 * (casterLevel / 2));
--- 30,34 ----
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Close (XP::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 25.0 + (5.0 * (casterLevel / 2));
***************
*** 41,45 ****
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Medium (Experience::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 100.0 + (10.0 * casterLevel);
--- 41,45 ----
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Medium (XP::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 100.0 + (10.0 * casterLevel);
***************
*** 52,56 ****
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Long (Experience::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 400.0 + (40.0 * casterLevel);
--- 52,56 ----
* @param casterLevel Level of spell caster.
*/
! LevelRange LevelRange::Long (XP::Level casterLevel) {
// TODO: Change feet into locale dependent unit.
float distance = 400.0 + (40.0 * casterLevel);
***************
*** 65,69 ****
*/
LevelRange::LevelRange (Range::Type type, float distance,
! Experience::Level casterLevel):
AbsoluteRange (type, distance) {
this->casterLevel = casterLevel;
--- 65,69 ----
*/
LevelRange::LevelRange (Range::Type type, float distance,
! XP::Level casterLevel):
AbsoluteRange (type, distance) {
this->casterLevel = casterLevel;
Index: LevelRange.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/LevelRange.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LevelRange.h 25 Feb 2003 19:40:24 -0000 1.2
--- LevelRange.h 13 Apr 2003 05:27:50 -0000 1.3
***************
*** 32,36 ****
OGS_BEGIN_MAGIC_NAMESPACE
! using ogs::core::Experience;
/**
--- 32,36 ----
OGS_BEGIN_MAGIC_NAMESPACE
! using ogs::core::XP;
/**
***************
*** 44,58 ****
class LevelRange: public AbsoluteRange {
public:
! static LevelRange Close (Experience::Level casterLevel);
! static LevelRange Medium (Experience::Level casterLevel);
! static LevelRange Long (Experience::Level casterLevel);
! Experience::Level getCasterLevel () const;
private:
! Experience::Level casterLevel;
LevelRange (Range::Type type, float distance,
! Experience::Level casterLevel);
};
--- 44,58 ----
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);
};
***************
*** 62,66 ****
* @return Caster level.
*/
! inline Experience::Level LevelRange::getCasterLevel () const {
return (this->casterLevel);
}
--- 62,66 ----
* @return Caster level.
*/
! inline XP::Level LevelRange::getCasterLevel () const {
return (this->casterLevel);
}
|
|
From: <ele...@us...> - 2003-04-13 05:27:09
|
Update of /cvsroot/ogs/dist/c++/ogs/feats
In directory sc8-pr-cvs1:/tmp/cvs-serv9407
Modified Files:
Alertness.cpp AllWeapons.cpp ArmorProficiency.cpp
ImprovedSave.cpp
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Alertness.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/Alertness.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Alertness.cpp 29 Mar 2003 02:10:35 -0000 1.3
--- Alertness.cpp 13 Apr 2003 05:27:06 -0000 1.4
***************
*** 22,30 ****
#include "ogs/core/Creature.h"
#include "ogs/feats/Alertness.h"
! #include "ogs/skills/Listen.h"
! #include "ogs/skills/Spot.h"
- using ogs::core::Creature;
using ogs::feats::Alertness;
--- 22,29 ----
#include "ogs/core/Creature.h"
+ #include "ogs/core/Types.h"
#include "ogs/feats/Alertness.h"
! #include "ogs/skills/CommonSkills.h"
using ogs::feats::Alertness;
***************
*** 73,93 ****
*/
void Alertness::addSkillModifier (Object& object) {
Creature* creature = dynamic_cast<Creature*> (&object);
if (creature != NULL) {
! Creature::Skills skills = creature->getSkills ();
! Creature::Skills::iterator itor = skills.begin ();
while (itor != skills.end ()) {
using ogs::core::Modifiers;
! using ogs::skills::Listen;
! Listen* listenSkill = dynamic_cast<Listen*> (*itor++);
! if (listenSkill != NULL) {
! Modifiers& modifiers = listenSkill->getModifiers ();
modifiers.addModifier (this->_modifier);
} else {
! using ogs::skills::Spot;
! Spot* spotSkill = dynamic_cast<Spot*> (*itor);
! if (spotSkill != NULL) {
! Modifiers& modifiers = spotSkill->getModifiers ();
modifiers.addModifier (this->_modifier);
}
--- 72,95 ----
*/
void Alertness::addSkillModifier (Object& object) {
+ using ogs::core::Creature;
Creature* creature = dynamic_cast<Creature*> (&object);
+
if (creature != NULL) {
! using ogs::core::Skills;
! Skills skills = creature->getSkills ();
! Skills::iterator itor = skills.begin ();
while (itor != skills.end ()) {
+ using ogs::core::SkillPtr;
using ogs::core::Modifiers;
! using ogs::skills::CommonSkills;
! SkillPtr skillPtr = *itor++;
!
! if (skillPtr->getType () == CommonSkills::LISTEN) {
! Modifiers& modifiers = skillPtr->getModifiers ();
modifiers.addModifier (this->_modifier);
} else {
! if (skillPtr->getType () == CommonSkills::SPOT) {
! Modifiers& modifiers = skillPtr->getModifiers ();
modifiers.addModifier (this->_modifier);
}
Index: AllWeapons.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/AllWeapons.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AllWeapons.cpp 4 Apr 2003 20:22:45 -0000 1.2
--- AllWeapons.cpp 13 Apr 2003 05:27:06 -0000 1.3
***************
*** 25,29 ****
#include "ogs/items/Weapon.h"
- using ogs::core::Creature;
using ogs::feats::AllWeapons;
using ogs::items::Weapon;
--- 25,28 ----
***************
*** 53,64 ****
}
const Creature& creature = dynamic_cast<const Creature&> (object);
! Creature::Feats feats = creature.getFeats ();
! Creature::Feats::iterator itor = feats.begin ();
while (itor != feats.end ()) {
! using ogs::core::Feat;
! Feat* feat = *itor++;
! AllWeapons* allWeapons = dynamic_cast <AllWeapons*> (feat);
if (allWeapons != NULL) {
if (allWeapons->getProficiency () == _proficiency) {
--- 52,65 ----
}
+ using ogs::core::Creature;
const Creature& creature = dynamic_cast<const Creature&> (object);
! using ogs::core::Feats;
! Feats feats = creature.getFeats ();
! Feats::iterator itor = feats.begin ();
while (itor != feats.end ()) {
! using ogs::core::FeatPtr;
! FeatPtr featPtr = *itor++;
! AllWeapons* allWeapons = dynamic_cast <AllWeapons*> (featPtr.get ());
if (allWeapons != NULL) {
if (allWeapons->getProficiency () == _proficiency) {
Index: ArmorProficiency.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/ArmorProficiency.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ArmorProficiency.cpp 4 Apr 2003 20:22:46 -0000 1.6
--- ArmorProficiency.cpp 13 Apr 2003 05:27:06 -0000 1.7
***************
*** 110,122 ****
findArmorProficiency (const Creature& creature,
Armor::Proficiency proficiency) {
! Creature::Feats feats = creature.getFeats ();
! Creature::Feats::iterator itor = feats.begin ();
bool found = false;
while (!found && itor != feats.end ()) {
! using ogs::core::Feat;
! Feat* feat = *itor++;
ArmorProficiency* armorProficiency =
! dynamic_cast <ArmorProficiency*> (feat);
if (armorProficiency != NULL) {
--- 110,123 ----
findArmorProficiency (const Creature& creature,
Armor::Proficiency proficiency) {
! using ogs::core::Feats;
! Feats feats = creature.getFeats ();
! Feats::iterator itor = feats.begin ();
bool found = false;
while (!found && itor != feats.end ()) {
! using ogs::core::FeatPtr;
! FeatPtr featPtr = *itor++;
ArmorProficiency* armorProficiency =
! dynamic_cast <ArmorProficiency*> (featPtr.get ());
if (armorProficiency != NULL) {
Index: ImprovedSave.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/ImprovedSave.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ImprovedSave.cpp 4 Apr 2003 20:22:46 -0000 1.3
--- ImprovedSave.cpp 13 Apr 2003 05:27:06 -0000 1.4
***************
*** 76,88 ****
const Creature& creature = dynamic_cast<const Creature&> (object);
! Creature::Feats feats = creature.getFeats ();
! Creature::Feats::iterator itor = feats.begin ();
while (itor != feats.end ()) {
! using ogs::core::Feat;
! Feat* feat = *itor++;
! ImprovedSave* improvedSave = dynamic_cast <ImprovedSave*> (feat);
if (improvedSave != NULL) {
! if (improvedSave->getType () == _type) {
return (false);
}
--- 76,91 ----
const Creature& creature = dynamic_cast<const Creature&> (object);
! using ogs::core::Feats;
! Feats feats = creature.getFeats ();
! Feats::iterator itor = feats.begin ();
while (itor != feats.end ()) {
! using ogs::core::FeatPtr;
! FeatPtr featPtr = *itor++;
! ImprovedSave* improvedSave =
! dynamic_cast <ImprovedSave*> (featPtr.get ());
!
if (improvedSave != NULL) {
! if (improvedSave->getType () == this->_type) {
return (false);
}
|
Update of /cvsroot/ogs/dist/c++/ogs/skills
In directory sc8-pr-cvs1:/tmp/cvs-serv9203
Modified Files:
Makefile.am Spot.cpp Spot.h
Added Files:
CommonSkills.cpp CommonSkills.h SkillFactory.h
Removed Files:
Appraise.h Bluff.h Climb.h Craft.h Diplomacy.cpp Diplomacy.h
DisableDevice.h Disguise.h EscapeArtist.h Forgery.h
GatherInformation.h HandleAnimal.h Hide.h Intimidate.h Jump.h
Knowledge.h Listen.h MoveSilently.h Profession.h Ride.h
Search.h SenseMotive.h SpeakLanguage.h Swim.h Tumble.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
--- NEW FILE: CommonSkills.cpp ---
/*
* CommonSkills.cpp -- class implementation for common skills
* 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: CommonSkills.cpp,v 1.1 2003/04/13 05:26:28 elemings Exp $
*/
#include "ogs/core/Ability.h"
#include "ogs/core/Skill.h"
#include "ogs/skills/CommonSkills.h"
#include "ogs/skills/SkillFactory.h"
#include "ogs/skills/Spot.h"
using ogs::core::Ability;
using ogs::core::Skill;
using ogs::skills::CommonSkills;
using ogs::skills::SkillFactory;
using ogs::skills::Spot;
/**
* Create a new common skill of a specified type. If the skill type is
* unknown, this function will return an empty pointer.
*
* @param skillType Type of skill to create.
* @return A skill pointer or an empty pointer.
*/
SkillFactory::SkillPtr
CommonSkills::createSkill (Skill::Type skillType) {
SkillFactory::SkillPtr skillPtr;
const bool trainedOnly = false;
const bool useUntrained = true;
const bool noArmorPenalty = false;
const bool useArmorPenalty = true;
switch (skillType) {
case APPRAISE:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case BLUFF:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case CLIMB:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, useArmorPenalty));
break;
case CRAFT:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case DIPLOMACY:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case DISABLE_DEVICE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case DISGUISE:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case ESCAPE_ARTIST:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, useArmorPenalty));
break;
case FORGERY:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case GATHER_INFORMATION:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case HANDLE_ANIMAL:
skillPtr.reset (new Skill (skillType, Ability::CHA,
trainedOnly, noArmorPenalty));
break;
case HIDE:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, useArmorPenalty));
break;
case INTIMIDATE:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case JUMP:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, useArmorPenalty));
break;
case KNOWLEDGE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case LISTEN:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, noArmorPenalty));
break;
case MOVE_SILENTLY:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, useArmorPenalty));
break;
case PROFESSION:
skillPtr.reset (new Skill (skillType, Ability::WIS,
trainedOnly, noArmorPenalty));
break;
case RIDE:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, noArmorPenalty));
break;
case SEARCH:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case SENSE_MOTIVE:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, noArmorPenalty));
break;
case SPEAK_LANGUAGE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case SPOT:
skillPtr.reset (new Spot ());
break;
case SWIM:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, noArmorPenalty));
break;
case TUMBLE:
skillPtr.reset (new Skill (skillType, Ability::DEX,
trainedOnly, useArmorPenalty));
break;
default:
break;
}
return (skillPtr);
}
--- NEW FILE: CommonSkills.h ---
/*
* CommonSkills.h -- class interface for common skills
* 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: CommonSkills.h,v 1.1 2003/04/13 05:26:28 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SKILLS_COMMON_SKILLS_H
# define OGS_SKILLS_COMMON_SKILLS_H
# include <ogs/core/Skill.h>
# include <ogs/skills/Namespace.h>
# include <ogs/skills/SkillFactory.h>
OGS_BEGIN_SKILLS_NAMESPACE
/**
* A skill factory that creates common skill objects.
*/
struct CommonSkills: public SkillFactory {
/** A skill for appraising the value of rare and exotic items. */
static const ogs::core::Skill::Type APPRAISE = 3;
/** A skill for deceiving and fooling other creatures. */
static const ogs::core::Skill::Type BLUFF = 5;
/** A skill for scaling all types of vertical surfaces. */
static const ogs::core::Skill::Type CLIMB = 6;
/** A skill for creating and repairing specific types of items. */
static const ogs::core::Skill::Type CRAFT = 8;
/** A skill for relating and negotiating with foreign creatures. */
static const ogs::core::Skill::Type DIPLOMACY = 10;
/** A skill for circumventing the function of items and devices. */
static const ogs::core::Skill::Type DISABLE_DEVICE = 11;
/** A skill for altering appearances with makeup and other items. */
static const ogs::core::Skill::Type DISGUISE = 12;
/** A skill for escaping from ropes, grapples, and other bonds. */
static const ogs::core::Skill::Type ESCAPE_ARTIST = 13;
/** A skill for forging documents and other items. */
static const ogs::core::Skill::Type FORGERY = 14;
/** A skill for collecting and analyzing rumors and information. */
static const ogs::core::Skill::Type GATHER_INFORMATION = 15;
/** A skill for gaining and maintaining control of animals. */
static const ogs::core::Skill::Type HANDLE_ANIMAL = 16;
/** A skill for concealing items and creatures in plain sight. */
static const ogs::core::Skill::Type HIDE = 18;
/** A skill for threatening and interrogating other creatures. */
static const ogs::core::Skill::Type INTIMIDATE = 20;
/** A skill for jumping over objects and across distances. */
static const ogs::core::Skill::Type JUMP = 22;
/** A skill for testing knowledge on a particular subject. */
static const ogs::core::Skill::Type KNOWLEDGE = 23;
/** A skill for hearing faint sounds. */
static const ogs::core::Skill::Type LISTEN = 27;
/** A skill for moving without making a noise. */
static const ogs::core::Skill::Type MOVE_SILENTLY = 28;
/** A skill for checking within a particular profession. */
static const ogs::core::Skill::Type PROFESSION = 32;
/** A skill that determines riding ability. */
static const ogs::core::Skill::Type RIDE = 34;
/** A skill for physically locating hidden or concealed objects. */
static const ogs::core::Skill::Type SEARCH = 36;
/** A skill for detecting real intent and hidden agenda. */
static const ogs::core::Skill::Type SENSE_MOTIVE = 37;
/** A skill for communicating orally with a specific language. */
static const ogs::core::Skill::Type SPEAK_LANGUAGE = 38;
/** A skill for visually locating hidden or concealed objects. */
static const ogs::core::Skill::Type SPOT = 40;
/* A skill for moving through varying currents of water. */
static const ogs::core::Skill::Type SWIM = 41;
/** A skill for maneuvering and recovering from falls. */
static const ogs::core::Skill::Type TUMBLE = 42;
SkillPtr createSkill (ogs::core::Skill::Type skillType);
};
OGS_END_SKILLS_NAMESPACE
# endif /* !defined OGS_SKILLS_COMMON_SKILLS_H */
#endif /* defined __cplusplus */
--- NEW FILE: SkillFactory.h ---
/*
* SkillFactory.h -- class interface for skill factory
* 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: SkillFactory.h,v 1.1 2003/04/13 05:26:29 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SKILLS_SKILL_FACTORY_H
# define OGS_SKILLS_SKILL_FACTORY_H
# include <boost/shared_ptr.hpp>
# include <ogs/core/Skill.h>
# include <ogs/skills/Namespace.h>
OGS_BEGIN_SKILLS_NAMESPACE
/**
* An object that creates skill objects.
*/
struct SkillFactory {
/** A smart pointer for a skill object. */
typedef boost::shared_ptr<ogs::core::Skill> SkillPtr;
/**
* Create a new skill of a specified type.
*
* @param skillType Type of skill to create.
* @return A new skill of the specified type.
*/
virtual SkillPtr createSkill (ogs::core::Skill::Type skillType) = 0;
};
OGS_END_SKILLS_NAMESPACE
# endif /* !defined OGS_SKILLS_SKILL_FACTORY_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Makefile.am 4 Mar 2003 03:24:42 -0000 1.2
--- Makefile.am 13 Apr 2003 05:26:28 -0000 1.3
***************
*** 24,53 ****
pkginclude_HEADERS = \
! Appraise.h \
! Bluff.h \
! Climb.h \
! Craft.h \
! Diplomacy.h \
! DisableDevice.h \
! Disguise.h \
! EscapeArtist.h \
! Forgery.h \
! GatherInformation.h \
! HandleAnimal.h \
! Hide.h \
! Intimidate.h \
! Jump.h \
! Knowledge.h \
! Listen.h \
! MoveSilently.h \
Namespace.h \
! Profession.h \
! Ride.h \
! Search.h \
! SenseMotive.h \
! SpeakLanguage.h \
! Spot.h \
! Swim.h \
! Tumble.h
INCLUDES = \
--- 24,31 ----
pkginclude_HEADERS = \
! CommonSkills.h \
Namespace.h \
! SkillFactory.h \
! Spot.h
INCLUDES = \
***************
*** 60,64 ****
libogs_skills_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_skills_la_SOURCES = \
! Diplomacy.cpp \
Spot.cpp
--- 38,42 ----
libogs_skills_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_skills_la_SOURCES = \
! CommonSkills.cpp \
Spot.cpp
Index: Spot.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Spot.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Spot.cpp 25 Mar 2003 06:13:14 -0000 1.2
--- Spot.cpp 13 Apr 2003 05:26:29 -0000 1.3
***************
*** 21,42 ****
*/
#include "ogs/core/Modifier.h"
#include "ogs/skills/Spot.h"
using ogs::core::Modifier;
using ogs::skills::Spot;
! Modifier Spot::distractedModifier (-5);
/**
! * Create a new Spot skill.
*
! * @param distance Distance of the target from the spotter (default less
! * than 10 feet).
! * @param distracted True if the spotter is distracted (default false).
*/
! Spot::Spot (float distance, bool distracted) {
! this->distance = distance;
! this->distracted = distracted;
}
--- 21,54 ----
*/
+ #include <algorithm>
+
+ #include "ogs/core/Ability.h"
#include "ogs/core/Modifier.h"
+ #include "ogs/core/Modifiers.h"
+ #include "ogs/skills/CommonSkills.h"
#include "ogs/skills/Spot.h"
+ using ogs::core::Ability;
using ogs::core::Modifier;
+ using ogs::core::Modifiers;
+ using ogs::skills::CommonSkills;
using ogs::skills::Spot;
! Modifier Spot::_distractedModifier (-5);
/**
! * Create a new Spot skill. The default distance of a new Spot skill is
! * 10 feet or less. The user of the new Spot skill is not distracted by
! * default.
*
! * @param distance Distance of the target from the spotter.
! * @param distracted True if the spotter is distracted.
*/
! Spot::Spot (float distance, bool distracted):
! Skill (CommonSkills::SPOT, Ability::WIS, true, false),
! _distance (distance),
! _distanceModifier (),
! _distracted (distracted) {
! (this->getModifiers ()).addModifier (this->_distanceModifier);
}
***************
*** 49,61 ****
*/
void Spot::setDistance (float distance) {
if (distance >= 10.0) {
// TODO: Make the 10 feet increment locale dependent.
! this->distanceModifier.setValue (int (distance / 10.0));
! // TODO: Add modifier to skill check if not already added.
} else {
! // TODO: Remove modifier from skill check if already added.
}
-
- this->distance = distance;
}
--- 61,72 ----
*/
void Spot::setDistance (float distance) {
+ this->_distance = distance;
+
if (distance >= 10.0) {
// TODO: Make the 10 feet increment locale dependent.
! this->_distanceModifier.setValue (- (int (distance / 10.0)));
} else {
! this->_distanceModifier.setValue (0);
}
}
***************
*** 70,81 ****
void Spot::setDistracted (bool distracted) {
// Do nothing unless distracted is changed.
! if ((!this->distracted) && distracted) {
// Changing from not distracted to distracted.
! // TODO: Add distractedModifier to skill check.
! this->distracted = distracted;
! } else if (this->distracted && (!distracted)) {
// Changing from distracted to not distracted.
! // TODO: Remove distractedModifier to skill check.
! this->distracted = distracted;
}
}
--- 81,92 ----
void Spot::setDistracted (bool distracted) {
// Do nothing unless distracted is changed.
! if ((!this->_distracted) && distracted) {
// Changing from not distracted to distracted.
! this->_distracted = distracted;
! (this->getModifiers ()).addModifier (this->_distractedModifier);
! } else if (this->_distracted && (!distracted)) {
// Changing from distracted to not distracted.
! this->_distracted = distracted;
! (this->getModifiers ()).removeModifier (this->_distractedModifier);
}
}
Index: Spot.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Spot.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Spot.h 29 Mar 2003 02:10:39 -0000 1.3
--- Spot.h 13 Apr 2003 05:26:29 -0000 1.4
***************
*** 28,32 ****
# include <ogs/core/Modifier.h>
# include <ogs/core/Skill.h>
! # include <ogs/core/Ability.h>
# include <ogs/skills/Namespace.h>
--- 28,32 ----
# include <ogs/core/Modifier.h>
# include <ogs/core/Skill.h>
! # include <ogs/skills/CommonSkills.h>
# include <ogs/skills/Namespace.h>
***************
*** 38,45 ****
class Spot: public ogs::core::Skill {
public:
- ogs::core::Ability::Type getKeyAbility () const;
- bool useUntrained () const;
- bool useArmorCheckPenalty () const;
-
Spot (float distance = 0.0, bool distracted = false);
--- 38,41 ----
***************
*** 50,88 ****
private:
! float distance;
! ogs::core::Modifier distanceModifier;
! bool distracted;
! static ogs::core::Modifier distractedModifier;
};
/**
- * The key ability of the Spot skill is Wisdom.
- *
- * @return Wisdom
- */
- inline ogs::core::Ability::Type
- Spot::getKeyAbility () const {
- return (ogs::core::Ability::WIS);
- }
-
- /**
- * The Spot skill can be used untrained.
- *
- * @return True.
- */
- inline bool Spot::useUntrained () const {
- return (true);
- }
-
- /**
- * The Spot skill does not use armor check penalties.
- *
- * @return False
- */
- inline bool Spot::useArmorCheckPenalty () const {
- return (false);
- }
-
- /**
* Determine the distance of the target from the spotter.
*
--- 46,56 ----
private:
! float _distance;
! ogs::core::Modifier _distanceModifier;
! bool _distracted;
! static ogs::core::Modifier _distractedModifier;
};
/**
* Determine the distance of the target from the spotter.
*
***************
*** 90,94 ****
*/
inline float Spot::getDistance () const {
! return (this->distance);
}
--- 58,62 ----
*/
inline float Spot::getDistance () const {
! return (this->_distance);
}
***************
*** 99,103 ****
*/
inline bool Spot::isDistracted () const {
! return (this->distracted);
}
--- 67,71 ----
*/
inline bool Spot::isDistracted () const {
! return (this->_distracted);
}
--- Appraise.h DELETED ---
--- Bluff.h DELETED ---
--- Climb.h DELETED ---
--- Craft.h DELETED ---
--- Diplomacy.cpp DELETED ---
--- Diplomacy.h DELETED ---
--- DisableDevice.h DELETED ---
--- Disguise.h DELETED ---
--- EscapeArtist.h DELETED ---
--- Forgery.h DELETED ---
--- GatherInformation.h DELETED ---
--- HandleAnimal.h DELETED ---
--- Hide.h DELETED ---
--- Intimidate.h DELETED ---
--- Jump.h DELETED ---
--- Knowledge.h DELETED ---
--- Listen.h DELETED ---
--- MoveSilently.h DELETED ---
--- Profession.h DELETED ---
--- Ride.h DELETED ---
--- Search.h DELETED ---
--- SenseMotive.h DELETED ---
--- SpeakLanguage.h DELETED ---
--- Swim.h DELETED ---
--- Tumble.h DELETED ---
|
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] |
|
From: <ele...@us...> - 2003-04-13 05:25:56
|
Update of /cvsroot/ogs/dist/c++/ogs/core/details
In directory sc8-pr-cvs1:/tmp/cvs-serv8930/details
Modified Files:
Gender.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Gender.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/details/Gender.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Gender.h 5 Feb 2003 06:01:28 -0000 1.1
--- Gender.h 13 Apr 2003 05:25:51 -0000 1.2
***************
*** 74,78 ****
* @return MALE, FEMALE, NONE, BOTH, or UNKNOWN.
*/
! inline Gender::Value Gender::getValue () const {
return (this->_value);
}
--- 74,79 ----
* @return MALE, FEMALE, NONE, BOTH, or UNKNOWN.
*/
! inline Gender::Value
! Gender::getValue () const {
return (this->_value);
}
***************
*** 84,88 ****
* @return True if the integer value is a valid gender value.
*/
! bool Gender::isValid (int i) {
return (i == UNKNOWN || i == MALE || i == FEMALE ||
i == ASEXUAL || i == BISEXUAL);
--- 85,90 ----
* @return True if the integer value is a valid gender value.
*/
! inline bool
! Gender::isValid (int i) {
return (i == UNKNOWN || i == MALE || i == FEMALE ||
i == ASEXUAL || i == BISEXUAL);
|
|
From: <ele...@us...> - 2003-04-13 05:25:26
|
Update of /cvsroot/ogs/dist/c++/ogs/creatures
In directory sc8-pr-cvs1:/tmp/cvs-serv8841
Modified Files:
Humanoid.cpp Humanoid.h Undead.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Humanoid.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Humanoid.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Humanoid.cpp 29 Mar 2003 02:10:34 -0000 1.4
--- Humanoid.cpp 13 Apr 2003 05:25:20 -0000 1.5
***************
*** 21,28 ****
*/
#include "ogs/creatures/Humanoid.h"
- using ogs::core::Creature;
using ogs::core::BodyPart;
using ogs::creatures::Humanoid;
--- 21,30 ----
*/
+ #include "ogs/core/BodyPart.h"
+ #include "ogs/core/Creature.h"
#include "ogs/creatures/Humanoid.h"
using ogs::core::BodyPart;
+ using ogs::core::Creature;
using ogs::creatures::Humanoid;
***************
*** 33,37 ****
* create humanoid bodies.
*/
! Creature::Body Humanoid::createBody (Creature& creature) {
BodyPart::Type bodyParts [] = {
BodyPart::HEAD, BodyPart::LEFT_EYE, BodyPart::RIGHT_EYE,
--- 35,39 ----
* create humanoid bodies.
*/
! Creature::Parts Humanoid::createParts () {
BodyPart::Type bodyParts [] = {
BodyPart::HEAD, BodyPart::LEFT_EYE, BodyPart::RIGHT_EYE,
***************
*** 43,63 ****
};
! Creature::Body body;
! const int n = sizeof (bodyParts) / sizeof (BodyPart::Type);
! for (int i = 0; i < n; ++i) {
! BodyPart* part = new BodyPart (creature, bodyParts [i]);
! body.push_back (part);
! }
!
! return (body);
! }
!
! /**
! * Create a humanoid creature. This constructor makes the body of this
! * creature into a humanoid body.
! */
! Humanoid::Humanoid ():
! Creature (createBody (*this)) {
! // empty constructor body
}
--- 45,50 ----
};
! const size_t n = sizeof (bodyParts) / sizeof (BodyPart::Type);
! return (Parts (& bodyParts [0], & bodyParts [n]));
}
Index: Humanoid.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Humanoid.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Humanoid.h 29 Mar 2003 02:10:34 -0000 1.3
--- Humanoid.h 13 Apr 2003 05:25:20 -0000 1.4
***************
*** 26,30 ****
--- 26,34 ----
# define OGS_CREATURES_HUMANOID_H
+ # include <ogs/core/Abilities.h>
# include <ogs/core/Creature.h>
+ # include <ogs/core/Die.h>
+ # include <ogs/core/Size.h>
+ # include <ogs/core/Skill.h>
# include <ogs/creatures/Namespace.h>
***************
*** 32,44 ****
/**
! * A creature with qualities similar to a human.
*/
class Humanoid: public ogs::core::Creature {
public:
! static Body createBody (Creature& creature);
protected:
! Humanoid ();
};
OGS_END_CREATURES_NAMESPACE
--- 36,76 ----
/**
! * A human-like creature. Although humanoids have the same general
! * shape and traits as human beings, size and appearance can vary
! * widely.
*/
class Humanoid: public ogs::core::Creature {
public:
! /** The hit die normally used for humanoid creatures. */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d8;
!
! /** The skill rate normally used for humanoid creatures. */
! static const ogs::core::Skill::Points SKILL_RATE = 1;
!
! static Parts createParts ();
protected:
! Humanoid (ogs::core::Die hitDice,
! ogs::core::Abilities abilities,
! ogs::core::Size::Type size = ogs::core::Size::MEDIUM,
! Parts parts = createParts ());
};
+
+ /**
+ * Create a new humanoid creature. This constructor just forwards the
+ * arguments to the Creature constructor.
+ *
+ * @param hitDice Hit dice of creature.
+ * @param abilities Ability scores of creature.
+ * @param size Size of creature.
+ * @param body Body of creature.
+ */
+ inline
+ Humanoid::Humanoid (ogs::core::Die hitDice,
+ ogs::core::Abilities abilities,
+ ogs::core::Size::Type size, Parts parts):
+ Creature (hitDice, abilities, size, parts) {
+ // empty constructor body
+ }
OGS_END_CREATURES_NAMESPACE
Index: Undead.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Undead.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Undead.h 4 Apr 2003 20:22:44 -0000 1.2
--- Undead.h 13 Apr 2003 05:25:20 -0000 1.3
***************
*** 26,30 ****
--- 26,33 ----
# define OGS_CREATURES_UNDEAD_H
+ # include <ogs/core/Abilities.h>
+ # include <ogs/core/Die.h>
# include <ogs/core/Creature.h>
+ # include <ogs/core/Size.h>
# include <ogs/creatures/Namespace.h>
***************
*** 44,53 ****
class Undead: public ogs::core::Creature {
public:
protected:
!
! private:
!
};
OGS_END_CREATURES_NAMESPACE
--- 47,77 ----
class Undead: public ogs::core::Creature {
public:
+ /** The hit die normally used for undead creatures. */
+ static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d12;
protected:
! Undead (ogs::core::Die hitDice,
! ogs::core::Abilities abilities,
! ogs::core::Size::Type size = ogs::core::Size::MEDIUM,
! Parts parts = Parts ());
};
+
+ /**
+ * Create a new undead creature. This constructor just forwards the
+ * arguments to the Creature constructor.
+ *
+ * @param hitDice Hit dice of creature.
+ * @param abilities Ability scores of creature.
+ * @param size Size of creature.
+ * @param body Body of creature.
+ */
+ inline
+ Undead::Undead (ogs::core::Die hitDice,
+ ogs::core::Abilities abilities,
+ ogs::core::Size::Type size,
+ Parts parts):
+ Creature (hitDice, abilities, size, parts) {
+ // empty constructor body
+ }
OGS_END_CREATURES_NAMESPACE
|
|
From: <ele...@us...> - 2003-04-13 05:25:26
|
Update of /cvsroot/ogs/dist/c++/ogs/creatures/humanoids
In directory sc8-pr-cvs1:/tmp/cvs-serv8841/humanoids
Modified Files:
Human.cpp Human.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Human.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/humanoids/Human.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Human.cpp 29 Mar 2003 02:10:35 -0000 1.1
--- Human.cpp 13 Apr 2003 05:25:21 -0000 1.2
***************
*** 21,30 ****
*/
#include "ogs/core/Die.h"
#include "ogs/creatures/humanoids/Human.h"
using ogs::core::Die;
using ogs::creatures::humanoids::Human;
! Die Human::_maximumAge (Die::d20, 2);
--- 21,45 ----
*/
+ #include "ogs/core/Ability.h"
+ #include "ogs/core/Abilities.h"
#include "ogs/core/Die.h"
#include "ogs/creatures/humanoids/Human.h"
+ using ogs::core::Abilities;
using ogs::core::Die;
using ogs::creatures::humanoids::Human;
! const Die Human::_maximumAge (Die::d20, 2);
!
! /**
! * Create a set of abilities for this type of creature. This method
! * creates a complete et of abilities using the average method.
! *
! * @return A set of abilities for this type of creature.
! */
! Abilities Human::createAbilities () {
! using ogs::core::Ability;
! Ability::AverageMethod averageMethod;
! return (Abilities (averageMethod));
! }
Index: Human.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/humanoids/Human.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Human.h 29 Mar 2003 02:10:35 -0000 1.2
--- Human.h 13 Apr 2003 05:25:21 -0000 1.3
***************
*** 47,51 ****
public ogs::core::details::Maturity {
public:
-
Human ();
--- 47,50 ----
***************
*** 56,68 ****
const ogs::core::Die& getMaximumAge () const;
! private:
! static ogs::core::Die _maximumAge;
};
/**
! * Create a new human creature.
*/
! inline Human::Human () {
// empty constructor body
}
--- 55,70 ----
const ogs::core::Die& getMaximumAge () const;
! protected:
! static ogs::core::Abilities createAbilities ();
+ private:
+ static const ogs::core::Die _maximumAge;
};
/**
! * Create a new human.
*/
! inline Human::Human ():
! Humanoid (ogs::core::Die (HIT_DIE, 1), createAbilities ()) {
// empty constructor body
}
***************
*** 74,78 ****
* @return 15 years
*/
! inline unsigned Human::getAdultAge () const {
return (15);
}
--- 76,81 ----
* @return 15 years
*/
! inline unsigned
! Human::getAdultAge () const {
return (15);
}
***************
*** 84,88 ****
* @return 35 years
*/
! inline unsigned Human::getMiddleAge () const {
return (35);
}
--- 87,92 ----
* @return 35 years
*/
! inline unsigned
! Human::getMiddleAge () const {
return (35);
}
***************
*** 94,98 ****
* @return 53 years
*/
! inline unsigned Human::getOldAge () const {
return (53);
}
--- 98,103 ----
* @return 53 years
*/
! inline unsigned
! Human::getOldAge () const {
return (53);
}
***************
*** 104,108 ****
* @return 70 years
*/
! inline unsigned Human::getVenerableAge () const {
return (70);
}
--- 109,114 ----
* @return 70 years
*/
! inline unsigned
! Human::getVenerableAge () const {
return (70);
}
***************
*** 114,119 ****
* @return 2d20
*/
! inline const ogs::core::Die& Human::getMaximumAge () const {
! return (_maximumAge);
}
--- 120,126 ----
* @return 2d20
*/
! inline const ogs::core::Die&
! Human::getMaximumAge () const {
! return (this->_maximumAge);
}
|
|
From: <ele...@us...> - 2003-04-13 05:25:10
|
Update of /cvsroot/ogs/dist/c++/ogs/combat
In directory sc8-pr-cvs1:/tmp/cvs-serv8771
Modified Files:
Combatant.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Combatant.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/Combatant.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Combatant.h 29 Mar 2003 02:10:26 -0000 1.3
--- Combatant.h 13 Apr 2003 05:25:07 -0000 1.4
***************
*** 60,64 ****
*/
inline bool Combatant::isNormal () const {
! return (creature->getCurrentHealth () > 0);
}
--- 60,64 ----
*/
inline bool Combatant::isNormal () const {
! return ((creature->getHealth ()).first > 0);
}
|
Update of /cvsroot/ogs/dist/c++/ogs/cclasses
In directory sc8-pr-cvs1:/tmp/cvs-serv8515
Modified Files:
Barbarian.h Bard.h Cleric.h Druid.h Fighter.h Monk.h
Paladin.cpp Paladin.h Ranger.h Rogue.h Sorcerer.h Wizard.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
Index: Barbarian.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Barbarian.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Barbarian.h 4 Apr 2003 20:22:41 -0000 1.2
--- Barbarian.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 29,43 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A savage, uncivilized, warlike character class. Barbarians are
--- 29,36 ----
***************
*** 59,74 ****
*
* Barbarians are typically used in fantasy campaign settings though
! * this class can be used in other settings as well..
*/
class Barbarian: public ogs::core::CClass {
public:
! Barbarian (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
protected:
! Modifier::Value getBaseAttackValue () const;
! Modifier::Value getBaseFortSaveValue () const;
};
--- 52,75 ----
*
* Barbarians are typically used in fantasy campaign settings though
! * this class can be used in other settings as well.
*/
class Barbarian: public ogs::core::CClass {
public:
! /**
! * Hit die of barbarians. Barbarians use d12 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d12;
! /**
! * Skill rate of barbarians. Barbarians gain 4 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 4;
!
! Barbarian (ogs::core::XP::Level xpLevel = 1);
protected:
! ogs::core::Modifier::Value getBaseAttackValue () const;
! ogs::core::Modifier::Value getBaseFortSaveValue () const;
};
***************
*** 78,107 ****
* @param xpLevel Experience level of barbarian.
*/
! inline Barbarian::Barbarian (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Barbarians use d12 for their
- * hit die.
- *
- * @return Die::d12.
- */
- inline Die::Sides Barbarian::getHitDie () const {
- return (Die::d12);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Barbarians gain 4 skill points for each experience level.
- *
- * @return 4 skill points.
- */
- inline Skill::Points Barbarian::getSkillPoints () const {
- return (4);
- }
-
- /**
* Determine the value of base attack bonus for this cclass. Barbarians
* use the strong advancement rate for base attack bonuses.
--- 79,92 ----
* @param xpLevel Experience level of barbarian.
*/
! inline Barbarian::Barbarian (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getStrongAttack (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base attack bonus for this cclass. Barbarians
* use the strong advancement rate for base attack bonuses.
***************
*** 109,114 ****
* @return Value of base attack bonus.
*/
! inline Modifier::Value Barbarian::getBaseAttackValue () const {
! return (Experience::getStrongAttack (getLevel ()));
}
--- 94,100 ----
* @return Value of base attack bonus.
*/
! inline ogs::core::Modifier::Value
! Barbarian::getBaseAttackValue () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
***************
*** 120,125 ****
* @return Value of base Fortitude save bonus.
*/
! inline Modifier::Value Barbarian::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 106,112 ----
* @return Value of base Fortitude save bonus.
*/
! inline ogs::core::Modifier::Value
! Barbarian::getBaseFortSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Bard.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Bard.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Bard.h 4 Apr 2003 20:22:41 -0000 1.2
--- Bard.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A "jack-of-all-trades" character class well versed in music and lore.
--- 31,38 ----
***************
*** 65,72 ****
class Bard: public ogs::core::CClass {
public:
! Bard (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 58,73 ----
class Bard: public ogs::core::CClass {
public:
! /**
! * Hit die of bards. Bards use d6 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d6;
! /**
! * Skill rate of bards. Bards gain 4 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 4;
!
! Bard (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 75,80 ****
protected:
! Modifier::Value getBaseRefSaveValue () const;
! Modifier::Value getBaseWillSaveValue () const;
};
--- 76,81 ----
protected:
! ogs::core::Modifier::Value getBaseRefSaveValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
};
***************
*** 84,114 ****
* @param xpLevel Experience level of bard.
*/
! inline Bard::Bard (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Bards use d6 for their hit
- * die.
- *
- * @return Die::d6.
- */
- inline Die::Sides Bard::getHitDie () const {
- return (Die::d6);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Bards gain 4 skill points for each experience level.
- *
- * @return 4 skill points.
- */
- inline Skill::Points Bard::getSkillPoints () const {
- return (4);
- }
-
-
- /**
* Determine the value of base Reflex save bonus for this cclass. Bards
* use the strong advancement rate for base Reflex save bonuses.
--- 85,98 ----
* @param xpLevel Experience level of bard.
*/
! inline Bard::Bard (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base Reflex save bonus for this cclass. Bards
* use the strong advancement rate for base Reflex save bonuses.
***************
*** 116,121 ****
* @return Value of base Reflex save bonus.
*/
! inline Modifier::Value Bard::getBaseRefSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 100,106 ----
* @return Value of base Reflex save bonus.
*/
! inline ogs::core::Modifier::Value
! Bard::getBaseRefSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
***************
*** 126,149 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Bard::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
! }
!
! /**
! * Determine the number of spells that this bard can cast per day.
! *
! * @return Number of spells at each spell leve.
! */
! inline Bard::SpellCounts Bard::getSpellsPerDay () const {
! return (SpellCounts ()); // TODO: Implement.
! }
!
! /**
! * Determine the number of spells knonwn by this bard.
! *
! * @return Number of spells at each spell level.
! */
! inline Bard::SpellCounts Bard::getSpellsKnown () const {
! return (SpellCounts ()); // TODO: Implement.
}
--- 111,117 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Bard::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Cleric.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Cleric.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Cleric.h 4 Apr 2003 20:22:41 -0000 1.2
--- Cleric.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A pious character class devoted to the service of a deity. Clerics
--- 31,38 ----
***************
*** 65,72 ****
class Cleric: public ogs::core::CClass {
public:
! Cleric (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 58,73 ----
class Cleric: public ogs::core::CClass {
public:
! /**
! * Hit die of clerics. Clerics use d8 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d8;
! /**
! * Skill rate of clerics. Clerics gain 2 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 2;
!
! Cleric (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 74,79 ****
protected:
! Modifier::Value getBaseFortSaveValue () const;
! Modifier::Value getBaseWillSaveValue () const;
};
--- 75,80 ----
protected:
! ogs::core::Modifier::Value getBaseFortSaveValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
};
***************
*** 83,112 ****
* @param xpLevel Experience level of cleric.
*/
! inline Cleric::Cleric (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Clerics use d8 for their hit
- * die.
- *
- * @return Die::d8.
- */
- inline Die::Sides Cleric::getHitDie () const {
- return (Die::d8);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Clerics gain 2 skill points for each experience level.
- *
- * @return 2 skill points.
- */
- inline Skill::Points Cleric::getSkillPoints () const {
- return (2);
- }
-
- /**
* Determine the value of base Fortitude save bonus for this cclass.
* Clerics use the strong advancement rate for base Fortitude save
--- 84,97 ----
* @param xpLevel Experience level of cleric.
*/
! inline Cleric::Cleric (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base Fortitude save bonus for this cclass.
* Clerics use the strong advancement rate for base Fortitude save
***************
*** 114,119 ****
* @return Value of base Fortitude save bonus.
*/
! inline Modifier::Value Cleric::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 99,105 ----
* @return Value of base Fortitude save bonus.
*/
! inline ogs::core::Modifier::Value
! Cleric::getBaseFortSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
***************
*** 124,138 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Cleric::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
! }
!
! /**
! * Determine the number of spells that this cleric can cast per day.
! *
! * @return Number of spells at each spell leve.
! */
! inline Cleric::SpellCounts Cleric::getSpellsPerDay () const {
! return (SpellCounts ()); // TODO: Implement.
}
--- 110,116 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Cleric::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Druid.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Druid.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Druid.h 4 Apr 2003 20:22:41 -0000 1.2
--- Druid.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class that reveres nature. Druids are protectors and
--- 31,38 ----
***************
*** 67,74 ****
class Druid: public ogs::core::CClass {
public:
! Druid (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 60,75 ----
class Druid: public ogs::core::CClass {
public:
! /**
! * Hit die of druids. Druids use d8 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d8;
! /**
! * Skill rate of druids. Druids gain 4 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 4;
!
! Druid (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 76,81 ****
protected:
! Modifier::Value getBaseFortSaveValue () const;
! Modifier::Value getBaseWillSaveValue () const;
};
--- 77,82 ----
protected:
! ogs::core::Modifier::Value getBaseFortSaveValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
};
***************
*** 85,114 ****
* @param xpLevel Experience level of druid.
*/
! inline Druid::Druid (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Druids use d8 for their hit
- * die.
- *
- * @return Die::d8.
- */
- inline Die::Sides Druid::getHitDie () const {
- return (Die::d8);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Druids gain 4 skill points for each experience level.
- *
- * @return 4 skill points.
- */
- inline Skill::Points Druid::getSkillPoints () const {
- return (4);
- }
-
- /**
* Determine the value of base Fortitude save bonus for this cclass.
* Druids use the strong advancement rate for base Fortitude save
--- 86,99 ----
* @param xpLevel Experience level of druid.
*/
! inline Druid::Druid (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base Fortitude save bonus for this cclass.
* Druids use the strong advancement rate for base Fortitude save
***************
*** 117,122 ****
* @return Value of base Fortitude save bonus.
*/
! inline Modifier::Value Druid::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 102,108 ----
* @return Value of base Fortitude save bonus.
*/
! inline ogs::core::Modifier::Value
! Druid::getBaseFortSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
***************
*** 127,141 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Druid::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
! }
!
! /**
! * Determine the number of spells that this druid can cast per day.
! *
! * @return Number of spells at each spell leve.
! */
! inline Druid::SpellCounts Druid::getSpellsPerDay () const {
! return (SpellCounts ()); // TODO: Implement.
}
--- 113,119 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Druid::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Fighter.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Fighter.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Fighter.h 4 Apr 2003 20:22:41 -0000 1.7
--- Fighter.h 13 Apr 2003 05:24:49 -0000 1.8
***************
*** 30,33 ****
--- 30,34 ----
# include <ogs/core/Experience.h>
# include <ogs/core/Skill.h>
+ # include <ogs/core/Types.h>
# include <ogs/cclasses/Namespace.h>
***************
*** 37,41 ****
* A character class formally trained in weapons, armor, and tactics.
* Fighters are prototypical soldiers and mercenaries. Fighters have no
! * alignment restrictions. They may be of any alignment.
*
* At 1st-level, fighers automatically gain the Light, Medium, and Heavy
--- 38,42 ----
* A character class formally trained in weapons, armor, and tactics.
* Fighters are prototypical soldiers and mercenaries. Fighters have no
! * alignment restrictions. They may be of any alignment. <P>
*
* At 1st-level, fighers automatically gain the Light, Medium, and Heavy
***************
*** 44,48 ****
* fighters instead gain a bonus feat at 1st level and every
* even-numbered level thereafter. Fighters can also select the Weapon
! * Specialization feat at 4th-level or higher.
*
* Fighters are a universal cclass. They can be found in virtually all
--- 45,49 ----
* fighters instead gain a bonus feat at 1st level and every
* even-numbered level thereafter. Fighters can also select the Weapon
! * Specialization feat at 4th-level or higher. <P>
*
* Fighters are a universal cclass. They can be found in virtually all
***************
*** 51,64 ****
class Fighter: public ogs::core::CClass {
public:
! Fighter (ogs::core::Experience::Level xpLevel = 1);
! ogs::core::Die::Sides getHitDie () const;
! ogs::core::Skill::Points getSkillPoints () const;
! ogs::core::Modifier::Value getBaseAttack () const;
! ogs::core::Modifier::Value getBaseFortSave () const;
private:
! typedef std::vector<ogs::core::Feat*> Feats;
! Feats _bonusFeats;
};
--- 52,73 ----
class Fighter: public ogs::core::CClass {
public:
! /**
! * Hit die of fighters. Fighters use d10 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d10;
! /**
! * Skill rate of fighters. Fighters gain 2 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 2;
!
! Fighter (ogs::core::XP::Level xpLevel = 1);
private:
! ogs::core::Feats _bonusFeats;
!
! ogs::core::Modifier::Value getBaseAttack () const;
! ogs::core::Modifier::Value getBaseFortSave () const;
};
***************
*** 68,99 ****
* @param xpLevel Experience level of fighter.
*/
! inline Fighter::Fighter (ogs::core::Experience::Level xpLevel):
! ogs::core::CClass (xpLevel), _bonusFeats () {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Fighters use d10 for their
- * hit die.
- *
- * @return Die::d10.
- */
- inline ogs::core::Die::Sides
- Fighter::getHitDie () const {
- return (ogs::core::Die::d10);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Fighters gain 2 skill poitns for each experience level.
- *
- * @return 2 skill points.
- */
- inline ogs::core::Skill::Points
- Fighter::getSkillPoints () const {
- return (2);
- }
-
- /**
* Determine the value of base attack bonus for this cclass. Fighters
* use the strong advancement rate for base attack bonuses.
--- 77,91 ----
* @param xpLevel Experience level of fighter.
*/
! inline Fighter::Fighter (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getStrongAttack (xpLevel),
! ogs::core::Saves::getStrongBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)),
! _bonusFeats () {
// empty constructor body
}
/**
* Determine the value of base attack bonus for this cclass. Fighters
* use the strong advancement rate for base attack bonuses.
***************
*** 103,107 ****
inline ogs::core::Modifier::Value
Fighter::getBaseAttack () const {
! return (ogs::core::Experience::getStrongAttack (getLevel ()));
}
--- 95,99 ----
inline ogs::core::Modifier::Value
Fighter::getBaseAttack () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
Index: Monk.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Monk.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Monk.h 4 Apr 2003 20:22:42 -0000 1.2
--- Monk.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 29,43 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class dedicated to martial arts. Monks are well known
--- 29,36 ----
***************
*** 62,77 ****
class Monk: public ogs::core::CClass {
public:
! Monk (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
! Die::Sides getUnarmedDamage () const;
! Modifier& getDefenseBonus () const;
protected:
! Modifier::Value getBaseFortSaveValue () const;
! Modifier::Value getBaseRefSaveValue () const;
! Modifier::Value getBaseWillSaveValue () const;
};
--- 55,78 ----
class Monk: public ogs::core::CClass {
public:
! /**
! * Hit die of monks. Monks use d8 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d8;
! /**
! * Skill rate of monks. Monks gain 4 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 4;
! Monk (ogs::core::XP::Level xpLevel = 1);
!
! ogs::core::Die::Sides getUnarmedDamage () const;
! ogs::core::Modifier& getDefenseBonus () const;
protected:
! ogs::core::Modifier::Value getBaseFortSaveValue () const;
! ogs::core::Modifier::Value getBaseRefSaveValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
};
***************
*** 81,110 ****
* @param xpLevel Experience level of monk.
*/
! inline Monk::Monk (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Monks use d8 for their hit
- * die.
- *
- * @return Die::d8.
- */
- inline Die::Sides Monk::getHitDie () const {
- return (Die::d8);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Monks gain 4 skill points for each experience level.
- *
- * @return 4 skill points.
- */
- inline Skill::Points Monk::getSkillPoints () const {
- return (4);
- }
-
- /**
* Determine the value of base Fortitude save bonus for this cclass.
* Monks use the strong advancement rate for base Fortitude save
--- 82,95 ----
* @param xpLevel Experience level of monk.
*/
! inline Monk::Monk (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base Fortitude save bonus for this cclass.
* Monks use the strong advancement rate for base Fortitude save
***************
*** 113,118 ****
* @return Value of base Fortitude save bonus.
*/
! inline Modifier::Value Monk::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 98,104 ----
* @return Value of base Fortitude save bonus.
*/
! inline ogs::core::Modifier::Value
! Monk::getBaseFortSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
***************
*** 123,128 ****
* @return Value of base Reflex save bonus.
*/
! inline Modifier::Value Monk::getBaseRefSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 109,115 ----
* @return Value of base Reflex save bonus.
*/
! inline ogs::core::Modifier::Value
! Monk::getBaseRefSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
***************
*** 133,138 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Monk::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 120,126 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Monk::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Paladin.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Paladin.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Paladin.cpp 8 Apr 2003 21:43:05 -0000 1.4
--- Paladin.cpp 13 Apr 2003 05:24:49 -0000 1.5
***************
*** 21,60 ****
*/
#include <climits>
! #include "ogs/core/Abilities.h"
! #include "ogs/core/Ability.h"
! #include "ogs/core/Character.h"
! #include "ogs/core/Creature.h"
! #include "ogs/core/Modifier.h"
! #include "ogs/core/Saves.h"
#include "ogs/cclasses/Paladin.h"
#include "ogs/feats/ArmorProficiency.h"
! using ogs::core::Abilities;
! using ogs::core::Ability;
! using ogs::core::AbilityPtr;
! using ogs::core::Character;
! using ogs::core::Creature;
! using ogs::core::Modifier;
! using ogs::core::Saves;
using ogs::cclasses::Paladin;
using ogs::feats::ArmorProficiency;
- static void
- addDivineGrace (Character& character);
- static void
- removeDivineGrace (Character& character);
-
/**
* Create a new Paladin cclass.
*/
! Paladin::Paladin (Experience::Level xpLevel):
! CClass (xpLevel), _feats () {
// empty constructor body
}
/**
! * Attach this Paladin cclass to a character.
*/
bool Paladin::attachObject (Object& object) {
--- 21,58 ----
*/
+ #include <algorithm>
#include <climits>
+ #include <list>
! #include "ogs/Core.h"
#include "ogs/cclasses/Paladin.h"
+ #include "ogs/feats/AllWeapons.h"
#include "ogs/feats/ArmorProficiency.h"
! using namespace ogs::core;
using ogs::cclasses::Paladin;
+ using ogs::feats::AllWeapons;
using ogs::feats::ArmorProficiency;
/**
* Create a new Paladin cclass.
+ *
+ * @param xpLevel Experience level of barbarian.
*/
! Paladin::Paladin (XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! XP::getStrongAttack (xpLevel),
! Saves::getStrongBonus (xpLevel),
! Saves::getWeakBonus (xpLevel),
! Saves::getWeakBonus (xpLevel)),
! _feats () {
// empty constructor body
}
/**
! * Attach this cclass to an object. When a paladin cclass is attached
! * to a character, the Divine Grace feature is added to the creature
! * along with armor and weapon proficiencies if the creature does not
! * already have them.
*/
bool Paladin::attachObject (Object& object) {
***************
*** 63,69 ****
}
! Character& character = dynamic_cast<Character&> (object);
! addDivineGrace (character);
! addProficiencies (character);
return (true);
--- 61,66 ----
}
! addProficiencies ();
! addDivineGrace ();
return (true);
***************
*** 71,97 ****
/**
! * Add armor and weapon proficiency feats of a paladin to a creature.
! *
! * @param character Character to add proficiency feats to.
*/
! void Paladin::addProficiencies (Character& character) {
! // Add armor proficiency feats to creature.
! ArmorProficiency* armorProficiency = ArmorProficiency::createLight ();
! Creature& creature = character.getCreature ();
! if (creature.addFeat (*armorProficiency)) {
! _feats.push_back (armorProficiency);
}
! armorProficiency = ArmorProficiency::createMedium ();
! if (creature.addFeat (*armorProficiency)) {
! _feats.push_back (armorProficiency);
}
! armorProficiency = ArmorProficiency::createHeavy ();
! if (creature.addFeat (*armorProficiency)) {
! _feats.push_back (armorProficiency);
}
! // TODO: Add weapon proficiency feats to creature.
}
--- 68,135 ----
/**
! * Add armor and weapon proficiency feats to creature. Paladins are
! * proficient with all types of armor and simple and martial weapons.
! * If the creature already has some of these feats, shared pointers are
! * stored for these feats so that other classes don't release them.
! * Otherwise, these feats are created and added to the creature.
*/
! void Paladin::addProficiencies () {
! using ogs::items::Armor;
! using ogs::items::Weapon;
!
! // Determine if the creature already has any of these feats.
! Character* character = dynamic_cast<Character*> (getObject ());
! Creature& creature = character->getCreature ();
! Feats feats = creature.getFeats ();
! Feats::iterator itor = feats.begin ();
! std::list<Armor::Proficiency> armors;
! std::list<Weapon::Proficiency> weapons;
!
! while (itor != feats.end ()) {
! FeatPtr featPtr = *itor++;
! ArmorProficiency* armorProficiency =
! dynamic_cast<ArmorProficiency*> (featPtr.get ());
!
! // If the creature has any of these feats, hold a shared pointer so
! // other classes can not release them by accident. Paladins have
! // all armor and all weapon proficiencies so it doesn't matter which
! // type they really are.
! if (armorProficiency != NULL) {
! this->_feats.push_back (featPtr);
! armors.push_back (armorProficiency->getProficiency ());
! } else {
! AllWeapons* allWeapons =
! dynamic_cast<AllWeapons*> (featPtr.get ());
!
! if (allWeapons != NULL) {
! this->_feats.push_back (featPtr);
! weapons.push_back (allWeapons->getProficiency ());
! }
! }
}
! // Create and add any proficiency feats that the creature does not
! // already have.
! std::list<Armor::Proficiency>::iterator end = armors.end ();
! if (std::find (armors.begin (), end, Armor::HEAVY) == end) {
! addProficiency (creature, FeatPtr (ArmorProficiency::createHeavy ()));
}
! if (std::find (armors.begin (), end, Armor::MEDIUM) == end) {
! addProficiency (creature, FeatPtr (ArmorProficiency::createMedium ()));
}
! if (std::find (armors.begin (), end, Armor::LIGHT) == end) {
! addProficiency (creature, FeatPtr (ArmorProficiency::createLight ()));
! }
!
! std::list<Weapon::Proficiency>::iterator wend = weapons.end ();
! if (std::find (weapons.begin (), wend, Weapon::MARTIAL) == wend) {
! addProficiency (creature, FeatPtr (AllWeapons::createMartial ()));
! }
!
! if (std::find (weapons.begin (), wend, Weapon::SIMPLE) == wend) {
! addProficiency (creature, FeatPtr (AllWeapons::createSimple ()));
! }
}
***************
*** 103,111 ****
* @param character Character to add Divine Grace feature to.
*/
! static void
! addDivineGrace (Character& character) {
! Creature& creature = character.getCreature ();
Abilities& abilities = creature.getAbilities ();
AbilityPtr cha = abilities [Ability::CHA];
if (cha) {
Modifier& modifier = cha->getModifier ();
--- 141,150 ----
* @param character Character to add Divine Grace feature to.
*/
! void Paladin::addDivineGrace () {
! Character* character = dynamic_cast<Character*> (getObject ());
! Creature& creature = character->getCreature ();
Abilities& abilities = creature.getAbilities ();
AbilityPtr cha = abilities [Ability::CHA];
+
if (cha) {
Modifier& modifier = cha->getModifier ();
***************
*** 120,134 ****
/**
! * Detach this Paladin cclass from a character.
*/
bool Paladin::detachObject () {
- Object* object = getObject ();
- Character* character = dynamic_cast<Character*> (object);
- if (character != NULL) {
- removeDivineGrace (*character);
- removeProficiencies (*character);
- }
! return (CClass::detachObject ());
}
--- 159,188 ----
/**
! * Detach this cclass from an object. The Paladin class is implemented
! * so that it can be detached from a character.
*/
bool Paladin::detachObject () {
! removeDivineGrace ();
! removeProficiencies ();
!
! return (true);
! }
!
! /**
! * Remove or release any proficiencies that were added to or held from
! * the creature.
! */
! void Paladin::removeProficiencies () {
! Character* character = dynamic_cast<Character*> (getObject ());
! Creature& creature = character->getCreature ();
!
! for (Feats::iterator itor = this->_feats.begin ();
! itor != this->_feats.end (); ++itor) {
! FeatPtr featPtr = *itor;
! if (creature.removeFeat (featPtr)) {
! this->_feats.erase (itor);
! }
! }
}
***************
*** 138,146 ****
* creature.
*/
! static void
! removeDivineGrace (Character& character) {
! Creature& creature = character.getCreature ();
! Abilities& abilities = creature.getAbilities ();
! AbilityPtr cha = abilities [Ability::CHA];
if (cha) {
Modifier& modifier = cha->getModifier ();
--- 192,200 ----
* creature.
*/
! void Paladin::removeDivineGrace () {
! Character* character = dynamic_cast<Character*> (getObject ());
! Creature& creature = character->getCreature ();
! AbilityPtr cha = (creature.getAbilities ()) [Ability::CHA];
!
if (cha) {
Modifier& modifier = cha->getModifier ();
***************
*** 153,170 ****
/**
- * Remove any proficiencies that were added to a creature.
- */
- void Paladin::removeProficiencies (Character& character) {
- // Remove armor proficiency feats from creature.
- Creature& creature = character.getCreature ();
- for (Feats::size_type i = 0; i < _feats.size (); ++i) {
- ogs::core::Feat* feat = _feats [i];
- creature.removeFeat (*feat);
- }
-
- // TODO: Remove weapon proficiency feats.
- }
-
- /**
* Determine the number of spells that this paladin can cast per day.
* The vector index of the return value is the spell level. If the
--- 207,210 ----
***************
*** 196,200 ****
};
! Experience::Level xpLevel = getLevel ();
SpellCounts spellCounts;
if (xpLevel >= 4) {
--- 236,240 ----
};
! XP::Level xpLevel = getLevel ();
SpellCounts spellCounts;
if (xpLevel >= 4) {
Index: Paladin.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Paladin.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Paladin.h 4 Apr 2003 20:22:42 -0000 1.2
--- Paladin.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 30,45 ****
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
!
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class that strives to be the paragon of virtue. Paladins
--- 30,40 ----
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
+ # include <ogs/core/Experience.h>
# include <ogs/core/Saves.h>
! # include <ogs/core/Types.h>
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
/**
* A character class that strives to be the paragon of virtue. Paladins
***************
*** 63,127 ****
class Paladin: public ogs::core::CClass {
public:
! Paladin (Experience::Level xpLevel = 1);
! bool attachObject (Object& object);
! bool detachObject ();
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
SpellCounts getSpellsPerDay () const;
private:
! typedef std::vector<ogs::core::Feat*> Feats;
! Feats _feats;
! Modifier::Value getBaseAttackValue () const;
! Modifier::Value getBaseFortSaveValue () const;
! void addProficiencies (ogs::core::Character& character);
! void removeProficiencies (ogs::core::Character& character);
};
! /**
! * Determine the hit die for this cclass. Paladins use d10 for their
! * hit die.
! *
! * @return Die::d10.
! */
! inline Die::Sides Paladin::getHitDie () const {
! return (Die::d10);
! }
!
! /**
! * Determine the skill points per experience level for this cclass.
! * Paladins gain 2 skill points for each experience level.
! *
! * @return 2 skill points.
! */
! inline Skill::Points Paladin::getSkillPoints () const {
! return (2);
! }
!
! /**
! * Determine the value of base attack bonus for this cclass. Paladins
! * use the strong advancement rate for base attack bonuses.
! *
! * @return Value of base attack bonus.
! */
! inline Modifier::Value Paladin::getBaseAttackValue () const {
! return (Experience::getStrongAttack (getLevel ()));
! }
!
! /**
! * Determine the value of base Fortitude save bonus for this cclass.
! * Paladins use the strong advancement rate for base Fortitude save
! * bonuses.
! *
! * @return Value of base Fortitude save bonus.
! */
! inline Modifier::Value Paladin::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 58,105 ----
class Paladin: public ogs::core::CClass {
public:
! /**
! * Hit die of paladins. Paladins use d12 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d10;
! /**
! * Skill rate of paladins. Paladins gain 2 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 2;
! Paladin (ogs::core::XP::Level xpLevel = 1);
!
! bool attachObject (ogs::support::Object& object);
! bool detachObject ();
+ /**
+ * An array of spell counts. Each element in the array represents
+ * the number of spells for that spell level. The spell level is
+ * the same as the index of the array.
+ */
typedef std::vector<unsigned> SpellCounts;
+
SpellCounts getSpellsPerDay () const;
private:
! ogs::core::Feats _feats;
! class ogs::core::Creature;
! void addProficiency (ogs::core::Creature& creature,
! ogs::core::FeatPtr featPtr);
! void addProficiencies ();
! void removeProficiencies ();
! void addDivineGrace ();
! void removeDivineGrace ();
};
! inline void
! Paladin::addProficiency (ogs::core::Creature& creature,
! ogs::core::FeatPtr featPtr) {
! if (creature.addFeat (featPtr)) {
! this->_feats.push_back (featPtr);
! }
}
Index: Ranger.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Ranger.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Ranger.h 4 Apr 2003 20:22:42 -0000 1.2
--- Ranger.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class skilled at outdoor hunting and survival. Rangers
--- 31,38 ----
***************
*** 68,75 ****
class Ranger: public ogs::core::CClass {
public:
! Ranger (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 61,76 ----
class Ranger: public ogs::core::CClass {
public:
! /**
! * Hit die of rangers. Rangers use d10 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d10;
! /**
! * Skill rate of rangers. Rangers gain 4 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 4;
!
! Ranger (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 77,82 ****
protected:
! Modifier::Value getBaseAttackValue () const;
! Modifier::Value getBaseFortSaveValue () const;
};
--- 78,83 ----
protected:
! ogs::core::Modifier::Value getBaseAttackValue () const;
! ogs::core::Modifier::Value getBaseFortSaveValue () const;
};
***************
*** 86,115 ****
* @param xpLevel Experience level of ranger.
*/
! inline Ranger::Ranger (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Rangers use d10 for their hit
- * die.
- *
- * @return Die::d10.
- */
- inline Die::Sides Ranger::getHitDie () const {
- return (Die::d10);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Rangers gain 4 skill points for each experience level.
- *
- * @return 4 skill points.
- */
- inline Skill::Points Ranger::getSkillPoints () const {
- return (4);
- }
-
- /**
* Determine the value of base attack bonus for this cclass. Rangers
* use the strong advancement rate for base attack bonuses.
--- 87,100 ----
* @param xpLevel Experience level of ranger.
*/
! inline Ranger::Ranger (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base attack bonus for this cclass. Rangers
* use the strong advancement rate for base attack bonuses.
***************
*** 117,122 ****
* @return Value of base attack bonus.
*/
! inline Modifier::Value Ranger::getBaseAttackValue () const {
! return (Experience::getStrongAttack (getLevel ()));
}
--- 102,108 ----
* @return Value of base attack bonus.
*/
! inline ogs::core::Modifier::Value
! Ranger::getBaseAttackValue () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
***************
*** 128,142 ****
* @return Value of base Fortitude save bonus.
*/
! inline Modifier::Value Ranger::getBaseFortSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
! }
!
! /**
! * Determine the number of spells that this ranger can cast per day.
! *
! * @return Number of spells at each spell leve.
! */
! inline Ranger::SpellCounts Ranger::getSpellsPerDay () const {
! return (SpellCounts ()); // TODO: Implement.
}
--- 114,120 ----
* @return Value of base Fortitude save bonus.
*/
! inline ogs::core::Modifier::Value
! Ranger::getBaseFortSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Rogue.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Rogue.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Rogue.h 4 Apr 2003 20:22:42 -0000 1.2
--- Rogue.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class adept at "obtaining the unobtainable". Rogues
--- 31,38 ----
***************
*** 58,68 ****
class Rogue: public ogs::core::CClass {
public:
! Rogue (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
protected:
! Modifier::Value getBaseRefSaveValue () const;
};
--- 51,69 ----
class Rogue: public ogs::core::CClass {
public:
! /**
! * Hit die of rogues. Rogues use d6 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d6;
! /**
! * Skill rate of rogues. Rogues gain 8 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 8;
!
! Rogue (ogs::core::XP::Level xpLevel = 1);
protected:
! ogs::core::Modifier::Value getBaseRefSaveValue () const;
};
***************
*** 72,101 ****
* @param xpLevel Experience level of rogue.
*/
! inline Rogue::Rogue (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Rogues use d6 for their hit
- * die.
- *
- * @return Die::d6.
- */
- inline Die::Sides Rogue::getHitDie () const {
- return (Die::d6);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Rogues gain 8 skill points for each experience level.
- *
- * @return 8 skill points.
- */
- inline Skill::Points Rogue::getSkillPoints () const {
- return (8);
- }
-
- /**
* Determine the value of base Reflex save bonus for this cclass.
* Rogues use the strong advancement rate for base Reflex save bonuses.
--- 73,86 ----
* @param xpLevel Experience level of rogue.
*/
! inline Rogue::Rogue (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base Reflex save bonus for this cclass.
* Rogues use the strong advancement rate for base Reflex save bonuses.
***************
*** 103,108 ****
* @return Value of base Reflex save bonus.
*/
! inline Modifier::Value Rogue::getBaseRefSaveValue () const {
! return (Saves::getWeakBonus (getLevel ()));
}
--- 88,94 ----
* @return Value of base Reflex save bonus.
*/
! inline ogs::core::Modifier::Value
! Rogue::getBaseRefSaveValue () const {
! return (ogs::core::Saves::getWeakBonus (getLevel ()));
}
Index: Sorcerer.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Sorcerer.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Sorcerer.h 4 Apr 2003 20:22:42 -0000 1.2
--- Sorcerer.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class with inherent spell casting abilities. Sorcerers
--- 31,38 ----
***************
*** 48,59 ****
* are more limited in their range of spell casting abilities but do not
* have to memorize spells before casting them. They are also
! * proficient with all simple weapons.
*/
class Sorcerer: public ogs::core::CClass {
public:
! Sorcerer (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 41,62 ----
* are more limited in their range of spell casting abilities but do not
* have to memorize spells before casting them. They are also
! * proficient with all simple weapons. <P>
! *
! * Sorcerers are typically found in fantasy campaign settings.
*/
class Sorcerer: public ogs::core::CClass {
public:
! /**
! * Hit die of sorcerers. Sorcerers use d4 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d4;
! /**
! * Skill rate of sorcerers. Sorcerers gain 2 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 2;
!
! Sorcerer (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 62,67 ****
protected:
! Modifier::Value getBaseAttackValue () const;
! Modifier::Value getBaseWillSaveValue () const;
};
--- 65,70 ----
protected:
! ogs::core::Modifier::Value getBaseAttackValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
};
***************
*** 71,100 ****
* @param xpLevel Experience level of sorcerer.
*/
! inline Sorcerer::Sorcerer (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this cclass. Sorcerers use d4 for their
- * hit die.
- *
- * @return Die::d4.
- */
- inline Die::Sides Sorcerer::getHitDie () const {
- return (Die::d4);
- }
-
- /**
- * Determine the skill points per experience level for this cclass.
- * Sorcerers gain 2 skill points for each experience level.
- *
- * @return 2 skill points.
- */
- inline Skill::Points Sorcerer::getSkillPoints () const {
- return (2);
- }
-
- /**
* Determine the value of base attack bonus for this cclass. Sorcerers
* use the weak advancment rate for base attack bonuses.
--- 74,87 ----
* @param xpLevel Experience level of sorcerer.
*/
! inline Sorcerer::Sorcerer (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base attack bonus for this cclass. Sorcerers
* use the weak advancment rate for base attack bonuses.
***************
*** 102,107 ****
* @return Value of base attack bonus.
*/
! inline Modifier::Value Sorcerer::getBaseAttackValue () const {
! return (Experience::getWeakAttack (getLevel ()));
}
--- 89,95 ----
* @return Value of base attack bonus.
*/
! inline ogs::core::Modifier::Value
! Sorcerer::getBaseAttackValue () const {
! return (ogs::core::XP::getWeakAttack (getLevel ()));
}
***************
*** 112,117 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Sorcerer::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
}
--- 100,106 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Sorcerer::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
Index: Wizard.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Wizard.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Wizard.h 4 Apr 2003 20:22:42 -0000 1.2
--- Wizard.h 13 Apr 2003 05:24:49 -0000 1.3
***************
*** 31,45 ****
# include <ogs/core/Die.h>
# include <ogs/core/Saves.h>
-
# include <ogs/cclasses/Namespace.h>
OGS_BEGIN_CCLASSES_NAMESPACE
- using ogs::core::Die;
- using ogs::core::Experience;
- using ogs::core::Modifier;
- using ogs::core::Saves;
- using ogs::core::Skill;
-
/**
* A character class devoted to the mastery of arcane magic. Wizards
--- 31,38 ----
***************
*** 73,80 ****
class Wizard: public ogs::core::CClass {
public:
! Wizard (Experience::Level xpLevel = 1);
! Die::Sides getHitDie () const;
! Skill::Points getSkillPoints () const;
typedef std::vector<unsigned> SpellCounts;
--- 66,81 ----
class Wizard: public ogs::core::CClass {
public:
! /**
! * Hit die of wizards. Wizards use d4 for their hit die.
! */
! static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d4;
! /**
! * Skill rate of wizards. Wizards gain 2 skill points per
! * experience level.
! */
! static const ogs::core::Skill::Points SKILL_RATE = 2;
!
! Wizard (ogs::core::XP::Level xpLevel = 1);
typedef std::vector<unsigned> SpellCounts;
***************
*** 82,90 ****
protected:
! Modifier::Value getBaseAttackValue () const;
! Modifier::Value getBaseWillSaveValue () const;
private:
! School specialty;
};
--- 83,91 ----
protected:
! ogs::core::Modifier::Value getBaseAttackValue () const;
! ogs::core::Modifier::Value getBaseWillSaveValue () const;
private:
! //Specialty _specialty;
};
***************
*** 94,123 ****
* @param xpLevel Experience level of wizard.
*/
! inline Wizard::Wizard (Experience::Level xpLevel):
! CClass (xpLevel) {
// empty constructor body
}
/**
- * Determine the hit die for this class. Wizards use d4 for their hit
- * die.
- *
- * @return Die::d4.
- */
- inline Die::Sides Wizard::getHitDie () const {
- return (Die::d4);
- }
-
- /**
- * Determine the skill points per experience level for wizards. Wizards
- * gain 2 skill points for each experience level.
- *
- * @return 2 skill points.
- */
- inline Skill::Points Wizard::getSkillPoints () const {
- return (2);
- }
-
- /**
* Determine the value of base attack bonus for wizards. Wizards use
* the weak advancement rate for base attack bonuses.
--- 95,108 ----
* @param xpLevel Experience level of wizard.
*/
! inline Wizard::Wizard (ogs::core::XP::Level xpLevel):
! CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::XP::getAverageAttack (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel),
! ogs::core::Saves::getWeakBonus (xpLevel)) {
// empty constructor body
}
/**
* Determine the value of base attack bonus for wizards. Wizards use
* the weak advancement rate for base attack bonuses.
***************
*** 125,130 ****
* @return Value of base attack bonus.
*/
! inline Modifier::Value Wizard::getBaseAttackValue () const {
! return (Experience::getWeakAttack (getLevel ()));
}
--- 110,116 ----
* @return Value of base attack bonus.
*/
! inline ogs::core::Modifier::Value
! Wizard::getBaseAttackValue () const {
! return (ogs::core::XP::getWeakAttack (getLevel ()));
}
***************
*** 135,149 ****
* @return Value of base Will save bonus.
*/
! inline Modifier::Value Wizard::getBaseWillSaveValue () const {
! return (Saves::getStrongBonus (getLevel ()));
! }
!
! /**
! * Determine the number of spells that this wizard can cast per day.
! *
! * @return Number of spells at each spell leve.
! */
! inline Wizard::SpellCounts Wizard::getSpellsPerDay () const {
! return (SpellCounts ()); // TODO: Implement.
}
--- 121,127 ----
* @return Value of base Will save bonus.
*/
! inline ogs::core::Modifier::Value
! Wizard::getBaseWillSaveValue () const {
! return (ogs::core::Saves::getStrongBonus (getLevel ()));
}
|
|
From: <ele...@us...> - 2003-04-08 21:43:48
|
Update of /cvsroot/ogs/dist/c++/ogs/support
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/ogs/support
Modified Files:
Event.cpp Event.h
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
Index: Event.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Event.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Event.cpp 25 Mar 2003 06:13:15 -0000 1.2
--- Event.cpp 8 Apr 2003 21:43:13 -0000 1.3
***************
*** 1,4 ****
/*
! * Event.c++ -- class implementation for events
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * Event.cpp -- class implementation for events
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 40,44 ****
std::ostringstream ostr;
ostr << (typeid (*this)).name () << "@" << this;
! ostr << " [source " << &source<< "]";
return (ostr.str ());
}
--- 40,44 ----
std::ostringstream ostr;
ostr << (typeid (*this)).name () << "@" << this;
! ostr << " [source " << &(this->_source) << "]";
return (ostr.str ());
}
Index: Event.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Event.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Event.h 25 Mar 2003 06:13:15 -0000 1.2
--- Event.h 8 Apr 2003 21:43:14 -0000 1.3
***************
*** 35,48 ****
/**
! * Base class for events. This class provides part of the
! * @em Observer pattern: it provides Observers with the details of
! * the event from Observed objects. The details contained in this class
! * provide observers with a pointer to the observed object. Subclasses
! * can extend this class if additional information is needed.
*/
class Event {
public:
Event (Object& object);
! virtual ~Event ();
Object& getSource () const;
--- 35,49 ----
/**
! * An object that notifies observers of significant events. Events are
! * collaborators in the @em Observer pattern: they provide observers
! * with details of the event from observed objects. An observed object
! * is also called an event source. The details contained in an event
! * provide observers with the source of the event. Derived classes can
! * extend this class to provide additional information if needed.
*/
class Event {
public:
Event (Object& object);
! virtual ~Event () { }
Object& getSource () const;
***************
*** 50,54 ****
private:
! Object& source;
};
--- 51,60 ----
private:
! /*
! * The lifetime of the source is assumed to outlast the lifetime of
! * events that it creates. If this assumption proves false, the
! * source type and perhaps the interface will have to be changed.
! */
! Object& _source;
};
***************
*** 58,62 ****
* @param object The object causing this event.
*/
! inline Event::Event (Object& object): source (object) {
// empty constructor
}
--- 64,69 ----
* @param object The object causing this event.
*/
! inline Event::Event (Object& object):
! _source (object) {
// empty constructor
}
***************
*** 67,75 ****
* @return The object causing this event.
*/
! inline Object& Event::getSource () const {
! return (this->source);
}
-
- inline Event::~Event () { }
OGS_END_SUPPORT_NAMESPACE
--- 74,81 ----
* @return The object causing this event.
*/
! inline Object&
! Event::getSource () const {
! return (this->_source);
}
OGS_END_SUPPORT_NAMESPACE
|
|
From: <ele...@us...> - 2003-04-08 21:43:46
|
Update of /cvsroot/ogs/dist/c++/ogs/magic/abilities
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/ogs/magic/abilities
Modified Files:
Charisma.h Intelligence.h Wisdom.h
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
Index: Charisma.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/abilities/Charisma.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Charisma.h 5 Feb 2003 06:01:28 -0000 1.1
--- Charisma.h 8 Apr 2003 21:43:11 -0000 1.2
***************
*** 61,65 ****
*/
inline Ability::SpellCounts Charisma::getBonusSpells () const {
! return (Ability::getBonusSpells (getCurrentScore ()));
}
--- 61,65 ----
*/
inline Ability::SpellCounts Charisma::getBonusSpells () const {
! return (Ability::getBonusSpells ((getModifier ()).getValue ()));
}
Index: Intelligence.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/abilities/Intelligence.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Intelligence.h 5 Feb 2003 06:01:28 -0000 1.1
--- Intelligence.h 8 Apr 2003 21:43:12 -0000 1.2
***************
*** 61,65 ****
*/
inline Ability::SpellCounts Intelligence::getBonusSpells () const {
! return (Ability::getBonusSpells (getCurrentScore ()));
}
--- 61,65 ----
*/
inline Ability::SpellCounts Intelligence::getBonusSpells () const {
! return (Ability::getBonusSpells ((getModifier ()).getValue ()));
}
Index: Wisdom.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/abilities/Wisdom.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Wisdom.h 5 Feb 2003 06:01:28 -0000 1.1
--- Wisdom.h 8 Apr 2003 21:43:12 -0000 1.2
***************
*** 61,65 ****
*/
inline Ability::SpellCounts Wisdom::getBonusSpells () const {
! return (Ability::getBonusSpells (getCurrentScore ()));
}
--- 61,65 ----
*/
inline Ability::SpellCounts Wisdom::getBonusSpells () const {
! return (Ability::getBonusSpells ((getModifier ()).getValue ()));
}
|
Update of /cvsroot/ogs/dist/c++/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/ogs/core
Modified Files:
Abilities.cpp Abilities.h Ability.cpp Ability.h Character.cpp
Creature.cpp Modifier.cpp Modifier.h Modifiers.cpp Modifiers.h
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
Index: Abilities.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Abilities.cpp 4 Apr 2003 20:22:43 -0000 1.4
--- Abilities.cpp 8 Apr 2003 21:43:06 -0000 1.5
***************
*** 29,32 ****
--- 29,37 ----
using ogs::core::Strength;
+ static Ability::Type types [] = {
+ Ability::CHA, Ability::CON, Ability::DEX,
+ Ability::INT, Ability::STR, Ability::WIS
+ };
+
/**
* Create a complete set of abilities. The ability scores are generated
***************
*** 34,44 ****
*/
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);
}
--- 39,49 ----
*/
Abilities::Abilities () {
! PtrMap& map = *this;
! map [Ability::CHA] = AbilityPtr (new Ability (Ability::CHA));
! map [Ability::CON] = AbilityPtr (new Ability (Ability::CON));
! map [Ability::DEX] = AbilityPtr (new Ability (Ability::DEX));
! map [Ability::INT] = AbilityPtr (new Ability (Ability::INT));
! map [Ability::STR] = AbilityPtr (new Strength ());
! map [Ability::WIS] = AbilityPtr (new Ability (Ability::WIS));
}
***************
*** 49,70 ****
*/
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);
}
- struct Abilities::Delete {
- void operator() (ValueType value) { delete value.second; }
- };
-
/**
! * Destroy this set of abilities.
*/
! Abilities::~Abilities () {
! std::for_each (this->begin (), this->end (), Delete ());
}
--- 54,84 ----
*/
Abilities::Abilities (Ability::Method& method) {
! PtrMap& map = *this;
! map [Ability::CHA] = AbilityPtr (new Ability (Ability::CHA, method));
! map [Ability::CON] = AbilityPtr (new Ability (Ability::CON, method));
! map [Ability::DEX] = AbilityPtr (new Ability (Ability::DEX, method));
! map [Ability::INT] = AbilityPtr (new Ability (Ability::INT, method));
! map [Ability::STR] = AbilityPtr (new Strength (method));
! map [Ability::WIS] = AbilityPtr (new Ability (Ability::WIS, method));
}
/**
! * Cteate a set of abilities using a direct method.
! *
! * @param directMethod A direct method.
*/
! Abilities::Abilities (PartialMethod& directMethod) {
! PtrMap& map = *this;
!
! for (int i = 0; i < Ability::NUM; ++i) {
! Ability::Type type = types [i];
!
! if (directMethod.hasAbility (type)) {
! Ability* ability = type == Ability::STR?
! new Strength (directMethod):
! new Ability (type, directMethod);
! map [type] = AbilityPtr (ability);
! }
! }
}
***************
*** 84,98 ****
if (isComplete ()) {
! Map& map = *this;
Modifier::Value total = 0;
Ability* ability = NULL;
Ability::Score highest = 0;
- Ability::Type types [] = {
- Ability::CHA, Ability::CON, Ability::DEX,
- Ability::INT, Ability::STR, Ability::WIS
- };
for (int i = 0; i < Ability::NUM; ++i) {
! ability = map [types [i]];
total += (ability->getModifier ()).getValue ();
if (ability->getOriginalScore () > highest) {
--- 98,108 ----
if (isComplete ()) {
! PtrMap& map = *this;
Modifier::Value total = 0;
Ability* ability = NULL;
Ability::Score highest = 0;
for (int i = 0; i < Ability::NUM; ++i) {
! ability = (map [types [i]]).get ();
total += (ability->getModifier ()).getValue ();
if (ability->getOriginalScore () > highest) {
Index: Abilities.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Abilities.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Abilities.h 4 Apr 2003 20:22:43 -0000 1.3
--- Abilities.h 8 Apr 2003 21:43:08 -0000 1.4
***************
*** 28,55 ****
# include <map>
# include <ogs/core/Ability.h>
OGS_BEGIN_CORE_NAMESPACE
/**
! * A set of ability scores. A set of ability scores normally consists
! * of one score for each ability. Some entities however may not possess
! * all six abilities. Certain creatures for example may lack
! * Intelligence, Constitution, Strength, or some other ability by their
! * very nature.
*/
! class Abilities: private std::map<Ability::Type, Ability*> {
public:
! // TODO: Change this to a smart pointer.
! typedef std::map<Ability::Type, Ability*>::iterator Iterator;
Abilities ();
Abilities (Ability::Method& method);
! ~Abilities ();
Iterator getBegin ();
Iterator getEnd ();
! Ability* operator[] (Ability::Type abilityType);
! void removeAbility (Ability::Type abilityType);
bool isComplete () const;
--- 28,67 ----
# 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
! * complete set of ability scores consists of one score for each type of
! * ability. Some entities however may not possess all six abilities.
! * Certain creatures for example may lack Intelligence, Constitution,
! * Strength, or some other ability by their very nature. Sentient items
! * also do not have physical abilities. These entities have partial
! * sets of ability scores.
*/
! class Abilities: private std::map<Ability::Type, AbilityPtr> {
! private:
! typedef std::map<Ability::Type, Ability::Score> ScoreMap;
! typedef std::map<Ability::Type, AbilityPtr> PtrMap;
!
public:
! /** An iterator for each ability in this set. */
! typedef PtrMap::iterator Iterator;
!
! struct PartialMethod;
Abilities ();
Abilities (Ability::Method& method);
! Abilities (PartialMethod& directMethod);
Iterator getBegin ();
Iterator getEnd ();
! AbilityPtr operator[] (Ability::Type abilityType);
bool isComplete () const;
***************
*** 59,73 ****
private:
! typedef std::map<Ability::Type, Ability*> Map;
! typedef Map::value_type ValueType;
! struct Delete;
! Abilities (const Abilities& abilities);
! Abilities& operator= (const Abilities& abilities);
! bool canReroll (Modifier::Value modifier, Ability::Score score);
};
/**
* Determine the iterator for the beginning of these abilities.
*
--- 71,134 ----
private:
! bool canReroll (Modifier::Value modifier, Ability::Score score);
! };
! /**
! * 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,
! private Abilities::ScoreMap {
! /** 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
+ }
+
+ /**
+ * Determine if this method provides a score for an ability type.
+ *
+ * @param type An ability type.
+ * @return True if this method provides a score for the type.
+ */
+ inline bool
+ Abilities::PartialMethod::hasAbility (Ability::Type type) {
+ return (this->find (type) != this->end ());
+ }
+
+ /**
+ * Determine the score for an ability type.
+ *
+ * @param type An ability type.
+ * @return An ability score.
+ */
+ inline Ability::Score
+ Abilities::PartialMethod::operator() (Ability::Type type) {
+ return ((*this) [type]);
+ }
+
+ /**
* Determine the iterator for the beginning of these abilities.
*
***************
*** 96,115 ****
* @return An ability or null if the ability does not exist.
*/
! inline Ability*
Abilities::operator[] (Ability::Type abilityType) {
// The map::operator[] inserts the key if not found so this operator
// cannot use it. It has to check first and return NULL if not found.
Iterator itor = find (abilityType);
! return (itor == end ()? NULL: itor->second);
! }
!
! /**
! * Remove an ability from this set of abilities.
! *
! * @param abilityType Type of ability to be removed.
! */
! inline void
! Abilities::removeAbility (Ability::Type abilityType) {
! this->erase (abilityType);
}
--- 157,166 ----
* @return An ability or null if the ability does not exist.
*/
! inline AbilityPtr
Abilities::operator[] (Ability::Type abilityType) {
// The map::operator[] inserts the key if not found so this operator
// cannot use it. It has to check first and return NULL if not found.
Iterator itor = find (abilityType);
! return (itor == end ()? AbilityPtr (): itor->second);
}
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Ability.cpp 4 Apr 2003 20:22:43 -0000 1.5
--- Ability.cpp 8 Apr 2003 21:43:08 -0000 1.6
***************
*** 116,120 ****
_type (type),
_originalScore (rollStandard ()),
! _currentScore (_originalScore),
_modifier (getModifier (_originalScore)) {
if (! isValidType (type)) {
--- 116,120 ----
_type (type),
_originalScore (rollStandard ()),
! _modifiers (),
_modifier (getModifier (_originalScore)) {
if (! isValidType (type)) {
***************
*** 124,127 ****
--- 124,129 ----
throw std::invalid_argument (ostr.str ());
}
+
+ this->_modifiers.addObserver (*this);
}
***************
*** 137,141 ****
_type (type),
_originalScore (method (type)),
! _currentScore (_originalScore),
_modifier (getModifier (_originalScore)) {
if (! isValidType (type)) {
--- 139,143 ----
_type (type),
_originalScore (method (type)),
! _modifiers (),
_modifier (getModifier (_originalScore)) {
if (! isValidType (type)) {
***************
*** 145,148 ****
--- 147,152 ----
throw std::invalid_argument (ostr.str ());
}
+
+ this->_modifiers.addObserver (*this);
}
***************
*** 155,173 ****
void Ability::handleEvent (Event& event) {
try {
! Modifier::Event& modEvent = dynamic_cast<Modifier::Event&> (event);
! Modifier& modifier = dynamic_cast<Modifier&> (event.getSource ());
!
! this->_currentScore -= modEvent.getPreviousValue ();
! this->_currentScore += modifier.getValue ();
! // Update ability modifier only when neccessary.
! if (this->_modifier.getValue () != getModifier (this->_currentScore)) {
! this->_modifier.setValue (getModifier (this->_currentScore));
}
- Event event (*this);
notifyObservers (event);
} catch (...) {
! // Observed object was not a modifier. Ignore it.
}
}
--- 159,177 ----
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.
}
}
Index: Ability.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Ability.h 4 Apr 2003 20:22:43 -0000 1.4
--- Ability.h 8 Apr 2003 21:43:08 -0000 1.5
***************
*** 105,174 ****
typedef unsigned short 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 Method {
! virtual Score operator() (Type type) = 0;
! virtual ~Method () { }
! };
!
! /**
! * A method that generates above-average ability scores. The
! * standard method rolls 4d6 and adds the highest three rolls to
! * generate an ability score. The standard method is normally used
! * to generate ability scores for player characters.
! */
! 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 ());
! }
! };
!
! /**
! * A method that generates average ability scores. The average
! * method rolls 3d6 to generate an ability score. The average
! * method is nnormally used to generate ability scores for
! * nonplayer characters.
! */
! 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 ());
! }
! };
!
! /**
! * A method that generates "high-powered" ability scores. The
! * high-powered method rolls 5d6 and adds the highest three rolls to
! * generate an ability score. The high-powered method is nnormally
! * used to generate ability scores for high-level player characters
! */
! 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);
--- 105,115 ----
typedef unsigned short Score;
! struct Method;
! struct StandardMethod;
! struct AverageMethod;
! struct HighPoweredMethod;
! struct DirectMethod;
static bool isValidType (int i);
static unsigned getIncreaseCount (Experience::Level xpLevel);
static Experience::Level getIncreaseCountLevel (unsigned count);
***************
*** 189,193 ****
Score _originalScore;
Modifiers _modifiers;
- Score _currentScore;
Modifier _modifier;
--- 130,133 ----
***************
*** 195,198 ****
--- 135,232 ----
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 () { }
+ };
+
+ /**
+ * A method that generates above-average ability scores. The standard
+ * method rolls 4d6 and adds the highest three rolls to generate an
+ * ability score. The standard method is normally used to generate
+ * ability scores for player characters.
+ */
+ struct Ability::StandardMethod: public Ability::Method {
+ /**
+ * Generate a score using the standard method. The type parameter
+ * is not used.
+ *
+ * @return An ability score.
+ */
+ Ability::Score operator() (Ability::Type) {
+ return (Ability::rollStandard ());
+ }
+ };
+
+ /**
+ * A method that generates average ability scores. The average method
+ * rolls 3d6 to generate an ability score. The average method is
+ * normally used to generate ability scores for nonplayer characters.
+ */
+ struct Ability::AverageMethod: public Ability::Method {
+ /**
+ * Generate a score using the average method. The type parameter
+ * is not used.
+ *
+ * @return An ability score.
+ */
+ Ability::Score operator() (Ability::Type) {
+ return (Ability::rollAverage ());
+ }
+ };
+
+ /**
+ * A method that generates "high-powered" ability scores. The
+ * high-powered method rolls 5d6 and adds the highest three rolls to
+ * generate an ability score. The high-powered method is nnormally
+ * used to generate ability scores for high-level player characters
+ */
+ struct Ability::HighPoweredMethod: public Ability::Method {
+ /**
+ * Generate a score using the high-powered method. The type
+ * parameter is not used.
+ *
+ * @return An ability score.
+ */
+ Ability::Score operator() (Ability::Type) {
+ return (Ability::rollHighPowered ());
+ }
+ };
+
+ /**
+ * A method that generates a direct ability score. The direct method is
+ * used to initialize an ability with a fixed score. This method is
+ * normally used by referees and players who are allowed to choose
+ * ability scores.
+ */
+ struct Ability::DirectMethod: public Ability::Method {
+ Ability::Score score;
+
+ /**
+ * Create a new direct method.
+ *
+ * @param score A score to be generated by this method.
+ */
+ DirectMethod (Ability::Score score) {
+ this->score = score;
+ }
+
+ /**
+ * Generate a score using the direct method. This method simply
+ * returns the score contained in the direct method.
+ *
+ * @return An ability score.
+ */
+ Ability::Score operator() (Ability::Type) {
+ return (score);
+ }
};
***************
*** 274,278 ****
inline Ability::Score
Ability::getCurrentScore () const {
! return (this->_currentScore);
}
--- 308,312 ----
inline Ability::Score
Ability::getCurrentScore () const {
! return (this->_originalScore + this->_modifiers.getValue ());
}
Index: Character.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Character.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Character.cpp 29 Mar 2003 02:10:29 -0000 1.5
--- Character.cpp 8 Apr 2003 21:43:09 -0000 1.6
***************
*** 77,82 ****
// Add Ingelligence bonus if any.
Abilities& abilities = _creature.getAbilities ();
! Ability* intl = abilities [Ability::INT];
! if (intl != NULL) {
Modifier& modifier = intl->getModifier ();
Modifier::Value value = modifier.getValue ();
--- 77,82 ----
// Add Ingelligence bonus if any.
Abilities& abilities = _creature.getAbilities ();
! AbilityPtr intl = abilities [Ability::INT];
! if (intl) {
Modifier& modifier = intl->getModifier ();
Modifier::Value value = modifier.getValue ();
Index: Creature.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Creature.cpp 29 Mar 2003 02:10:29 -0000 1.8
--- Creature.cpp 8 Apr 2003 21:43:09 -0000 1.9
***************
*** 41,45 ****
_skills (), _feats (), _body (body), _character (NULL) {
// Add Dexterity modifier to Reflex save, initiative, and defense.
! Ability* ability = this->_abilities [Ability::DEX];
Modifier& modifier = ability->getModifier ();
this->_saves.ref.addModifier (modifier);
--- 41,45 ----
_skills (), _feats (), _body (body), _character (NULL) {
// Add Dexterity modifier to Reflex save, initiative, and defense.
! AbilityPtr ability = this->_abilities [Ability::DEX];
Modifier& modifier = ability->getModifier ();
this->_saves.ref.addModifier (modifier);
Index: Modifier.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifier.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Modifier.cpp 25 Mar 2003 06:13:11 -0000 1.2
--- Modifier.cpp 8 Apr 2003 21:43:09 -0000 1.3
***************
*** 25,32 ****
#include <typeinfo>
! #include "ogs/Support.h"
#include "ogs/core/Modifier.h"
! using namespace ogs::support;
using ogs::core::Modifier;
--- 25,32 ----
#include <typeinfo>
! #include "ogs/support/Object.h"
#include "ogs/core/Modifier.h"
! using ogs::support::Object;
using ogs::core::Modifier;
***************
*** 39,44 ****
// Let event store previous value before it is changed.
Modifier::Event event (*this);
!
! this->value = value;
notifyObservers (event);
}
--- 39,43 ----
// Let event store previous value before it is changed.
Modifier::Event event (*this);
! this->_value = value;
notifyObservers (event);
}
***************
*** 52,68 ****
std::string Modifier::toString () const {
std::ostringstream ostr;
! ostr << (typeid (this)).name () << "@" << this;
! ostr << " [value " << value << "]";
return (ostr.str ());
- }
-
- /**
- * Create a new modifier event.
- *
- * @param modifier Modifier causing this event.
- */
- Modifier::Event::Event (Modifier& modifier):
- ogs::support::Event (modifier) {
- this->value = modifier.getValue ();
}
--- 51,57 ----
std::string Modifier::toString () const {
std::ostringstream ostr;
! ostr << Object::toString ();
! ostr << " [value " << this->_value << "]";
return (ostr.str ());
}
Index: Modifier.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifier.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifier.h 7 Jan 2003 07:41:33 -0000 1.1
--- Modifier.h 8 Apr 2003 21:43:09 -0000 1.2
***************
*** 36,41 ****
/**
! * A modifier is an integer value added to (or subtracted from if
! * negative) another integer value.
*/
class Modifier: public ogs::support::Object {
--- 36,45 ----
/**
! * An integer value added to another integer value. If the value of the
! * modifier is negative, the value of the modifier is subtracted from
! * the other value. The "other" value may be an objects that has a
! * modifiable integer attribute. The integer value is encapsulated in
! * a class to allow modifier objects to notify observers of events that
! * cause the value of the modifier to change.
*/
class Modifier: public ogs::support::Object {
***************
*** 44,50 ****
* A signed integer type representing the value of a modifier. This
* type is explicitly named in case the underlying type should
! * changes in the future.
*/
! typedef int Value;
class Event;
--- 48,54 ----
* A signed integer type representing the value of a modifier. This
* type is explicitly named in case the underlying type should
! * change in the future.
*/
! typedef short Value;
class Event;
***************
*** 58,71 ****
private:
! Value value;
};
/**
! * Create a modifier with a specified value.
*
* @param value Value of the modifier.
*/
! inline Modifier::Modifier (Value value) {
! this->value = value;
}
--- 62,77 ----
private:
! Value _value;
};
/**
! * Create a new modifier. The default value of the modifier is zero (0).
*
* @param value Value of the modifier.
*/
! inline
! Modifier::Modifier (Value value):
! _value (value) {
! // empty constructor body
}
***************
*** 75,102 ****
* @return Value of the modifier.
*/
! inline Modifier::Value Modifier::getValue () const {
! return (this->value);
}
/**
* An event that allows observers to determine the previous value of
! * the modifier.
*/
class Modifier::Event: public ogs::support::Event {
public:
- Event (Modifier& modifier);
Value getPreviousValue () const;
private:
! Value value;
};
/**
* Determine previous value of this modifier.
*
* @return Previous value of this modifier.
*/
! inline Modifier::Value Modifier::Event::getPreviousValue () const {
! return (this->value);
}
--- 81,123 ----
* @return Value of the modifier.
*/
! inline Modifier::Value
! Modifier::getValue () const {
! return (this->_value);
}
/**
* An event that allows observers to determine the previous value of
! * the modifier. Modifier events must be created before the modifier
! * value is changed so the event can store the preivous value!
*/
class Modifier::Event: public ogs::support::Event {
public:
Value getPreviousValue () const;
private:
! Value _value;
! Event (Modifier& modifier);
! friend void Modifier::setValue (Value value);
};
/**
+ * Create a new modifier event.
+ *
+ * @param modifier Modifier causing this event.
+ */
+ inline
+ Modifier::Event::Event (Modifier& modifier):
+ ogs::support::Event (modifier), _value (modifier.getValue ()) {
+ // empty constructor body
+ }
+
+ /**
* Determine previous value of this modifier.
*
* @return Previous value of this modifier.
*/
! inline Modifier::Value
! Modifier::Event::getPreviousValue () const {
! return (this->_value);
}
Index: Modifiers.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifiers.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Modifiers.cpp 25 Mar 2003 06:13:11 -0000 1.2
--- Modifiers.cpp 8 Apr 2003 21:43:10 -0000 1.3
***************
*** 21,24 ****
--- 21,25 ----
*/
+ #include "ogs/support/Event.h"
#include "ogs/core/Modifiers.h"
***************
*** 27,35 ****
/**
- * Create an empty list of modifiers.
- */
- Modifiers::Modifiers (): list (), value (0) { }
-
- /**
* Add a modifier to this list of modifiers. The total value is
* updated accordingly and observers are notified.
--- 28,31 ----
***************
*** 39,46 ****
void Modifiers::addModifier (Modifier& modifier) {
modifier.addObserver (*this);
! list.push_front (&modifier);
! Event event (*this);
! this->value += modifier.getValue ();
notifyObservers (event);
}
--- 35,42 ----
void Modifiers::addModifier (Modifier& modifier) {
modifier.addObserver (*this);
! this->_list.push_front (&modifier);
! Event event (*this, Event::ADDED, modifier);
! this->_value += modifier.getValue ();
notifyObservers (event);
}
***************
*** 54,61 ****
void Modifiers::removeModifier (Modifier& modifier) {
modifier.removeObserver (*this);
! list.remove (&modifier);
! Event event (*this);
! value -= modifier.getValue ();
notifyObservers (event);
}
--- 50,57 ----
void Modifiers::removeModifier (Modifier& modifier) {
modifier.removeObserver (*this);
! this->_list.remove (&modifier);
! Event event (*this, Event::REMOVED, modifier);
! this->_value -= modifier.getValue ();
notifyObservers (event);
}
***************
*** 68,80 ****
* @param event Event that occured.
*/
! void Modifiers::handleEvent (Event& event) {
try {
! Modifier::Event& modEvent = dynamic_cast<Modifier::Event&> (event);
Modifier& modifier = dynamic_cast<Modifier&> (event.getSource ());
! Event event (*this);
! this->value -= modEvent.getPreviousValue ();
! this->value += modifier.getValue ();
! notifyObservers (event);
} catch (...) {
// Observed object was not a modifier. Ignore it.
--- 64,81 ----
* @param event Event that occured.
*/
! void Modifiers::handleEvent (ogs::support::Event& event) {
try {
! Modifier::Event& oldEvent = dynamic_cast<Modifier::Event&> (event);
Modifier& modifier = dynamic_cast<Modifier&> (event.getSource ());
! /* The cached value is updated by subtracting the previous value of
! * the modifier that changed and then adding its new value. The
! * only other way to update the cached value would be to reset it to
! * zero (0), then add every modifier in the list.
! */
! Event newEvent (*this, Event::CHANGED, modifier);
! this->_value -= oldEvent.getPreviousValue ();
! this->_value += modifier.getValue ();
! notifyObservers (newEvent);
} catch (...) {
// Observed object was not a modifier. Ignore it.
Index: Modifiers.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifiers.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifiers.h 7 Jan 2003 07:41:33 -0000 1.1
--- Modifiers.h 8 Apr 2003 21:43:10 -0000 1.2
***************
*** 26,29 ****
--- 26,30 ----
# define OGS_CORE_MODIFIERS_H
+ # include <cassert>
# include <list>
***************
*** 35,43 ****
/**
! * A list of modifiers.
*/
class Modifiers: public ogs::support::Object,
public ogs::support::Observer {
public:
Modifiers ();
--- 36,54 ----
/**
! * A list of modifiers. A modifier list allows objects to observe a
! * single object rather than each modifier in the list. A modifier list
! * intercepts events caused by each modifier in the list. It also
! * generates its own events when a modifier is added or removed from the
! * list. In either case, the list updates a total value, cached
! * internally, and transmits an event to observers of the list. Note
! * that a modifier list behaves just like an STL list. If dynamically
! * allocated modifiers are added to it, they must be deallocated by the
! * caller.
*/
class Modifiers: public ogs::support::Object,
public ogs::support::Observer {
public:
+ class Event;
+
Modifiers ();
***************
*** 49,67 ****
void handleEvent (ogs::support::Event& event);
! protected:
typedef std::list<Modifier*> List;
! private:
! List list;
! Modifier::Value value;
};
/**
* Determine the total value of all modifiers in this list.
*
* @return Total value of all modifiers in this list.
*/
! inline Modifier::Value Modifiers::getValue () const {
! return (this->value);
}
--- 60,168 ----
void handleEvent (ogs::support::Event& event);
! private:
typedef std::list<Modifier*> List;
! List _list;
! Modifier::Value _value;
};
/**
+ * Create an empty list of modifiers.
+ */
+ inline
+ Modifiers::Modifiers ():
+ _list (), _value (0) {
+ // empty constructor body
+ }
+
+ /**
* Determine the total value of all modifiers in this list.
*
* @return Total value of all modifiers in this list.
*/
! inline Modifier::Value
! Modifiers::getValue () const {
! return (this->_value);
! }
!
! /**
! * An event that allows observers to determine the previous value of a
! * list of modifiers. Modifier list events must be created before the
! * list is changed so the event can store the preivous value!
! */
! class Modifiers::Event: public ogs::support::Event {
! public:
! /** The type of event that happened. */
! enum Type {
! /** A modifier was added to the list. */
! ADDED,
! /** A modifier was removed from the list. */
! REMOVED,
! /** The value of a modifier in the list changed. */
! CHANGED
! };
!
! Modifier::Value getPreviousValue () const;
! Type getType () const;
! Modifier& getModifier () const;
!
! private:
! Modifier::Value _value;
! Type _type;
! Modifier* _modifier;
!
! Event (Modifiers& modifiers, Type type, Modifier& modifier);
!
! friend void Modifiers::addModifier (Modifier& modifier);
! friend void Modifiers::removeModifier (Modifier& modifier);
! friend void Modifiers::handleEvent (ogs::support::Event& event);
! };
!
! /**
! * Create a new modifier list event.
! *
! * @param modifiers Modifier list causing this event.
! */
! inline
! Modifiers::Event::Event (Modifiers& modifiers,
! Type type,
! Modifier& modifier):
! ogs::support::Event (modifiers),
! _value (modifiers.getValue ()),
! _type (type),
! _modifier (&modifier) {
! // empty constructor body
! }
!
! /**
! * Determine previous value of this list of modifiers.
! *
! * @return Previous value of this list of modifiers.
! */
! inline Modifier::Value
! Modifiers::Event::getPreviousValue () const {
! return (this->_value);
! }
!
! /**
! * Determine the type of this event. A modifier list event has three
! * types: added, removed, or changed.
! *
! * @return Type of this event.
! */
! inline Modifiers::Event::Type
! Modifiers::Event::getType () const {
! return (this->_type);
! }
!
! /**
! * Determine the modifier described by the type of this event.
! *
! * @return Modifier described by the type of this event.
! */
! inline Modifier&
! Modifiers::Event::getModifier () const {
! assert (this->_modifier != NULL);
! return (*(this->_modifier));
}
|
|
From: <ele...@us...> - 2003-04-08 21:43:45
|
Update of /cvsroot/ogs/dist/c++/ogs/magic
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/ogs/magic
Modified Files:
Ability.cpp Ability.h
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
Index: Ability.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Ability.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Ability.cpp 25 Mar 2003 06:13:13 -0000 1.3
--- Ability.cpp 8 Apr 2003 21:43:10 -0000 1.4
***************
*** 33,39 ****
*/
Ability::SpellCounts
! Ability::getBonusSpells (ogs::core::Ability::Score score) {
SpellCounts spellCounts;
- Modifier::Value modifier = ogs::core::Ability::getModifier (score);
for (int spellLevel = 1; spellLevel < 10; ++spellLevel) {
--- 33,38 ----
*/
Ability::SpellCounts
! Ability::getBonusSpells (ogs::core::Modifier::Value modifier) {
SpellCounts spellCounts;
for (int spellLevel = 1; spellLevel < 10; ++spellLevel) {
Index: Ability.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Ability.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Ability.h 5 Feb 2003 06:01:28 -0000 1.2
--- Ability.h 8 Apr 2003 21:43:11 -0000 1.3
***************
*** 29,32 ****
--- 29,33 ----
# include <ogs/core/Ability.h>
+ # include <ogs/core/Modifier.h>
# include <ogs/magic/Namespace.h>
***************
*** 58,63 ****
protected:
! static int getHighestSpellLevel (ogs::core::Ability::Score score);
! static SpellCounts getBonusSpells (ogs::core::Ability::Score score);
};
--- 59,64 ----
protected:
! static int getHighestSpellLevel (ogs::core::Ability::Score);
! static SpellCounts getBonusSpells (ogs::core::Modifier::Value);
};
|
|
From: <ele...@us...> - 2003-04-08 21:43:41
|
Update of /cvsroot/ogs/dist/c++/ogs/cclasses
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/ogs/cclasses
Modified Files:
Paladin.cpp
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
Index: Paladin.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Paladin.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Paladin.cpp 29 Mar 2003 02:10:26 -0000 1.3
--- Paladin.cpp 8 Apr 2003 21:43:05 -0000 1.4
***************
*** 34,37 ****
--- 34,38 ----
using ogs::core::Abilities;
using ogs::core::Ability;
+ using ogs::core::AbilityPtr;
using ogs::core::Character;
using ogs::core::Creature;
***************
*** 106,111 ****
Creature& creature = character.getCreature ();
Abilities& abilities = creature.getAbilities ();
! Ability* cha = abilities [Ability::CHA];
! if (cha != NULL) {
Modifier& modifier = cha->getModifier ();
if (modifier.getValue () > 0) {
--- 107,112 ----
Creature& creature = character.getCreature ();
Abilities& abilities = creature.getAbilities ();
! AbilityPtr cha = abilities [Ability::CHA];
! if (cha) {
Modifier& modifier = cha->getModifier ();
if (modifier.getValue () > 0) {
***************
*** 141,146 ****
Creature& creature = character.getCreature ();
Abilities& abilities = creature.getAbilities ();
! Ability* cha = abilities [Ability::CHA];
! if (cha != NULL) {
Modifier& modifier = cha->getModifier ();
Saves& saves = creature.getSaves ();
--- 142,147 ----
Creature& creature = character.getCreature ();
Abilities& abilities = creature.getAbilities ();
! AbilityPtr cha = abilities [Ability::CHA];
! if (cha) {
Modifier& modifier = cha->getModifier ();
Saves& saves = creature.getSaves ();
|
|
From: <ele...@us...> - 2003-04-08 21:43:38
|
Update of /cvsroot/ogs/dist/c++ In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++ Modified Files: ChangeLog README configure.in Log Message: See C++ ChangeLog (Apr 5 and 8) for details. Index: ChangeLog =================================================================== RCS file: /cvsroot/ogs/dist/c++/ChangeLog,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ChangeLog 4 Apr 2003 20:22:39 -0000 1.15 --- ChangeLog 8 Apr 2003 21:43:04 -0000 1.16 *************** *** 1,3 **** --- 1,35 ---- + Tue Apr 8 19:59:15 UTC 2003 Eric Lemings <ele...@us...> + + * ogs/core/Modifiers.*: Added event type and modifier to event. + + * ogs/core/Ability.*: Added direct method. + + * test/Makefile.am, test/*.cpp: Renamed and updated a few test + drivers. + + Sat Apr 5 12:22:54 UTC 2003 Eric Lemings <ele...@us...> + + * README, configure.in: Require Boost C++ Library. + + * ogs/support/Event.*: Minor updates. + + * ogs/core/Ability.*: Removed current score member. Made static + getModifier() function private. Moved method definitions after + Ability class and replaced them with forward declarations. + + * ogs/core/Abilities.*: Using smart pointers to hold ability + scores. Added partial method for creating partial abilities. + + * ogs/core/Modifier.*: Minor updates (documentation, naming, etc.) + * ogs/core/Modifiers.*: Inlined constructor. Added modifiers + event class to store previous list value. + + * ogs/core/Creature.cpp, ogs/core/Character.cpp, + ogs/cclasses/Paladin.cpp: Changed pointer to shared pointer. + + * ogs/magic/Ability.h (getBonusSpells), ogs/magic/abilities/*.h: + Changed score parameter to modifier value. + Thu Apr 3 22:35:57 UTC 2003 Eric Lemings <ele...@us...> *************** *** 17,31 **** * ogs/core/Feat.h: Moved findFeat() template from source file. - * ogs/cclasses/*.h: Added constructors. Update docs. - * ogs/creatures/humanoids/*.h: Remove starting ages. - * ogs/feats/AllWeapons.*: Inlined factory methods. - * ogs/feats/ArmorProficiency.cpp: Optimizations. - * ogs/magic/Spell.h: Removed static descriptors member. - * ogs/test/CoreTest03.cpp: Updated for ability interface changes. --- 49,57 ---- Index: README =================================================================== RCS file: /cvsroot/ogs/dist/c++/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README 4 Mar 2003 08:19:57 -0000 1.3 --- README 8 Apr 2003 21:43:04 -0000 1.4 *************** *** 7,11 **** it. ! * An ISO/ANSI C++ compiler (such as GCC 3.2 or higher) To generate the API Reference documentation, you will also need the --- 7,14 ---- it. ! * An ISO/ANSI C++ compiler. ! * The Boost C++ Library. ! ! The Boost C++ Library is available from wwww.boost.org. To generate the API Reference documentation, you will also need the *************** *** 14,18 **** * Doxygen (version 1.2.18 or higher) ! The API Reference documentation may be generated using the 'make doc' ! command after configuring the package. --- 17,22 ---- * Doxygen (version 1.2.18 or higher) ! Doxygen is available from www.doxygen.org. The API Reference ! documentation may be generated using the 'make doc' command after ! configuring the package. Index: configure.in =================================================================== RCS file: /cvsroot/ogs/dist/c++/configure.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** configure.in 4 Apr 2003 20:22:40 -0000 1.11 --- configure.in 8 Apr 2003 21:43:05 -0000 1.12 *************** *** 92,95 **** --- 92,100 ---- fi + dnl Checks for header files. + AC_CHECK_HEADER(boost/version.hpp,, AC_MSG_ERROR([ + The Boost C++ Library is required to build this software. + Download the library from the www.boost.org website.])) + dnl Checks for system services. ALL_LINGUAS="" |
|
From: <ele...@us...> - 2003-04-08 21:43:25
|
Update of /cvsroot/ogs/dist/c++/test
In directory sc8-pr-cvs1:/tmp/cvs-serv21226/c++/test
Modified Files:
Makefile.am
Added Files:
AbilitiesTest.cpp DieTest.cpp ModifiersTest.cpp
SupportTest.cpp
Removed Files:
CoreTest01.cpp CoreTest02.cpp CoreTest03.cpp SupportTest01.cpp
SupportTest02.cpp
Log Message:
See C++ ChangeLog (Apr 5 and 8) for details.
--- NEW FILE: AbilitiesTest.cpp ---
/*
* AbilitiesTest.cpp -- test driver for ability scores
* Copyright (C) 2002 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: AbilitiesTest.cpp,v 1.1 2003/04/08 21:43:15 elemings Exp $
*/
// Need to add configure checks before using <mcheck.h> and mtrace().
//#include <mcheck.h>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <ogs/Support.h>
#include <ogs/core/Ability.h>
#include <ogs/core/Abilities.h>
#include <ogs/core/Modifier.h>
#include <ogs/core/Modifiers.h>
#include <ogs/core/Strength.h>
using std::cout;
using std::endl;
using namespace ogs::support;
using ogs::core::Ability;
using ogs::core::Abilities;
using ogs::core::Modifier;
using ogs::core::Modifiers;
using ogs::core::Strength;
#define TEST_DRIVER "AbilitiesTest"
/**
* An object that observes ability scores.
*/
class Foo: public Observer {
public:
void handleEvent (Event& event);
};
void Foo::handleEvent (Event& event) {
cout << "Handling event: " << event.toString () << endl;
try {
Ability& ability = dynamic_cast<Ability&> (event.getSource ());
cout << "ability.getCurrentScore () = "
<< ability.getCurrentScore () << endl;
} catch (...) {
// Ignore it.
}
}
/**
* Display the distribution of N scores for a random method. Random
* methods are like the predefined methods in the Ability class. They
* generate scores by rolling dice.
*/
template <int N>
void printDistribution (Ability::Method& method, char* name) {
Ability::Score minimumScore = 1;
Ability::Score maximumScore = 20;
std::vector<Ability::Score> scores (maximumScore);
cout << "Rolling " << name << " method " << N;
cout << " times (X = 10 rolls):" << endl;
for (int i = 0; i < N; ++i) {
scores [method (Ability::CHA) - 1]++;
}
for (int i = minimumScore - 1; i < maximumScore; ++i) {
if (scores [i] > 0) {
cout.width (2);
cout.fill (' ');
cout << i+1 << ": ";
cout.width (scores [i] / 10);
cout.fill ('X');
cout << "";
cout.width (0);
cout.fill (' ');
cout << " (" << scores [i] << ")" << endl;
}
}
cout << endl;
}
void testAbility () {
cout << "sizeof (Ability) = " << sizeof (Ability) << endl;
// In practice, this would require a cast but ya never know...
Ability::Type type = Ability::Type (0);
assert (! Ability::isValidType (type));
try {
Ability ability (type);
} catch (std::exception& e) {
cout << e.what () << endl;
}
Ability ability (Ability::CHA);
Ability::Score score = ability.getOriginalScore ();
cout << "ability.getOriginaScore () = " << score << endl;
cout << "ability.getCurrentScore () = "
<< ability.getCurrentScore () << endl;
// A new ability score has no score modifiers.
assert (ability.getOriginalScore () == ability.getCurrentScore ());
Modifier& modifier = ability.getModifier ();
cout << "&modifier = " << &modifier << endl;
cout << "modifier.getValue () = "
<< modifier.getValue () << endl;
Modifiers& modifiers = ability.getModifiers ();
Modifier array [10] = {
Modifier (-2), Modifier (+4), Modifier (+1), Modifier (),
Modifier (-1), Modifier (+5), Modifier (+2), Modifier (-3),
Modifier (+1), Modifier (0)
};
modifiers.addModifier (array [0]);
modifiers.addModifier (array [1]);
modifiers.addModifier (array [2]);
modifiers.addModifier (array [3]);
modifiers.addModifier (array [4]);
modifiers.addModifier (array [5]);
modifiers.addModifier (array [6]);
modifiers.addModifier (array [7]);
assert (ability.getCurrentScore () == score + 6);
cout << "ability.getCurrentScore () = "
<< ability.getCurrentScore () << endl;
cout << "modifier.getValue () = "
<< modifier.getValue () << endl;
Foo foo;
cout << "&foo = " << &foo << endl;
ability.addObserver (foo);
modifiers.addModifier (array [8]);
modifiers.addModifier (array [9]);
assert (ability.getCurrentScore () == score + 7);
modifiers.removeModifier (array [5]); // remove +5
modifiers.removeModifier (array [3]); // remove 0
assert (ability.getCurrentScore () == score + 2);
(array [8]).setValue (-4); // change +1 to -4
assert (ability.getCurrentScore () == score - 3);
(array [9]).setValue (+10); // change 0 to +10
assert (ability.getCurrentScore () == score + 7);
cout << endl;
}
void testStrength () {
Ability::DirectMethod directMethod (1);
Strength str (directMethod);
Modifier modifier;
(str.getModifiers ()).addModifier (modifier);
cout.width (10);
cout << "Strength";
cout.width (0);
cout << "\tLight\tMedium\tHeavy" << endl;
for (Modifier::Value value = 0; value < 50; value += 2) {
modifier.setValue (value);
cout.width (10);
cout << str.getCurrentScore () << "\t";
cout << str.getLightLoad () << "\t";
cout << str.getMediumLoad () << "\t";
cout << str.getHeavyLoad () << endl;
}
cout.width (0);
cout << endl;
}
void testPartialAbilities () {
Abilities::PartialMethod::Value dex (Ability::DEX, 16);
Abilities::PartialMethod::Value intl (Ability::INT, 14);
Abilities::PartialMethod::Value wis (Ability::WIS, 14);
Abilities::PartialMethod::Value cha (Ability::CHA, 15);
Abilities::PartialMethod::Value values [] = { dex, intl, wis, cha };
/*
Abilities::PartialMethod partialMethod (& values [0], & values [3]);
Abilities wraithAbilities (partialMethod);
assert (! wraithAbilities [Ability::STR]);
assert (wraithAbilities [Ability::DEX]);
assert (wraithAbilities [Ability::DEX]->getCurrentScore () == 16);
assert (! wraithAbilities [Ability::CON]);
assert (wraithAbilities [Ability::INT]);
assert (wraithAbilities [Ability::INT]->getCurrentScore () == 14);
assert (wraithAbilities [Ability::WIS]);
assert (wraithAbilities [Ability::WIS]->getCurrentScore () == 14);
assert (wraithAbilities [Ability::CHA]);
assert (wraithAbilities [Ability::CHA]->getCurrentScore () == 15);
*/
cout << endl;
}
/**
* Run various tests on ability scores.
*/
int main (void) {
//mtrace ();
cout << "BEGIN: " TEST_DRIVER "\n\n";
// Seed random number generator with current time.
std::srand (std::time (NULL));
Ability::StandardMethod standard;
printDistribution<1000> (standard, "standard");
Ability::AverageMethod average;
printDistribution<1000> (average, "average");
Ability::HighPoweredMethod highPowered;
printDistribution<1000> (highPowered, "high-powered");
testAbility ();
testStrength ();
testPartialAbilities ();
cout << "END: " TEST_DRIVER "\n";
//muntrace ();
return (0);
}
--- NEW FILE: DieTest.cpp ---
/*
* DieTest.cpp -- test driver for polyhedral dice
* Copyright (C) 2002 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: DieTest.cpp,v 1.1 2003/04/08 21:43:17 elemings Exp $
*/
// Need to add configure checks before using <mcheck.h> and mtrace().
// //#include <mcheck.h>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>
#include <ogs/core/Die.h>
using std::cout;
using std::endl;
using ogs::core::Die;
#define TEST_DRIVER "DieTest"
/**
* Display the distribution of N die rolls.
*/
template <int N>
void printDistribution (Die::Sides sides = Die::d20,
Die::Count count = 1,
Die::Modifier modifier = 0) {
Die::Value minimumRoll = count + modifier;
Die::Value maximumRoll = (sides * count) + modifier;
std::vector<Die::Value> values (maximumRoll);
cout << "Rolling " << count << "d" << sides;
cout << std::showpos << modifier << std::noshowpos << " ";
cout << N << " times (X = 10 rolls):" << endl;
for (int i = 0; i < N; ++i) {
values [Die::roll (sides, count, modifier) - 1]++;
}
for (int i = minimumRoll - 1; i < maximumRoll; ++i) {
cout.width (2);
cout.fill (' ');
cout << i+1 << ": ";
cout.width (values [i] / 10);
cout.fill ('X');
cout << "";
cout.width (0);
cout.fill (' ');
cout << " (" << values [i] << ")" << endl;
}
cout << endl;
}
void testDie () {
cout << "sizeof (Die) = " << sizeof (Die) << endl;
Die die;
assert (die.getSides () == Die::d20);
assert (die.getCount () == 1);
assert (die.getModifier () == 0);
assert (die.getMinimumValue () == 1);
assert (die.getMaximumValue () == 20);
Die::Value value = die.getValue ();
assert (value >= 1 && value <= 20);
cout << "die.getValue () = " << value << endl;
die.setSides (Die::d12);
assert (die.getSides () == Die::d12);
assert (die.getMinimumValue () == 1);
assert (die.getMaximumValue () == 12);
value = die.getValue ();
assert (value >= 1 && value <= 12);
cout << "die.getValue () = " << value << endl;
die.setCount (2);
assert (die.getCount () == 2);
assert (die.getMinimumValue () == 2);
assert (die.getMaximumValue () == 24);
value = die.getValue ();
assert (value >= 2 && value <= 24);
cout << "die.getValue () = " << value << endl;
die.setModifier (8);
assert (die.getModifier () == 8);
assert (die.getMinimumValue () == 10);
assert (die.getMaximumValue () == 32);
value = die.getValue ();
assert (value >= 10 && value <= 32);
cout << "die.getValue () = " << value << endl;
// The sides, count, and modifier of a const die can't change but it
// can still be rolled.
const Die& constDie = die;
cout << "Printing 10 rolls of 2d12+8: ";
for (int i = 0; i < 10; ++i) {
value = constDie.rollValue ();
assert (value >= 10 && value <= 32);
cout << value << " ";
}
cout << "\n\n";
}
/**
* Run various tests on polyhedral die.
*/
int main (void) {
//mtrace ();
cout << "BEGIN: " TEST_DRIVER "\n\n";
// Seed random number generator with current time.
std::srand (std::time (NULL));
printDistribution<10000> ();
printDistribution<1000> (Die::d6, 3);
printDistribution<1000> (Die::d4, 4, +4);
testDie ();
cout << "END: " TEST_DRIVER "\n";
//muntrace ();
return (0);
}
--- NEW FILE: ModifiersTest.cpp ---
/*
* ModifiersTest.cpp -- test driver for modifiers
* Copyright (C) 2002 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: ModifiersTest.cpp,v 1.1 2003/04/08 21:43:18 elemings Exp $
*/
// Need to add configure checks before using <mcheck.h> and mtrace().
//#include <mcheck.h>
#include <cassert>
#include <iostream>
#include <ogs/Support.h>
#include <ogs/core/Modifier.h>
#include <ogs/core/Modifiers.h>
using std::cout;
using std::endl;
using namespace ogs::support;
using ogs::core::Modifier;
using ogs::core::Modifiers;
#define TEST_DRIVER "ModifiersTest"
/**
* An object that observers modifiers.
*/
class Foo: public Observer {
public:
void handleEvent (Event& event);
};
extern void
Foo::handleEvent (Event& event) {
cout << "this = " << this << endl;;
cout << "Handling event: " << event.toString () << endl;
Modifier::Event& modEvent = dynamic_cast<Modifier::Event&> (event);
cout << "modEvent.getPreviousValue () = " <<
modEvent.getPreviousValue () << endl;
Modifier& modifier = dynamic_cast<Modifier&> (event.getSource ());
cout << "modifier.getValue () = " << modifier.getValue () << endl;
}
/**
* An object that observers modifier lists. The Foo class could observe
* both modifiers and modifier lists but in practice this probably won't
* happen.
*/
class Bar: public Observer {
public:
void handleEvent (Event& event);
};
extern void
Bar::handleEvent (Event& event) {
cout << "this = " << this << endl;;
cout << "Handling event: " << event.toString () << endl;
Modifiers::Event& modEvent = dynamic_cast<Modifiers::Event&> (event);
cout << "modEvent.getPreviousValue () = "
<< modEvent.getPreviousValue () << endl;
Modifiers::Event::Type type = modEvent.getType ();
assert (type == Modifiers::Event::ADDED ||
type == Modifiers::Event::REMOVED ||
type == Modifiers::Event::CHANGED);
cout << "modEvent.getType () = "
<< (type == Modifiers::Event::ADDED? "ADDED":
type == Modifiers::Event::REMOVED? "REMOVED": "CHANGED")
<< endl;
Modifier& modifier = modEvent.getModifier ();
cout << "modEvent.getModifier () = " << &modifier << endl;
Modifiers& modifiers = dynamic_cast<Modifiers&> (event.getSource ());
cout << "modifiers.getValue () = " << modifiers.getValue () << endl;
}
void testModifier () {
cout << "sizeof (Modifier) = " << sizeof (Modifier) << endl;
Modifier mod1;
cout << "&mod1 = " << &mod1 << endl;
cout << "mod1.toString () = " << mod1.toString () << endl;
assert (mod1.getValue () == 0);
cout << "mod1.getValue () = " << mod1.getValue () << endl;
Modifier mod2 (+2);
cout << "&mod1 = " << &mod2 << endl;
cout << "mod2.toString () = " << mod2.toString () << endl;
assert (mod2.getValue () == 2);
cout << "mod2.getValue () = " << mod2.getValue () << endl;
Foo foo;
cout << "&foo = " << &foo << endl;
mod1.addObserver (foo);
mod1.setValue (-1);
assert (mod1.getValue () == -1);
mod2.addObserver (foo);
mod2.setValue (+4);
assert (mod2.getValue () == 4);
cout << endl;
}
void testModifiers () {
// Let's pretend these modifiers are components scattered across
// several different objects and that they have many different values..
Modifier array [10] = {
Modifier (-2), Modifier (+4), Modifier (+1), Modifier (),
Modifier (-1), Modifier (+5), Modifier (+2), Modifier (-3),
Modifier (+1), Modifier (0)
};
Modifiers modifiers;
cout << "&modifiers = " << &modifiers << endl;
assert (modifiers.getValue () == 0);
cout << "modifiers.getValue () = " << modifiers.getValue ()
<< endl;
modifiers.addModifier (array [0]);
modifiers.addModifier (array [1]);
modifiers.addModifier (array [2]);
modifiers.addModifier (array [3]);
modifiers.addModifier (array [4]);
modifiers.addModifier (array [5]);
modifiers.addModifier (array [6]);
modifiers.addModifier (array [7]);
assert (modifiers.getValue () == 6);
cout << "modifiers.getValue () = " << modifiers.getValue ()
<< endl;
Bar bar;
cout << "&bar = " << &bar << endl;
modifiers.addObserver (bar);
modifiers.addModifier (array [8]);
modifiers.addModifier (array [9]);
assert (modifiers.getValue () == 7);
modifiers.removeModifier (array [5]); // remove +5
modifiers.removeModifier (array [3]); // remove 0
assert (modifiers.getValue () == 2);
(array [8]).setValue (-4); // change +1 to -4
assert (modifiers.getValue () == -3);
(array [2]).setValue (+10); // change +1 to +10
assert (modifiers.getValue () == 6);
cout << endl;
}
/**
* Run various tests on modifiers.
*/
int main (void)
{
//mtrace ();
cout << "BEGIN: " TEST_DRIVER "\n\n";
testModifier ();
testModifiers ();
cout << "END: " TEST_DRIVER "\n";
//muntrace ();
return (0);
}
--- NEW FILE: SupportTest.cpp ---
/*
* SupportTest.cpp -- test driver for library support
* Copyright (C) 2002 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: SupportTest.cpp,v 1.1 2003/04/08 21:43:19 elemings Exp $
*/
// Need to add configure checks before using <mcheck.h> and mtrace().
//#include <mcheck.h>
#include <cassert>
#include <iostream>
#include <string>
#include <ogs/Support.h>
using std::cout;
using std::endl;
using std::string;
using namespace ogs::support;
#define TEST_DRIVER "SupportTest"
/**
* Foo is a simple object class with one simple name attribute and an
* event for notifying observers of changes to this name.
*/
class Foo: public Object {
public:
class Event;
Foo (const string& name = "");
string getName () const;
void setName (string name);
private:
string _name;
};
/**
* An event that provides observers of Foo objects with the previous
* name. Note that the constructor is private: Foo events can only
* be created by the Foo::setName() function. Foo events must be
* created before the name is actually changed!
*/
class Foo::Event: public ogs::support::Event {
public:
string getPreviousName () const;
private:
string _name;
Event (Foo& foo);
friend void Foo::setName (string name);
};
inline Foo::Foo (const string& name):
Object (), _name (name) {
// empty constructor body
}
inline string
Foo::getName () const {
return (this->_name);
}
extern void
Foo::setName (string name) {
Event event (*this);
this->_name = name;
notifyObservers (event);
}
inline Foo::Event::Event (Foo& foo):
ogs::support::Event (foo), _name (foo.getName ()) {
// empty constructor body
}
inline string
Foo::Event::getPreviousName () const {
return (this->_name);
}
OGS_BEGIN_SUPPORT_NAMESPACE
/**
* An object that observers Foo objects. Note that this class is in the
* ogs::support namespace. Yeah, it's ludicrous but it's just to check
* the compiler for namespace support.
*/
class Bar: public Observer {
public:
void handleEvent (Event& event);
};
extern void
Bar::handleEvent (Event& event) {
cout << "this = " << this << endl;;
cout << "Handling event: " << event.toString () << endl;
Foo::Event& fooEvent = dynamic_cast<Foo::Event&> (event);
cout << "fooEvent.getPreviousName () = \"" <<
fooEvent.getPreviousName () << "\"" << endl;
Foo& foo = dynamic_cast<Foo&> (event.getSource ());
cout << "foo.getName () = " << foo.getName () << endl;
}
OGS_END_SUPPORT_NAMESPACE
/**
* Test the Object and Class classes.
*/
void testObjectClass () {
Foo foo;
cout << "foo = " << &foo << endl;
cout << "sizeof (foo) = " << sizeof (foo) << endl;
cout << "foo.toString () = " << foo.toString () << endl;
cout << "foo.getName () = \"" << foo.getName () << "\"\n";
//ogs::support::Class cls; // Error: private constructor
Class fooCls = foo.getClass (); // operator=
cout << "fooCls = " << &fooCls << endl;
cout << "sizeof (fooCls) = " << sizeof (fooCls) << endl;
cout << "fooCls.getName () = " << fooCls.getName () << endl;
Foo bigFoo;
Class bigCls (bigFoo.getClass ()); // copy constructor
cout << "bigCls = " << &bigCls << endl;
cout << "bigCls.getName () = " << bigCls.getName () << endl;
assert (fooCls == bigCls); // operator==
cout << endl;
}
/**
* Test the Event and Observer cclasses.
*/
void testEventObserver () {
Foo foo;
cout << "&foo = " << &foo << endl;
Bar obs1;
cout << "&obs1 = " << &obs1 << endl;
foo.addObserver (obs1);
Bar obs2;
cout << "&obs2 = " << &obs2 << endl;
foo.addObserver (obs2);
// Trigger event.
foo.setName ("first name");
foo.removeObserver (obs1);
foo.setName ("second name");
cout << endl;
}
/**
* Test the Library Support classes.
*/
int main (void) {
//mtrace ();
cout << "BEGIN: " TEST_DRIVER "\n\n";
testObjectClass ();
testEventObserver ();
cout << "END: " TEST_DRIVER "\n";
//muntrace ();
return (0);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/test/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am 8 Mar 2003 01:08:51 -0000 1.3
--- Makefile.am 8 Apr 2003 21:43:18 -0000 1.4
***************
*** 33,53 ****
# These programs are not built until the check target is run.
check_PROGRAMS = \
! SupportTest01 \
! SupportTest02 \
! CoreTest01 \
! CoreTest02 \
! CoreTest03 \
CombatTest01
! SupportTest01_SOURCES = \
! SupportTest01.cpp
! SupportTest02_SOURCES = \
! SupportTest02.cpp
! CoreTest01_SOURCES = \
! CoreTest01.cpp
! CoreTest02_SOURCES = \
! CoreTest02.cpp
! CoreTest03_SOURCES = \
! CoreTest03.cpp
CombatTest01_SOURCES = \
CombatTest01.cpp
--- 33,50 ----
# These programs are not built until the check target is run.
check_PROGRAMS = \
! SupportTest \
! ModifiersTest \
! DieTest \
! AbilitiesTest \
CombatTest01
! SupportTest_SOURCES = \
! SupportTest.cpp
! ModifiersTest_SOURCES = \
! ModifiersTest.cpp
! DieTest_SOURCES = \
! DieTest.cpp
! AbilitiesTest_SOURCES = \
! AbilitiesTest.cpp
CombatTest01_SOURCES = \
CombatTest01.cpp
--- CoreTest01.cpp DELETED ---
--- CoreTest02.cpp DELETED ---
--- CoreTest03.cpp DELETED ---
--- SupportTest01.cpp DELETED ---
--- SupportTest02.cpp DELETED ---
|
|
From: <ele...@us...> - 2003-04-08 20:00:54
|
Update of /cvsroot/ogs/dist/c In directory sc8-pr-cvs1:/tmp/cvs-serv5652 Modified Files: configure.in Log Message: Changed "AC_CHECK_HEADERS(stdbool.h)" to "AC_HEADER_STDBOOL". Index: configure.in =================================================================== RCS file: /cvsroot/ogs/dist/c/configure.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** configure.in 4 Apr 2003 20:22:39 -0000 1.8 --- configure.in 8 Apr 2003 20:00:49 -0000 1.9 *************** *** 105,109 **** AC_HEADER_STDC AC_HEADER_STDINT ! AC_CHECK_HEADERS(stdbool.h) dnl Checks for typedefs. --- 105,109 ---- AC_HEADER_STDC AC_HEADER_STDINT ! AC_HEADER_STDBOOL dnl Checks for typedefs. |
|
From: <ele...@us...> - 2003-04-04 20:38:10
|
Update of /cvsroot/ogs/dist/java/ogs/spells/conjurations
In directory sc8-pr-cvs1:/tmp/cvs-serv9450/java/ogs/spells/conjurations
Added Files:
CureWounds.java package.html
Log Message:
See ChangeLog files (Apr 3-4) for details.
--- NEW FILE: CureWounds.java ---
/*
* CureWounds.java -- class declaration for cure wounds spells
* 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: CureWounds.java,v 1.1 2003/04/04 20:22:59 elemings Exp $
*/
package ogs.spells.conjurations;
import java.util.Vector;
import ogs.core.Creature;
import ogs.magic.Component;
import ogs.magic.Range;
import ogs.magic.School;
import ogs.magic.Subschool;
import ogs.spells.Conjuration;
/**
* A spell that heals damage to living creatures. Cure wounds spells
* have the opposite effect on undead creatures: the spell causes damage
* to undead creatures instead of curing it. Cure wounds spells can
* have different degrees. The degree of the spell determines how much
* damage is healed (or dealt in the case of undead creatures).
*/
public class CureWounds extends Conjuration {
private byte casterLevel;
private Creature target;
private byte degree;
/** Cures 1 point of damage. */
public static final byte MINOR = 1;
/**
* Cures 1d8 points of damage plus 1 per caster level (up to 5).
*/
public static final byte LIGHT = 2;
/**
* Cures 2d8 points of damage plus 1 per caster level (up to 10).
*/
public static final byte MODERATE = 3;
/**
* Cures 3d8 points of damage plus 1 per caster level (up to 15).
*/
public static final byte SERIOUS = 4;
/**
* Cures 4d8 points of damage plus 1 per caster level (up to 20).
*/
public static final byte CRITICAL = 5;
/**
* Create a new Cure Minor Wounds spell.
*
* @param casterLevel Level of caster.
* @return A new Cure Minor Wounds spell.
*/
public CureWounds createMinor (byte casterLevel) {
return (new CureWounds (casterLevel, MINOR));
}
/**
* Create a new Cure Light Wounds spell.
*
* @param casterLevel Level of caster.
* @return A new Cure Light Wounds spell.
*/
public CureWounds createLight (byte casterLevel) {
return (new CureWounds (casterLevel, LIGHT));
}
/**
* Create a new Cure Moderate Wounds spell.
*
* @param casterLevel Level of caster.
* @return A new Cure Moderate Wounds spell.
*/
public CureWounds createModerate (byte casterLevel) {
return (new CureWounds (casterLevel, MODERATE));
}
/**
* Create a new Cure Serious Wounds spell.
*
* @param casterLevel Level of caster.
* @return A new Cure Serious Wounds spell.
*/
public CureWounds createSerious (byte casterLevel) {
return (new CureWounds (casterLevel, SERIOUS));
}
/**
* Create a new Cure Critical Wounds spell.
*
* @param casterLevel Level of caster.
* @return A new Cure Critical Wounds spell.
*/
public CureWounds createCritical (byte casterLevel) {
return (new CureWounds (casterLevel, CRITICAL));
}
/**
* Create a new cure wounds spell.
*
* @param casterLevel Level of caster.
* @param degree Degree of cure wounds spell.
*/
private CureWounds (byte casterLevel, byte degree) {
this.casterLevel = casterLevel;
this.target = null;
this.degree = degree;
}
/**
* Determine the school (or subschool) for this type of spell. All
* cure wounds spells are in the Healing subschool of the Conjuration
* school.
*
* @return Healing subshool of the Conjuration school.
*/
public School getSchool () {
return (new Subschool (Subschool.HEALING));
}
/**
* Determine the components needed to cast this spell. The components
* of a cure wounds spell are normally verbal and somantic. Silence
* Spell and Still spell feats however may negate one or both of these
* components.
*
* @return Array of components for this spell.
*/
public Vector getComponents () {
Vector components = new Vector ();
// TODO: Determine if Silence or Still metamagic feats apply.
components.add (Component.Verbal ());
components.add (Component.Somantic());
return (components);
}
/**
* Determine the range of this spell. Cure wounds spells always have
* touch range.
*
* @return Touch range.
*/
public Range getRange () {
return (Range.Touch ());
}
/**
* Determine the target of this spell. The target of this spell is
* the entity that will be healed (or damaged). If the entity is not
* a creature, the spell does nothing. If the spell does not yet have
* a target, the function returns NULL.
*
* @return Target of spell or NULL if spell is not targeted.
*/
public Creature getTarget () {
return (this.target);
}
/**
* Determine the degree of this cure wounds spell.
*
* #return Degree of cure wounds spell.
*/
public byte getDegree () {
return (this.degree);
}
/**
* Cast this spell. When a cure wounds spell is cast, this function
* first checks to see if there is a target. If there is not target,
* nothing happens. (In other words, this function does nothing).
* Otherwise, the target is checked to see if it is a creature. If
* the target is not a creature, nothing happens. If the target is a
* creature, this function rolls a random number of hit points
* according to the degree of spell. Next, the creature is checked to
* see if it is undead. If it is, a Will save is rolled for the
* undead creature. If the save fails, the points are subtracted from
* the current hit points of the undead creature. If the creature is
* not undead, the points are added to the current hit points of the
* creature (up to its maximum points).
*/
public void castSpell () {
// TODO: Translate C++ implementation.
}
}
--- NEW FILE: package.html ---
<HTML>
<HEAD>
<TITLE>ogs.spells.conjurations (Open Gaming System)</TITLE>
</HEAD>
<BODY>
A collection of common Conjuration spells.
</BODY>
</HTML>
|
|
From: <ele...@us...> - 2003-04-04 20:38:09
|
Update of /cvsroot/ogs/dist/java/ogs/skills
In directory sc8-pr-cvs1:/tmp/cvs-serv9450/java/ogs/skills
Modified Files:
Diplomacy.java Spot.java
Log Message:
See ChangeLog files (Apr 3-4) for details.
Index: Diplomacy.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/skills/Diplomacy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Diplomacy.java 27 Feb 2003 01:24:45 -0000 1.2
--- Diplomacy.java 4 Apr 2003 20:22:57 -0000 1.3
***************
*** 23,29 ****
package ogs.skills;
import ogs.core.Modifier;
import ogs.core.Skill;
- import ogs.core.abilities.Charisma;
/**
--- 23,29 ----
package ogs.skills;
+ import ogs.core.Ability;
import ogs.core.Modifier;
import ogs.core.Skill;
/**
***************
*** 45,50 ****
* @return Charisma.class
*/
! public Class getKeyAbility () {
! return (Charisma.class);
}
--- 45,50 ----
* @return Charisma.class
*/
! public int getKeyAbility () {
! return (Ability.CHA);
}
Index: Spot.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/skills/Spot.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Spot.java 27 Feb 2003 01:24:45 -0000 1.2
--- Spot.java 4 Apr 2003 20:22:57 -0000 1.3
***************
*** 23,30 ****
package ogs.skills;
import ogs.core.Modifier;
import ogs.core.Modifiers;
import ogs.core.Skill;
- import ogs.core.abilities.Wisdom;
/**
--- 23,30 ----
package ogs.skills;
+ import ogs.core.Ability;
import ogs.core.Modifier;
import ogs.core.Modifiers;
import ogs.core.Skill;
/**
***************
*** 51,56 ****
* @return Wisdom.class
*/
! public Class getKeyAbility () {
! return (Wisdom.class);
}
--- 51,56 ----
* @return Wisdom.class
*/
! public int getKeyAbility () {
! return (Ability.WIS);
}
|
|
From: <ele...@us...> - 2003-04-04 20:38:09
|
Update of /cvsroot/ogs/dist/java/ogs/magic/abilities
In directory sc8-pr-cvs1:/tmp/cvs-serv9450/java/ogs/magic/abilities
Modified Files:
Charisma.java Intelligence.java Wisdom.java
Log Message:
See ChangeLog files (Apr 3-4) for details.
Index: Charisma.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/magic/abilities/Charisma.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Charisma.java 27 Feb 2003 01:24:44 -0000 1.2
--- Charisma.java 4 Apr 2003 20:22:56 -0000 1.3
***************
*** 23,27 ****
package ogs.magic.abilities;
! import ogs.magic.Ability;
import ogs.magic.abilities.Utility;
--- 23,27 ----
package ogs.magic.abilities;
! import ogs.core.Ability;
import ogs.magic.abilities.Utility;
***************
*** 31,36 ****
*/
public class Charisma
! extends ogs.core.abilities.Charisma
implements ogs.magic.Ability {
/**
--- 31,43 ----
*/
public class Charisma
! extends ogs.core.Ability
implements ogs.magic.Ability {
+
+ /**
+ * Create a new Charisma ability.
+ */
+ public Charisma () {
+ super (Ability.CHA);
+ }
/**
Index: Intelligence.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/magic/abilities/Intelligence.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Intelligence.java 27 Feb 2003 01:24:44 -0000 1.2
--- Intelligence.java 4 Apr 2003 20:22:56 -0000 1.3
***************
*** 23,27 ****
package ogs.magic.abilities;
! import ogs.magic.Ability;
import ogs.magic.abilities.Utility;
--- 23,27 ----
package ogs.magic.abilities;
! import ogs.core.Ability;
import ogs.magic.abilities.Utility;
***************
*** 31,36 ****
*/
public class Intelligence
! extends ogs.core.abilities.Intelligence
implements ogs.magic.Ability {
/**
--- 31,43 ----
*/
public class Intelligence
! extends ogs.core.Ability
implements ogs.magic.Ability {
+
+ /**
+ * Create a new Intelligence score.
+ */
+ public Intelligence () {
+ super (Ability.INT);
+ }
/**
Index: Wisdom.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/magic/abilities/Wisdom.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Wisdom.java 27 Feb 2003 01:24:44 -0000 1.2
--- Wisdom.java 4 Apr 2003 20:22:56 -0000 1.3
***************
*** 23,27 ****
package ogs.magic.abilities;
! import ogs.magic.Ability;
import ogs.magic.abilities.Utility;
--- 23,27 ----
package ogs.magic.abilities;
! import ogs.core.Ability;
import ogs.magic.abilities.Utility;
***************
*** 31,36 ****
*/
public class Wisdom
! extends ogs.core.abilities.Wisdom
implements ogs.magic.Ability {
/**
--- 31,43 ----
*/
public class Wisdom
! extends ogs.core.Ability
implements ogs.magic.Ability {
+
+ /**
+ * Create a new Wisdom score.
+ */
+ public Wisdom () {
+ super (Ability.WIS);
+ }
/**
|