[ogs-changes] dist/c++/ogs/core/details Subdual.h,NONE,1.1 Vision.h,NONE,1.1 Makefile.am,1.3,1.4
Status: Alpha
Brought to you by:
elemings
|
From: <ele...@us...> - 2003-05-02 19:07:08
|
Update of /cvsroot/ogs/dist/c++/ogs/core/details
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/core/details
Modified Files:
Makefile.am
Added Files:
Subdual.h Vision.h
Log Message:
See C++ ChangeLog (May 2) for details.
--- NEW FILE: Subdual.h ---
/*
* Subdual.h -- class interface for subdual damage
* 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: Subdual.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_DETAILS_SUBDUAL_H
# define OGS_CORE_DETAILS_SUBDUAL_H
# include <ogs/core/Creature.h>
# include <ogs/core/Detail.h>
# include <ogs/core/details/Namespace.h>
OGS_BEGIN_CORE_DETAILS_NAMESPACE
using ogs::core::Creature;
/**
* A detail of creatures that tracks subdual damage. Subdual damage
* usually results from nonlethal combat but can also result from other
* activities that cause overexertion. When subdual damage to a
* creature equals the current hit points of a creature, the creature is
* staggered and can only take partial actions. When subdual damage
* exceeds the current hit points, the creature falls unconscious but is
* still alive.
*/
class Subdual: public ogs::core::Detail {
public:
typedef short Damage;
static Damage getDamage (const Creature& creature);
static void addDamage (Creature& creature, Damage damage);
static void removeDamage (Creature& creature);
private:
Damage _damage;
static Subdual* findSubdual (const Creature& creature);
Subdual (Damage damage);
};
/**
* Determine the subdual damage for a creature.
*
* @return Subdual damage for the creature.
*/
inline Subdual::Damage
Subdual::getDamage (const Creature& creature) {
Subdual* subdual = findSubdual (creature);
return (subdual == NULL? 0: subdual->_damage);
}
/**
* Add subdual damage to a creature. If the subdual damage is negative,
* the subdual damage is removed from the creature instead.
*
* @param creature Creature to add subdual damage to.
* @param damage Amount of damage to add.
*/
inline void
Subdual::addDamage (Creature& creature, Damage damage) {
Subdual* subdual = findSubdual (creature);
if (subdual != NULL) {
subdual->_damage += damage;
} else {
subdual = new Subdual (damage);
creature.addFeature (*subdual);
}
//updateCondition ();
}
/**
* Remove all subdual damage from a creature.
*
* @param creature Creature to remove all subdual damage from.
*/
inline void
Subdual::removeDamage (Creature& creature) {
Subdual* subdual = findSubdual (creature);
if (subdual != NULL) {
subdual->detachObject ();
}
//updateCondition ();
}
/**
* Create a new subdual damage object. The amount of damage for the new
* object is zero (0) when initially created.
*/
inline
Subdual::Subdual (Damage damage):
_damage (damage) {
// empty constructor body
}
/**
* Find the subdual damage for a creature.
*
* @return Pointer to subdual damage or NULL if the creature has none.
*/
inline Subdual*
Subdual::findSubdual (const Creature& creature) {
using ogs::core::Features;
Features features = creature.getFeatures ();
// TODO: Finish this function.
return (NULL);
}
OGS_END_CORE_DETAILS_NAMESPACE
# endif /* !defined OGS_CORE_DETAILS_SUBDUAL_H */
#endif /* defined __cplusplus */
--- NEW FILE: Vision.h ---
/*
* Vision.h -- class interface for forms of vision
* 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: Vision.h,v 1.1 2003/05/02 19:06:30 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_CORE_DETAILS_VISION_H
# define OGS_CORE_DETAILS_VISION_H
# include <ogs/core/Creature.h>
# include <ogs/core/Feature.h>
# include <ogs/core/details/Namespace.h>
OGS_BEGIN_CORE_DETAILS_NAMESPACE
/**
* A creature feature describing various forms of vision.
*/
class Vision: public ogs::core::Feature {
public:
/** A floating-point type representing distance. */
typedef double Distance;
enum Type {
/** Vision-like senses in total darkness. */
BLINDSIGHT = 1,
/** Colorless vision in total darkness. */
DARKVISION,
/** Color vision in near-dark conditions. */
LOW_LIGHT
};
static Vision* createBlindsight (Distance distance);
static Vision* createDarkvision (Distance distance);
static Vision* createLowLight (Distance distance);
protected:
Vision (Type type, Distance distance);
private:
Type _type;
Distance _distance;
bool canAttach (const ogs::support::Object& object) const;
};
/**
* Create a new blindsight vision.
*
* @param distance Maximum distance of vision.
* @return A new Blindsight vision.
*/
inline Vision*
Vision::createBlindsight (Distance distance) {
return (new Vision (BLINDSIGHT, distance));
}
/**
* Create a new darkvision vision.
*
* @param distance Maximum distance of vision.
* @return A new Darkvision vision.
*/
inline Vision*
Vision::createDarkvision (Distance distance) {
return (new Vision (DARKVISION, distance));
}
/**
* Create a new low-light vision.
*
* @param distance Maximum distance of vision.
* @return A new Darkvision vision.
*/
inline Vision*
Vision::createLowLight(Distance distance) {
return (new Vision (LOW_LIGHT, distance));
}
/**
* Create a new vision.
*
* @param type Type of vision.
* @param distance Maximum distance of vision.
*/
inline
Vision::Vision (Type type, Distance distance):
_type (type),
_distance (distance) {
// empty constructor body
}
/**
* Determine if this vision can be attached to an object. Visions can
* only be attached to creatures.
*
* @param object An object to attach this vision to.
* @return True if this vision can be attached to object.
*/
inline bool
Vision::canAttach (const ogs::support::Object& object) const {
return (Feature::canAttach (object) &&
dynamic_cast<const Creature*> (&object) != NULL);
}
OGS_END_CORE_DETAILS_NAMESPACE
# endif /* !defined OGS_CORE_DETAILS_VISION_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/core/details/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am 23 Mar 2003 22:14:36 -0000 1.3
--- Makefile.am 2 May 2003 19:06:30 -0000 1.4
***************
*** 29,33 ****
Maturity.h \
Namespace.h \
! Quantity.h
INCLUDES = \
--- 29,35 ----
Maturity.h \
Namespace.h \
! Quantity.h \
! Subdual.h \
! Vision.h
INCLUDES = \
|