[ogs-changes] dist/c++/ogs/spells/conjurations CureWounds.cpp,1.4,1.5 CureWounds.h,1.3,1.4
Status: Alpha
Brought to you by:
elemings
|
From: <ele...@us...> - 2003-05-02 19:06:42
|
Update of /cvsroot/ogs/dist/c++/ogs/spells/conjurations
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/spells/conjurations
Modified Files:
CureWounds.cpp CureWounds.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: CureWounds.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/conjurations/CureWounds.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CureWounds.cpp 18 Apr 2003 01:41:07 -0000 1.4
--- CureWounds.cpp 2 May 2003 19:06:36 -0000 1.5
***************
*** 21,43 ****
*/
! //#include "ogs/support/TypeTraits.h"
#include "ogs/core/Creature.h"
#include "ogs/creatures/Undead.h"
#include "ogs/spells/conjurations/CureWounds.h"
using ogs::core::Die;
! using ogs::core::Experience;
! using ogs::spells::Conjuration;
using ogs::spells::conjurations::CureWounds;
/**
- * This function is a stub for a future TypeTraits header addition.
- */
- template <class BaseClass, class DerivedClass>
- bool isBaseAndDerived (const DerivedClass& derivedObject) {
- return (true);
- }
-
- /**
* Create a new cure wounds spell.
*
--- 21,38 ----
*/
! #include <cassert>
!
#include "ogs/core/Creature.h"
+ #include "ogs/magic/Component.h"
+ #include "ogs/magic/Subschool.h"
#include "ogs/creatures/Undead.h"
#include "ogs/spells/conjurations/CureWounds.h"
using ogs::core::Die;
! using ogs::magic::Components;
! using ogs::magic::Subschool;
using ogs::spells::conjurations::CureWounds;
/**
* Create a new cure wounds spell.
*
***************
*** 49,85 ****
Degree degree,
bool inflict):
_casterLevel (casterLevel),
_degree (degree),
_inflict (inflict) {
! // empty
! }
!
! /**
! * 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.
! */
! ogs::magic::Spell::Components CureWounds::getComponents () const {
! using ogs::magic::Component;
! using ogs::magic::Spell;
!
! Spell::Components components;
!
! bool silenced = false; // TODO: Determine this.
! if (!silenced) {
! Component component = Component::Verbal ();
! components.push_back (component);
! }
!
! bool stilled = false; // TODO: Determine this.
! if (!stilled) {
! Component component = Component::Somantic ();
! components.push_back (component);
! }
!
! return (components);
}
--- 44,56 ----
Degree degree,
bool inflict):
+ ogs::spells::Conjuration (createComponents (),
+ ogs::magic::Range::Touch (),
+ Subschool (Subschool::HEALING)),
_casterLevel (casterLevel),
_degree (degree),
_inflict (inflict) {
! assert (degree == MINOR || degree == LIGHT ||
! degree == MODERATE || degree == SERIOUS ||
! degree == CRITICAL);
}
***************
*** 101,124 ****
*/
void CureWounds::castSpell () {
! if (_target != NULL) {
! using ogs::core::Entity;
! using ogs::core::Creature;
!
! if (isBaseAndDerived<Creature, Entity> (*_target)) {
! Die::Value hitPoints = rollHitPoints ();
! using ogs::creatures::Undead;
! if (isBaseAndDerived<Undead, Entity> (*_target)) {
! 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);
}
}
}
--- 72,95 ----
*/
void CureWounds::castSpell () {
! if (this->_target != NULL) {
! Die::Value hitPoints = rollHitPoints ();
! using ogs::core::Entity;
! using ogs::creatures::Undead;
! Undead* undead = dynamic_cast<Undead*> (this->_target);
! if ((undead != NULL && !this->_inflict) ||
! (undead == NULL && this->_inflict)) {
! // TODO: Add ability modifier to dc.
! Die::Value dc = 10 + this->_casterLevel;
! if (!(this->_target->getSaves ()).rollWillSave (dc) &&
! !checkTargetSpellResistance ()) {
! Entity::Health health = this->_target->getHealth ();
! health.first -= hitPoints;
! this->_target->setHealth (health);
}
+ } else {
+ Entity::Health health = this->_target->getHealth ();
+ health.first += hitPoints;
+ this->_target->setHealth (health);
}
}
***************
*** 126,129 ****
--- 97,116 ----
/**
+ * Create a list of components for Cure Wounds spells.
+ *
+ * @return A list of spell components.
+ */
+ Components CureWounds::createComponents () {
+ using ogs::magic::Component;
+ using ogs::magic::ComponentPtr;
+ Components components;
+ Component somantic (Component::Somantic ());
+ components.push_front (ComponentPtr (new Component (somantic)));
+ Component verbal (Component::Verbal ());
+ components.push_front (ComponentPtr (new Component (verbal)));
+ return (components);
+ }
+
+ /**
* Roll hit points for this cure wounds spell. If the spell has been
* empowered or maximized, the hit points are adjusted accordingly.
***************
*** 132,148 ****
*/
Die::Value CureWounds::rollHitPoints () const {
! Die::Value hitPoints = 0;
! if (_degree == MINOR) {
! hitPoints = 1;
! } else {
! // Note the value of the degree is important here.
! Die die (Die::d8);
! die.setCount (_degree);
! bool maximized = false; // TODO: Determine this.
! hitPoints = maximized? die.getMaximumValue (): die.rollValue ();
! unsigned maxBonus = 5 * _degree;
! hitPoints += _casterLevel > maxBonus? maxBonus: _casterLevel;
bool empowered = false; // TODO: Determine this.
--- 119,132 ----
*/
Die::Value CureWounds::rollHitPoints () const {
! Die::Value hitPoints = 1; // Assume degree is minor.
! if (this->_degree != MINOR) {
! // Note, the value of the degree is important here.
! unsigned maxBonus = 5 * this->_degree;
! Die die (Die::d8, this->_degree, this->_casterLevel > maxBonus?
! maxBonus: this->_casterLevel);
! bool maximized = false; // TODO: Determine this.
! hitPoints = maximized? die.getMaximumValue (): die.getValue ();
bool empowered = false; // TODO: Determine this.
***************
*** 153,165 ****
return (hitPoints);
- }
-
- /**
- * Roll a Will save for the target of this spell.
- *
- * @return True if Will save of target succeeded.
- */
- bool CureWounds::checkTargetWillSave () const {
- return (false); // TODO: Implement this function. Easy.
}
--- 137,140 ----
Index: CureWounds.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/conjurations/CureWounds.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CureWounds.h 18 Apr 2003 01:41:07 -0000 1.3
--- CureWounds.h 2 May 2003 19:06:37 -0000 1.4
***************
*** 28,32 ****
# include <ogs/core/Die.h>
# include <ogs/core/Experience.h>
- # include <ogs/magic/Subschool.h>
# include <ogs/spells/Conjuration.h>
# include <ogs/spells/conjurations/Namespace.h>
--- 28,31 ----
***************
*** 34,38 ****
OGS_BEGIN_SPELLS_CONJURATIONS_NAMESPACE
! class ogs::core::Entity;
/**
--- 33,37 ----
OGS_BEGIN_SPELLS_CONJURATIONS_NAMESPACE
! class ogs::core::Creature;
/**
***************
*** 48,52 ****
* damage to living creatures and heals undead creatures.
*
! * @todo Determine effects of metamagic feats and implement them.
*/
class CureWounds: public ogs::spells::Conjuration {
--- 47,56 ----
* damage to living creatures and heals undead creatures.
*
! * @todo
! * <UL>
! * <LI>Determine effects of metamagic feats and implement them.
! * <LI>Add ability modifier to constructors.
! * <LI>Add target to constructors?
! * </UL>
*/
class CureWounds: public ogs::spells::Conjuration {
***************
*** 56,60 ****
/** Target of cure wounds spell. */
! typedef ogs::core::Entity* Target;
/** Determines how much damage is healed (or dealt). */
--- 60,64 ----
/** Target of cure wounds spell. */
! typedef ogs::core::Creature* Target;
/** Determines how much damage is healed (or dealt). */
***************
*** 101,120 ****
bool inflict = false);
- const ogs::magic::School& getSchool () const;
- ogs::magic::Spell::Components getComponents () const;
- ogs::magic::Range getRange () const;
-
Degree getDegree () const;
Target getTarget () const;
! void setTarget (Target target);
bool inflictsWounds () const;
void castSpell ();
- protected:
- CureWounds (CasterLevel casterLevel,
- Degree degree,
- bool inflict = false);
-
private:
CasterLevel _casterLevel;
--- 105,115 ----
bool inflict = false);
Degree getDegree () const;
Target getTarget () const;
! void setTarget (ogs::core::Creature& creature);
bool inflictsWounds () const;
void castSpell ();
private:
CasterLevel _casterLevel;
***************
*** 123,126 ****
--- 118,126 ----
bool _inflict;
+ CureWounds (CasterLevel casterLevel,
+ Degree degree,
+ bool inflict = false);
+
+ static ogs::magic::Components createComponents ();
ogs::core::Die::Value rollHitPoints () const;
bool checkTargetWillSave () const;
***************
*** 151,155 ****
CureWounds::createLight (CasterLevel casterLevel,
bool inflict) {
! return (new CureWounds (casterLevel, LIGHT));
}
--- 151,155 ----
CureWounds::createLight (CasterLevel casterLevel,
bool inflict) {
! return (new CureWounds (casterLevel, LIGHT, inflict));
}
***************
*** 164,168 ****
CureWounds::createModerate (CasterLevel casterLevel,
bool inflict) {
! return (new CureWounds (casterLevel, MODERATE));
}
--- 164,168 ----
CureWounds::createModerate (CasterLevel casterLevel,
bool inflict) {
! return (new CureWounds (casterLevel, MODERATE, inflict));
}
***************
*** 194,221 ****
/**
- * 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.
- */
- inline const ogs::magic::School&
- CureWounds::getSchool () const {
- using ogs::magic::Subschool;
- static Subschool subschool (Subschool::HEALING);
- return (subschool);
- }
-
- /**
- * Determine the range of this spell. Cure wounds spells always have
- * touch range.
- *
- * @return Touch range.
- */
- inline ogs::magic::Range
- CureWounds::getRange () const {
- return (ogs::magic::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
--- 194,197 ----
***************
*** 237,242 ****
*/
inline void
! CureWounds::setTarget (Target target) {
! this->_target = target;
}
--- 213,218 ----
*/
inline void
! CureWounds::setTarget (ogs::core::Creature& creature) {
! this->_target = &creature;
}
|