[ogs-changes] dist/c++/ogs/core Attack.h,NONE,1.1 Move.h,NONE,1.1 Moves.h,NONE,1.1 Weapon.h,NONE,1.1
Status: Alpha
Brought to you by:
elemings
Update of /cvsroot/ogs/dist/c++/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/core
Modified Files:
Ability.h CClass.cpp Creature.cpp Creature.h Details.h Die.cpp
Die.h Entity.cpp Entity.h Experience.h Makefile.am
Modifier.cpp Modifier.h Modifiers.cpp Modifiers.h Types.h
Added Files:
Attack.h Move.h Moves.h Weapon.h
Log Message:
See C++ ChangeLog (May 2) for details.
--- NEW FILE: Attack.h ---
/*
* Attack.h -- class interface for attack rolls
* 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: Attack.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_ATTACK_H
# define OGS_CORE_ATTACK_H
# include <ogs/core/Experience.h>
# include <ogs/core/Modifier.h>
# include <ogs/core/Modifiers.h>
# include <ogs/core/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
//class Defense;
class Weapon;
/**
* An attack roll used in combat. Attacks provide the information
* required for rolling attacks such as the modifiers added to attack
* rolls and the weapon used in an attack.
*/
class Attack {
public:
/**
* An enumerated type that represents the result of an attack roll.
*/
enum Result {
/** An integer constant that indicates a miss. */
MISS,
/** An integer constant that indicates a normal hit. */
HIT,
/** An integer constant that indicates a critical hit. */
CRIT
};
static Modifier::Value getStrongBonus (XP::Level xpLevel);
static Modifier::Value getAverageBonus (XP::Level xpLevel);
static Modifier::Value getWeakBonus (XP::Level xpLevel);
Attack ();
const Modifiers& getModifiers () const;
Modifiers& getModifiers ();
Weapon* getWeapon () const;
void setWeapon (Weapon& weapon);
//Result rollAttack (const Defense& defense) const;
//void addDamage (Creature& creature) const;
private:
Modifiers _modifiers;
Weapon* _weapon;
};
/**
* Determine value of attack bonus for cclasses that are strong in
* combat.
*
* @param xpLevel An experience level.
* @return Value of attack bonus.
*/
inline Modifier::Value
Attack::getStrongBonus (XP::Level xpLevel) {
return (xpLevel);
}
/**
* Determine value of attack bonus for cclasses that are average in
* combat.
*
* @param xpLevel An experience level.
* @return Value of attack bonus.
*/
inline Modifier::Value
Attack::getAverageBonus (XP::Level xpLevel) {
return ((3 * xpLevel) / 4);
}
/**
* Determine value of attack bonus for cclasses that are weak in combat.
*
* @param xpLevel An experience level.
* @return Value of attack bonus.
*/
inline Modifier::Value
Attack::getWeakBonus (XP::Level xpLevel) {
return (xpLevel / 2);
}
/**
* Create a new attack. The new attack initially has no roll modifiers
* and no weapon is specified for it.
*/
inline Attack::Attack ():
_modifiers (),
_weapon (NULL) {
// empty constructor body
}
/**
* Determine the roll modifiers for this attack.
*
* @return Roll modifiers for this attack.
*/
inline const Modifiers&
Attack::getModifiers () const {
return (this->_modifiers);
}
/**
* Determine the roll modifiers for this attack. This function allows
* the caller to add and remove modifiers to rolls for this attack.
*
* @return Roll modifiers for this attack.
*/
inline Modifiers&
Attack::getModifiers () {
return (this->_modifiers);
}
/**
* Determine the weapon used for this attack. If no weapon has been
* specified for this attack, this function returns NULL.
*
* @return Weapon used for this attack or NULL if not specified.
*/
inline Weapon*
Attack::getWeapon () const {
return (this->_weapon);
}
OGS_END_CORE_NAMESPACE
# endif /* !defined OGS_CORE_ATTACK_H */
#endif /* defined __cplusplus */
--- NEW FILE: Move.h ---
/*
* Move.h -- class interface for modes of movement
* 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: Move.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_MOVE_H
# define OGS_CORE_MOVE_H
# include <ogs/core/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
/**
* A mode of movement All modes of movement have an associated speed.
* A speed of zero (0) usually means that a creature (or entity) can not
* move in this mode. Some modes have additional details specific to
* that mode.
*
* @see ogs::core::moves
*/
class Move {
public:
/**
* An enumerated type that indicates the mode of moveoement.
*/
enum Mode {
WALK = 1,
CLIMB,
SWIM,
FLY,
BURROW
};
/**
* A floating point type that represents speed of move. Units of
* measurement are locale-dependent.
*/
typedef double Speed;
static Move* createClimb (Speed speed);
static Move* createSwim (Speed speed);
Mode getMode () const;
Speed getSpeed () const;
protected:
Move (Mode mode, Speed speed);
private:
Mode _mode;
Speed _speed;
};
/**
* Create a new climb move.
*
* @param speed Speed of move.
* @return A new climb move.
*/
inline Move*
Move::createClimb (Speed speed) {
return (new Move (CLIMB, speed));
}
/**
* Create a new climb move.
*
* @param speed Speed of move.
* @return A new swim move.
*/
inline Move*
Move::createSwim (Speed speed) {
return (new Move (SWIM, speed));
}
/**
* Determine the mode of this move.
*
* @return Mode of this move.
*/
inline Move::Mode
Move::getMode () const {
return (this->_mode);
}
/**
* Determine the speed for this move.
*
* @return Speed for this move.
*/
inline Move::Speed
Move::getSpeed () const {
return (this->_speed);
}
/**
* Create a new move.
*/
inline
Move::Move (Mode mode, Speed speed):
_mode (mode),
_speed (speed) {
// empty constructor body
}
OGS_END_CORE_NAMESPACE
# endif /* !defined OGS_CORE_MOVE_H */
#endif /* defined __cplusplus */
--- NEW FILE: Moves.h ---
/*
* Moves.h -- class interfaces for creature movements
* 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: Moves.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifndef OGS_CORE_MOVES_H
# define OGS_CORE_MOVES_H
# include <ogs/core/moves/Burrow.h>
# include <ogs/core/moves/Fly.h>
# include <ogs/core/moves/Walk.h>
#endif /* !defined OGS_CORE_MOVES_H */
--- NEW FILE: Weapon.h ---
/*
* Weapon.h -- class interface for weapons
* 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: Weapon.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_WEAPON_H
# define OGS_CORE_WEAPON_H
# include <bitset>
# include <ogs/core/Die.h>
# include <ogs/items/Namespace.h>
OGS_BEGIN_CORE_NAMESPACE
/**
* An object used in combat to damage opponents. Weapons can be body
* parts used as natural weapons or items used as manufactured weapons.
* These weapons define the type of damage inflicted by the weapon and
* the die used for damage rolls. Weapons typically have a critical
* modifier of x2 and a threat range of 20.
*/
struct Weapon {
/**
* Indicates the type of damage inflicted by the weapon. Most weapons
* inflict only one type of damage but some may inflict two types.
*/
typedef std::bitset<3> DamageType;
enum {
/** Indicates that this weapon inflicts bashing damage. */
BASHING = 1,
/** Indicates that this weapon Inflicts piercing damage. */
PIERCING = 2,
/** Indicates that this weapon inflicts slashing damage. */
SLASHING = 3,
};
virtual ~Weapon () {}
/**
* Determine the type of this weapon.
*
* @return Type of damage inflicted by this weapon.
*/
virtual DamageType getDamageType () const = 0;
/**
* Determine the die used to roll damage caused by this weapon.
*
* @return Die used to roll damage from this weapon.
*/
virtual const Die& getDamageRoll () const = 0;
virtual unsigned getCriticalMultiplier () const;
virtual Die::Value getThreatRange () const;
};
/**
* Determine the critical multiplier of this weapon. The default
* critical multiplier of a weapon is x2.
*
* @return Critical multiplier of this weapon.
*/
inline unsigned
Weapon::getCriticalMultiplier () const {
return (2);
}
/**
* Determine the threat range of this weapon. The default threat range
* of a weapon is 20.
*
* @return Threat range of this weapon.
*/
inline Die::Value
Weapon::getThreatRange () const {
return (20);
}
OGS_END_CORE_NAMESPACE
# endif /* !defined OGS_CORE_WEAPON_H */
#endif /* defined __cplusplus */
Index: Ability.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Ability.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Ability.h 18 Apr 2003 01:41:02 -0000 1.7
--- Ability.h 2 May 2003 19:06:30 -0000 1.8
***************
*** 127,130 ****
--- 127,132 ----
Modifier& getModifier ();
+ class Loss;
+
private:
Type _type;
***************
*** 392,395 ****
--- 394,458 ----
Ability::Event::getPreviousScore () const {
return (this->_score);
+ }
+
+ /**
+ * A modifier that reduces ability scores. Ability loss can result from
+ * supernatural attacks, poisons, and spells. Targets of ability loss
+ * are normally entitled to a saving throw. The severity and duration
+ * of the ability loss varies according to type.
+ */
+ class Ability::Loss: public ogs::core::Modifier {
+ public:
+ /** An enumerated type representing the type of ability loss. */
+ enum Type {
+
+ /**
+ * Temporary loss that returns naturally. Ability damage returns
+ * naturally at the rate of 1 point per day or 2 points per day
+ * of complete rest. It can also be restored with spells.
+ */
+ DAMAGE = 1,
+
+ /**
+ * Permanent loss that can only be restored by magic. Ability
+ * loss resulting from drain does not return naturally. It can
+ * only be restored with spells.
+ */
+ DRAIN,
+
+ /**
+ * Temporary loss that returns automatically. Ability loss
+ * resulting from reduction automatically returns when the effect
+ * that caused the reduction expires.
+ */
+ REDUCTION
+ };
+
+ Loss (Type type, Modifier::Value value);
+
+ Type getType () const;
+
+ private:
+ Type _type;
+ };
+
+ /**
+ * Create a new ability loss modifier.
+ */
+ inline
+ Ability::Loss::Loss (Type type, Modifier::Value value):
+ Modifier (value),
+ _type (type) {
+ // empty constructor body
+ }
+
+ /**
+ * Determine the type of this ability loss.
+ *
+ * @return Type of this ability loss.
+ */
+ inline Ability::Loss::Type
+ Ability::Loss::getType () const {
+ return (this->_type);
}
Index: CClass.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/CClass.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CClass.cpp 13 Apr 2003 05:25:51 -0000 1.5
--- CClass.cpp 2 May 2003 19:06:30 -0000 1.6
***************
*** 23,26 ****
--- 23,27 ----
#include <typeinfo>
+ #include "ogs/core/Attack.h"
#include "ogs/core/CClass.h"
#include "ogs/core/Character.h"
***************
*** 84,88 ****
void CClass::updateCClass () {
! Modifier::Value modifierValue = XP::getAverageAttack (this->_xpLevel);
if (_baseAttack.getValue () != modifierValue) {
_baseAttack.setValue (modifierValue);
--- 85,89 ----
void CClass::updateCClass () {
! Modifier::Value modifierValue = Attack::getAverageBonus (this->_xpLevel);
if (_baseAttack.getValue () != modifierValue) {
_baseAttack.setValue (modifierValue);
Index: Creature.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Creature.cpp 19 Apr 2003 18:37:40 -0000 1.13
--- Creature.cpp 2 May 2003 19:06:30 -0000 1.14
***************
*** 39,42 ****
--- 39,44 ----
*
* @param hitDice Hit dice of creature.
+ * @param moves A list of movement rates.
+ * @param attacks An array of attacks.
* @param abilities Ability scores of creature.
* @param size Size of creature.
***************
*** 44,58 ****
* @todo Observe Con modifier and update hit dice modifier and hit points.
*/
! 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.
--- 46,62 ----
* @todo Observe Con modifier and update hit dice modifier and hit points.
*/
! Creature::Creature (Die hitDice, Moves moves,
! Attacks attacks, Abilities abilities,
Size::Type size, Parts parts):
Entity (size),
_hitDice (hitDice),
_initiative (),
+ _moves (moves),
+ _attacks (attacks),
_saves (),
_abilities (abilities),
_skills (),
_feats (),
! _body () {
// Add Dexterity modifier to Reflex save, initiative, and defense.
Index: Creature.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Creature.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Creature.h 18 Apr 2003 01:41:02 -0000 1.11
--- Creature.h 2 May 2003 19:06:30 -0000 1.12
***************
*** 66,69 ****
--- 66,77 ----
Die::Value rollInitiative () const;
+ Moves getMoves () const;
+ void addMove (Move& move);
+ void removeMove (Move& move);
+
+ Attacks getAttacks () const;
+ void addAttack (Attack& attack);
+ void removeAttack (Attack& attack);
+
const Saves& getSaves () const;
Saves& getSaves ();
***************
*** 85,90 ****
bool unequipItem (Item& item);
- Character* getCharacter () const;
-
virtual ~Creature () = 0;
--- 93,96 ----
***************
*** 100,105 ****
typedef std::vector<BodyPart::Type> Parts;
! Creature (Die hitDice, Abilities abilities,
! Size::Type size = Size::MEDIUM,
Parts parts = Parts ());
--- 106,111 ----
typedef std::vector<BodyPart::Type> Parts;
! Creature (Die hitDice, Moves moves, Attacks attacks,
! Abilities abilities, Size::Type size = Size::MEDIUM,
Parts parts = Parts ());
***************
*** 107,111 ****
Die _hitDice;
Modifiers _initiative;
! //TODO: Add moves;
Saves _saves;
Abilities _abilities;
--- 113,118 ----
Die _hitDice;
Modifiers _initiative;
! Moves _moves;
! Attacks _attacks;
Saves _saves;
Abilities _abilities;
***************
*** 113,117 ****
Feats _feats;
Body _body;
- Character* _character;
Modifier _fortModifier;
--- 120,123 ----
***************
*** 247,262 ****
Creature::getBody () const {
return (this->_body);
- }
-
- /**
- * Determine if this creature is a character. If this creature is a
- * character, a pointer to the Character object is returned. Otherwise,
- * a null pointer is returned.
- *
- * @return Null pointer or a pointer to a Character object.
- */
- inline Character*
- Creature::getCharacter () const {
- return (this->_character);
}
--- 253,256 ----
Index: Details.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Details.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Details.h 25 Mar 2003 06:13:11 -0000 1.2
--- Details.h 2 May 2003 19:06:30 -0000 1.3
***************
*** 21,26 ****
*/
! #ifndef OGS_DETAILS_H
! # define OGS_DETAILS_H
# include <ogs/core/details/Alignment.h>
--- 21,26 ----
*/
! #ifndef OGS_CORE_DETAILS_H
! # define OGS_CORE_DETAILS_H
# include <ogs/core/details/Alignment.h>
***************
*** 28,32 ****
# include <ogs/core/details/Gender.h>
# include <ogs/core/details/Quantity.h>
! #endif /* !defined OGS_DETAILS_H */
--- 28,34 ----
# include <ogs/core/details/Gender.h>
# include <ogs/core/details/Quantity.h>
+ # include <ogs/core/details/Subdual.h>
+ # include <ogs/core/details/Vision.h>
! #endif /* !defined OGS_CORE_DETAILS_H */
Index: Die.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Die.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Die.cpp 25 Mar 2003 06:13:11 -0000 1.3
--- Die.cpp 2 May 2003 19:06:30 -0000 1.4
***************
*** 21,26 ****
*/
- #include <stdexcept>
#include <cstdlib>
#include "ogs/support/Event.h"
--- 21,27 ----
*/
#include <cstdlib>
+ #include <sstream>
+ #include <stdexcept>
#include "ogs/support/Event.h"
***************
*** 36,40 ****
* @param modifier Arbitrary value added to sum of die rolls.
* @return Sum of die rolls and modifier.
! * @throws invalid_argument If sides or count is zero (0).
*/
Die::Value Die::roll (Sides sides, Count count, Modifier modifier) {
--- 37,41 ----
* @param modifier Arbitrary value added to sum of die rolls.
* @return Sum of die rolls and modifier.
! * @throws std::invalid_argument If sides is less than one (1).
*/
Die::Value Die::roll (Sides sides, Count count, Modifier modifier) {
***************
*** 43,49 ****
// and let programmers pass in zero if they like get zero in return.
if (sides < 1) {
! throw std::invalid_argument ("sides must be greater than 0");
! } else if (count < 1) {
! throw std::invalid_argument ("count must be greater than 0");
}
--- 44,51 ----
// and let programmers pass in zero if they like get zero in return.
if (sides < 1) {
! std::ostringstream ostr;
! ostr << "die sides (" << int (sides) <<
! ") must be greater than zero (0)";
! throw std::invalid_argument (ostr.str ());
}
***************
*** 57,74 ****
/**
- * Create a new die.
- *
- * @param sides Number of sides on die.
- * @param count Number of times to roll die.
- * @param modifier Arbitrary value added to sum of die rolls.
- */
- Die::Die (Sides sides, Count count, Modifier modifier) {
- this->sides = sides;
- this->count = count;
- this->modifier = modifier;
- this->value = roll (sides, count, modifier);
- }
-
- /**
* Change the sides on this die.
*
--- 59,62 ----
***************
*** 76,83 ****
*/
void Die::setSides (Sides sides) {
! this->sides = sides;
!
! // Update current value to syncronize with new sides.
! setValue ();
}
--- 64,72 ----
*/
void Die::setSides (Sides sides) {
! if (this->_sides != sides) {
! this->_sides = sides;
! // Update current value to syncronize with new sides.
! setValue ();
! }
}
***************
*** 88,95 ****
*/
void Die::setCount (Count count) {
! this->count = count;
!
! // Update current value to syncronize with new count.
! setValue ();
}
--- 77,84 ----
*/
void Die::setCount (Count count) {
! if (this->_count != count) {
! this->_count = count;
! setValue ();
! }
}
***************
*** 100,107 ****
*/
void Die::setModifier (Modifier modifier) {
! this->modifier = modifier;
!
! // Update current value to syncronize with new modifier.
! setValue ();
}
--- 89,96 ----
*/
void Die::setModifier (Modifier modifier) {
! if (this->_modifier != modifier) {
! this->_modifier = modifier;
! setValue ();
! }
}
***************
*** 110,114 ****
*/
void Die::setValue () const {
! this->value = roll (sides, count, modifier);
}
--- 99,103 ----
*/
void Die::setValue () const {
! this->_value = roll (this->_sides, this->_count, this->_modifier);
}
Index: Die.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Die.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Die.h 23 Mar 2003 22:14:36 -0000 1.2
--- Die.h 2 May 2003 19:06:30 -0000 1.3
***************
*** 128,145 ****
private:
! Sides sides;
! Count count;
! Modifier modifier;
// The value can be rerolled even if the die is const.
! mutable Value value;
};
/**
* Determine the number of sides on this die.
*
* @return Number of sides on this die.
*/
! inline Die::Sides Die::getSides () const {
! return (this->sides);
}
--- 128,163 ----
private:
! Sides _sides;
! Count _count;
! Modifier _modifier;
// The value can be rerolled even if the die is const.
! mutable Value _value;
};
/**
+ * Create a new die.
+ *
+ * @param sides Number of sides on die.
+ * @param count Number of times to roll die.
+ * @param modifier Arbitrary value added to sum of die rolls.
+ * @throws std::invalid_argument If sides is less than one (1).
+ */
+ inline
+ Die::Die (Sides sides, Count count, Modifier modifier):
+ _sides (sides),
+ _count (count),
+ _modifier (modifier),
+ _value (roll (sides, count, modifier)) {
+ // empty constructor body
+ }
+
+ /**
* Determine the number of sides on this die.
*
* @return Number of sides on this die.
*/
! inline Die::Sides
! Die::getSides () const {
! return (this->_sides);
}
***************
*** 149,154 ****
* @return Number of times this die is rolled.
*/
! inline Die::Count Die::getCount () const {
! return (this->count);
}
--- 167,173 ----
* @return Number of times this die is rolled.
*/
! inline Die::Count
! Die::getCount () const {
! return (this->_count);
}
***************
*** 158,163 ****
* @return Arbitrary value added to the sum of die rolls.
*/
! inline Die::Modifier Die::getModifier () const {
! return (this->modifier);
}
--- 177,183 ----
* @return Arbitrary value added to the sum of die rolls.
*/
! inline Die::Modifier
! Die::getModifier () const {
! return (this->_modifier);
}
***************
*** 167,172 ****
* @return Value of the last die roll.
*/
! inline Die::Value Die::getValue () const {
! return (this->value);
}
--- 187,193 ----
* @return Value of the last die roll.
*/
! inline Die::Value
! Die::getValue () const {
! return (this->_value);
}
***************
*** 177,181 ****
* @return New value of the die.
*/
! inline Die::Value Die::rollValue () const {
setValue ();
return (getValue ());
--- 198,203 ----
* @return New value of the die.
*/
! inline Die::Value
! Die::rollValue () const {
setValue ();
return (getValue ());
***************
*** 187,192 ****
* @return Lowest possible value of this die.
*/
! inline Die::Value Die::getMinimumValue () const {
! return (this->count + this->modifier);
}
--- 209,215 ----
* @return Lowest possible value of this die.
*/
! inline Die::Value
! Die::getMinimumValue () const {
! return (this->_count + this->_modifier);
}
***************
*** 196,201 ****
* @return Highest possible value of this die.
*/
! inline Die::Value Die::getMaximumValue () const {
! return ((this->count * this->sides) + this->modifier);
}
--- 219,225 ----
* @return Highest possible value of this die.
*/
! inline Die::Value
! Die::getMaximumValue () const {
! return ((this->_count * this->_sides) + this->_modifier);
}
Index: Entity.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Entity.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Entity.cpp 15 Apr 2003 16:58:35 -0000 1.7
--- Entity.cpp 2 May 2003 19:06:30 -0000 1.8
***************
*** 60,72 ****
/**
! * Change the health of this entity. Observers are notified of this
! * change.
*
* @param health Health of this entity.
*/
void Entity::setHealth (Health health) {
! Event event (*this);
! this->_health = health;
! notifyObservers (event);
}
--- 60,79 ----
/**
! * Change the health of this entity. If the current health exceeds the
! * maximum health, it is lowered to the maximum health. Observers are
! * notified of this change.
*
* @param health Health of this entity.
*/
void Entity::setHealth (Health health) {
! if (this->_health != health) {
! if (health.first > health.second) {
! health.first = health.second;
! }
!
! Event event (*this);
! this->_health = health;
! notifyObservers (event);
! }
}
Index: Entity.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Entity.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Entity.h 18 Apr 2003 01:41:02 -0000 1.8
--- Entity.h 2 May 2003 19:06:30 -0000 1.9
***************
*** 59,63 ****
* Health is also referred to as hit points.
*/
! typedef std::pair<int, int> Health;
const Size& getSize () const;
--- 59,63 ----
* Health is also referred to as hit points.
*/
! typedef std::pair<short, short> Health;
const Size& getSize () const;
Index: Experience.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Experience.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Experience.h 18 Apr 2003 01:41:02 -0000 1.5
--- Experience.h 2 May 2003 19:06:30 -0000 1.6
***************
*** 44,95 ****
* negative values.
*/
! class Experience {
! public:
! /** An unsigned integer type that represents experience points. */
! typedef unsigned int Points;
! /** An unsigned integer type that represents experience level. */
! typedef unsigned short Level;
!
! static Level getLevel (Points points);
! static Points getPoints (Level level);
! static Modifier::Value getStrongAttack (Level level);
! static Modifier::Value getAverageAttack (Level level);
! static Modifier::Value getWeakAttack (Level level);
! static std::string formatLevel (Level level);
};
-
- /**
- * Determine value of attack bonus for cclasses that are strong in
- * combat.
- *
- * @return Value of attack bonus.
- */
- inline Modifier::Value
- Experience::getStrongAttack (Level level) {
- return (level);
- }
-
- /**
- * Determine value of attack bonus for cclasses that are average in
- * combat.
- *
- * @return Value of attack bonus.
- */
- inline Modifier::Value
- Experience::getAverageAttack (Level level) {
- return ((3 * level) / 4);
- }
-
- /**
- * Determine value of attack bonus for cclasses that are weak in combat.
- *
- * @return Value of attack bonus.
- */
- inline Modifier::Value
- Experience::getWeakAttack (Level level) {
- return (level / 2);
- }
OGS_END_CORE_NAMESPACE
--- 44,58 ----
* negative values.
*/
! struct Experience {
! /** An unsigned integer type that represents experience points. */
! typedef unsigned int Points;
! /** An unsigned integer type that represents experience level. */
! typedef unsigned short Level;
! static Level getLevel (Points points);
! static Points getPoints (Level level);
! static std::string formatLevel (Level level);
};
OGS_END_CORE_NAMESPACE
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Makefile.am 13 Apr 2003 05:25:51 -0000 1.8
--- Makefile.am 2 May 2003 19:06:30 -0000 1.9
***************
*** 21,25 ****
##
! SUBDIRS = details
pkgincludedir = $(includedir)/ogs/core
--- 21,25 ----
##
! SUBDIRS = details moves
pkgincludedir = $(includedir)/ogs/core
***************
*** 28,31 ****
--- 28,32 ----
Abilities.h \
Ability.h \
+ Attack.h \
BodyPart.h \
CClass.h \
***************
*** 43,46 ****
--- 44,49 ----
Modifier.h \
Modifiers.h \
+ Move.h \
+ Moves.h \
Namespace.h \
Saves.h \
***************
*** 48,52 ****
Skill.h \
Strength.h \
! Types.h
INCLUDES = \
--- 51,56 ----
Skill.h \
Strength.h \
! Types.h \
! Weapon.h
INCLUDES = \
Index: Modifier.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifier.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Modifier.cpp 8 Apr 2003 21:43:09 -0000 1.3
--- Modifier.cpp 2 May 2003 19:06:30 -0000 1.4
***************
*** 23,44 ****
#include <sstream>
#include <string>
- #include <typeinfo>
#include "ogs/support/Object.h"
#include "ogs/core/Modifier.h"
- using ogs::support::Object;
using ogs::core::Modifier;
/**
! * Change the value of the modifier. Notifies listeners.
*
! * @param value Value of the modifier.
*/
void Modifier::setValue (Value value) {
! // Let event store previous value before it is changed.
! Modifier::Event event (*this);
! this->_value = value;
! notifyObservers (event);
}
--- 23,45 ----
#include <sstream>
#include <string>
#include "ogs/support/Object.h"
#include "ogs/core/Modifier.h"
using ogs::core::Modifier;
/**
! * Change the value of this modifier. This function notifies observers
! * of this modifier with a modifier event.
*
! * @param value Value of this modifier.
*/
void Modifier::setValue (Value value) {
! // Notify observers only when neccessary.
! if (value != this->_value) {
! Modifier::Event event (*this);
! this->_value = value;
! notifyObservers (event);
! }
}
***************
*** 51,55 ****
std::string Modifier::toString () const {
std::ostringstream ostr;
! ostr << Object::toString ();
ostr << " [value " << this->_value << "]";
return (ostr.str ());
--- 52,56 ----
std::string Modifier::toString () const {
std::ostringstream ostr;
! ostr << ogs::support::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.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Modifier.h 13 Apr 2003 05:25:51 -0000 1.3
--- Modifier.h 2 May 2003 19:06:30 -0000 1.4
***************
*** 1,5 ****
/**
! * @file ogs/core/Modifier.h
! * Class interface for general purpose modifiers.
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/**
! * Modifier.h -- class interface for general purpose modifiers
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 42,45 ****
--- 41,47 ----
* a class to allow modifier objects to notify observers of events that
* cause the value of the modifier to change.
+ *
+ * @todo
+ * Overload operators for add, subtract, and other integer operations?
*/
class Modifier: public ogs::support::Object {
***************
*** 47,52 ****
/**
* 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;
--- 49,54 ----
/**
* A signed integer type representing the value of a modifier. This
! * type is explicitly defined to hide the underlying type in case it
! * should change in the future.
*/
typedef short Value;
***************
*** 77,83 ****
/**
! * Determine the value of the modifier.
*
! * @return Value of the modifier.
*/
inline Modifier::Value
--- 79,85 ----
/**
! * Determine the value of this modifier.
*
! * @return Value of this modifier.
*/
inline Modifier::Value
***************
*** 97,100 ****
--- 99,103 ----
private:
Value _value;
+
Event (Modifier& modifier);
friend void Modifier::setValue (Value value);
***************
*** 102,106 ****
/**
! * Create a new modifier event.
*
* @param modifier Modifier causing this event.
--- 105,110 ----
/**
! * Create a new modifier event. The event must be created
! * <em>before</em> the value of the modifier is actually changed.
*
* @param modifier Modifier causing this event.
***************
*** 108,119 ****
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
--- 112,124 ----
inline
Modifier::Event::Event (Modifier& modifier):
! ogs::support::Event (modifier),
! _value (modifier.getValue ()) {
// empty constructor body
}
/**
! * Determine the previous value of the modifier.
*
! * @return Previous value of the modifier.
*/
inline Modifier::Value
Index: Modifiers.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifiers.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Modifiers.cpp 13 Apr 2003 05:25:51 -0000 1.4
--- Modifiers.cpp 2 May 2003 19:06:30 -0000 1.5
***************
*** 24,33 ****
#include "ogs/core/Modifiers.h"
- using ogs::support::Event;
using ogs::core::Modifiers;
/**
! * Add a modifier to this list of modifiers. The total value is
! * updated accordingly and observers are notified.
*
* @param modifier A modifier to be added to the list.
--- 24,32 ----
#include "ogs/core/Modifiers.h"
using ogs::core::Modifiers;
/**
! * Add a modifier to this list of modifiers. The total value of the
! * list is updated and observers are notified of the event.
*
* @param modifier A modifier to be added to the list.
***************
*** 43,48 ****
/**
! * Remove a modifier from this list of modifiers. The total value is
! * updated accordingly and observers are notified.
*
* @param modifier A modifier to be removed from the list.
--- 42,47 ----
/**
! * Remove a modifier from this list of modifiers. The total value of
! * the list is updated and observers are notified of the event.
*
* @param modifier A modifier to be removed from the list.
Index: Modifiers.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Modifiers.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Modifiers.h 13 Apr 2003 05:25:51 -0000 1.3
--- Modifiers.h 2 May 2003 19:06:30 -0000 1.4
***************
*** 122,126 ****
/**
! * Create a new modifier list event.
*
* @param modifiers Modifier list causing this event.
--- 122,127 ----
/**
! * Create a new modifier list event. The event must be created
! * <em>before</em> the list of modifiers is changed.
*
* @param modifiers Modifier list causing this event.
***************
*** 140,146 ****
/**
! * Determine previous value of this list of modifiers.
*
! * @return Previous value of this list of modifiers.
*/
inline Modifier::Value
--- 141,147 ----
/**
! * Determine the previous value of the list of modifiers.
*
! * @return Previous value of the list of modifiers.
*/
inline Modifier::Value
Index: Types.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/Types.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Types.h 18 Apr 2003 01:41:02 -0000 1.2
--- Types.h 2 May 2003 19:06:30 -0000 1.3
***************
*** 27,30 ****
--- 27,31 ----
# include <list>
+ # include <vector>
# include <boost/shared_ptr.hpp>
***************
*** 35,41 ****
--- 36,44 ----
class Ability;
+ class Attack;
class Feature;
class Feat;
class Item;
+ class Move;
class Skill;
***************
*** 60,63 ****
--- 63,76 ----
/** A smart pointer that holds an item object. */
typedef boost::shared_ptr<Item> ItemPtr;
+
+ /** A smart pointer that holds a move. */
+ typedef boost::shared_ptr<Move> MovePtr;
+ /** A list of moves. */
+ typedef std::list<MovePtr> Moves;
+
+ /** A smart pointer that holds an attack. */
+ typedef boost::shared_ptr<Attack> AttackPtr;
+ /** An array of attacks. */
+ typedef std::vector<AttackPtr> Attacks;
OGS_END_CORE_NAMESPACE
|