ogs-changes Mailing List for Open Gaming System
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-11-26 01:44:18
|
Update of /cvsroot/ogs/dist/c++/ogs/support
In directory sc8-pr-cvs1:/tmp/cvs-serv18323
Modified Files:
Class.h
Log Message:
Modeled after TypeInfo from Loki library.
Index: Class.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Class.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Class.h 18 Apr 2003 01:41:07 -0000 1.2
--- Class.h 26 Nov 2003 01:44:11 -0000 1.3
***************
*** 1,4 ****
/*
! * Class.h -- class interface for class identification
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * Class.h -- class interface for type information
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 26,113 ****
# define OGS_SUPPORT_CLASS_H
! # include <string>
# include <typeinfo>
# include <ogs/support/Namespace.h>
- # include <ogs/support/Object.h>
OGS_BEGIN_SUPPORT_NAMESPACE
/**
! * An object representing the class of another object. This class is
! * actually a thin wrapper for the type_info class declared in the
! * @<typeinfo@> header of the standard C++ library.
*/
class Class {
public:
template <class C>
static Class getClass ();
- bool operator== (const Class& cls) const;
- bool operator!= (const Class& cls) const;
- std::string getName () const;
-
private:
! const std::type_info& typeInfo;
! Class ();
! Class (const std::type_info& typeInfo);
! friend Class Object::getClass () const;
! };
/**
! * Determine the class of a type. The type is given as a template
! * argument.
*
! * @return Class of type.
*/
! template <class C>
! inline Class Class::getClass () {
! Class c (typeid (C));
! return (c);
}
/**
! * Determine if this object describes the same class as another object.
*
! * @param cls Class to be compared to.
! * @return True if the two objects describe the same class.
*/
inline bool
! Class::operator== (const Class& cls) const {
! return (typeInfo == cls.typeInfo);
}
/**
! * Determine if this object does not describe the same class as another
! * object.
*
! * @param cls Class to be compared to.
! * @return True if each object describes a different class.
*/
! inline bool
! Class::operator!= (const Class& cls) const {
! return (typeInfo != cls.typeInfo);
}
/**
! * Determine the name of this class.
*
! * @return Name of class.
*/
! inline std::string Class::getName () const {
! return (std::string (typeInfo.name ()));
}
/**
! * Determine the class of this object.
*
! * @return Class of this object.
*/
! inline Class
! Object::getClass () const {
! return (Class (typeid (*this)));
}
OGS_END_SUPPORT_NAMESPACE
--- 26,158 ----
# define OGS_SUPPORT_CLASS_H
! # include <cassert>
# include <typeinfo>
# include <ogs/support/Namespace.h>
OGS_BEGIN_SUPPORT_NAMESPACE
/**
! * An object that represents the class of another object. This class is
! * actually a thin wrapper for the <code>type_info</code> class declared
! * in the @<typeinfo@> header of the standard C++ library.
*/
class Class {
public:
+ Class ();
+ Class (const std::type_info& typeInfo);
+
+ const std::type_info& getInfo () const;
+ const char* getName () const;
+ bool isBefore (const Class& rhs) const;
+
template <class C>
static Class getClass ();
private:
! const std::type_info* _typeInfo;
! };
! /**
! * Create a new class object. This constructor is provided for
! * containers that require default constructors.
! */
! inline
! Class::Class () {
! class Nil { };
! _typeInfo = &(typeid (Nil));
! assert (_typeInfo);
! }
!
! /**
! * Create a new class object from type info.
! *
! * @param typeInfo A type info object.
! */
! inline
! Class::Class (const std::type_info& typeInfo):
! _typeInfo (&typeInfo) {
! assert (_typeInfo);
! }
! /**
! * Determine the type info contained in this class.
! *
! * @return Type info.
! */
! inline const std::type_info&
! Class::getInfo () const {
! assert (_typeInfo);
! return (*_typeInfo);
! }
/**
! * Determine the name of this class.
*
! * @return Name of class.
*/
! inline const char*
! Class::getName () const {
! assert (_typeInfo);
! return (_typeInfo->name ());
}
/**
! * Determine if this class is before another class in logical order.
*
! * @param rhs Another class object.
! * @return True if this class is before the other class.
*/
inline bool
! Class::isBefore (const Class& rhs) const {
! assert (_typeInfo);
! // type_info::before return type is int in some VC libraries
! return (_typeInfo->before (*(rhs._typeInfo)) != 0);
}
/**
! * Determine the class of a type. The type is given as a template
! * argument.
*
! * @return Class of type.
*/
! template <class C>
! inline Class
! Class::getClass () {
! Class c (typeid (C));
! return (c);
}
/**
! * Determine if this class is equivalent to another class.
*
! * @param lhs Class on left-hand side of operator.
! * @param rhs Class on right-hand side of operator.
! * @return True if the two classes are equivalewnt.
*/
! inline bool
! operator== (const Class& lhs, const Class& rhs) {
! // type_info::operator== return type is int in some VC libraries
! return (lhs.getInfo () == rhs.getInfo ()) != 0;
}
/**
! * Determine if this class is less than another class. This operator is
! * used for imposing an order on class objects for operations like
! * sorting
*
! * @param lhs Class on left-hand side of operator.
! * @param rhs Class on right-hand side of operator.
! * @return True if @c lhs is less than @c rhs.
*/
! inline bool
! operator< (const Class& lhs, const Class& rhs) {
! return (lhs.isBefore (rhs));
}
+
+ /*
+ * Portions of this file adapted from The Loki Library
+ * Copyright (c) 2001 by Andrei Alexandrescu
+ */
OGS_END_SUPPORT_NAMESPACE
|
|
From: <ele...@us...> - 2003-06-30 12:41:04
|
Update of /cvsroot/ogs/dist/java In directory sc8-pr-cvs1:/tmp/cvs-serv17359/java Modified Files: AUTHORS Log Message: Changed email address. Index: AUTHORS =================================================================== RCS file: /cvsroot/ogs/dist/java/AUTHORS,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AUTHORS 7 Jan 2003 07:20:33 -0000 1.1 --- AUTHORS 30 Jun 2003 12:41:00 -0000 1.2 *************** *** 1 **** ! Eric Lemings <ele...@us...> --- 1 ---- ! Eric Lemings <er...@le...> |
|
From: <ele...@us...> - 2003-06-30 12:41:04
|
Update of /cvsroot/ogs/dist/c++ In directory sc8-pr-cvs1:/tmp/cvs-serv17359/c++ Modified Files: AUTHORS Log Message: Changed email address. Index: AUTHORS =================================================================== RCS file: /cvsroot/ogs/dist/c++/AUTHORS,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AUTHORS 7 Jan 2003 07:41:31 -0000 1.1 --- AUTHORS 30 Jun 2003 12:41:00 -0000 1.2 *************** *** 1 **** ! Eric Lemings <ele...@us...> --- 1 ---- ! Eric Lemings <er...@le...> |
|
From: <ele...@us...> - 2003-06-30 12:41:04
|
Update of /cvsroot/ogs/dist/c In directory sc8-pr-cvs1:/tmp/cvs-serv17359/c Modified Files: AUTHORS Log Message: Changed email address. Index: AUTHORS =================================================================== RCS file: /cvsroot/ogs/dist/c/AUTHORS,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AUTHORS 7 Jan 2003 07:52:04 -0000 1.1 --- AUTHORS 30 Jun 2003 12:41:00 -0000 1.2 *************** *** 1 **** ! Eric Lemings <ele...@us...> --- 1 ---- ! Eric Lemings <er...@le...> |
|
From: <ele...@us...> - 2003-06-30 12:41:04
|
Update of /cvsroot/ogs/dist In directory sc8-pr-cvs1:/tmp/cvs-serv17359 Modified Files: AUTHORS Log Message: Changed email address. Index: AUTHORS =================================================================== RCS file: /cvsroot/ogs/dist/AUTHORS,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AUTHORS 1 Nov 2001 00:09:02 -0000 1.1.1.1 --- AUTHORS 30 Jun 2003 12:41:00 -0000 1.2 *************** *** 1 **** ! Eric Lemings <ele...@us...> --- 1 ---- ! Eric Lemings <er...@le...> |
|
From: <ele...@us...> - 2003-05-15 02:25:35
|
Update of /cvsroot/ogs/dist/java In directory sc8-pr-cvs1:/tmp/cvs-serv8992 Modified Files: configure.in Log Message: Reversing the last commit since it doesn't work for some reason. Index: configure.in =================================================================== RCS file: /cvsroot/ogs/dist/java/configure.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** configure.in 15 May 2003 02:14:54 -0000 1.5 --- configure.in 15 May 2003 02:25:32 -0000 1.6 *************** *** 44,51 **** dnl Checks for programs. ! AC_CHECK_PROG(JAVAC, javac, no) ! AC_CHECK_PROG(JAR, jar, no) ! AC_CHECK_PROG(JAVADOC, javadoc, no) ! AC_CHECK_PROG(ANT, ant, no) AC_OUTPUT([ --- 44,51 ---- dnl Checks for programs. ! AC_PATH_PROG(JAVAC, javac, no) ! AC_PATH_PROG(JAR, jar, no) ! AC_PATH_PROG(JAVADOC, javadoc, no) ! AC_PATH_PROG(ANT, ant, no) AC_OUTPUT([ |
|
From: <ele...@us...> - 2003-05-15 02:14:57
|
Update of /cvsroot/ogs/dist/java/ogs/core
In directory sc8-pr-cvs1:/tmp/cvs-serv378/ogs/core
Modified Files:
Modifier.java Modifiers.java
Log Message:
See Java ChangeLog (May 14) for details.
Index: Modifier.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/core/Modifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifier.java 7 Jan 2003 07:20:33 -0000 1.1
--- Modifier.java 15 May 2003 02:14:54 -0000 1.2
***************
*** 28,78 ****
/**
! * A modifier is an integer value added to another integer value. If
! * the value of the modifier is negative, the modifier is subtracted
! * from the value.
*/
public class Modifier extends Object {
/**
! * An event indicating that a modifier has changed value.
*/
public class Event extends EventObject {
! private int previousValue;
/**
! * Create a new modifier event. The event <EM>must</EM> be created
! * <EM>before</EM> the value of the modifier is actually changed.
*
! * @param modifier Modifier that changed value.
*/
Event (Modifier modifier) {
super ((java.lang.Object) modifier);
! this.previousValue = modifier.getValue ();
}
/**
! * Determine previous value of modifier.
*
! * @return Previous value of modifier.
*/
public int getPreviousValue () {
! return (this.previousValue);
}
}
- private int value = 0;
-
/**
! * Create a modifier with a zero (0) value.
*/
public Modifier () {
! // All field declarations above have instance initializers.
}
/**
! * Create a modifier with a specified value.
*
! * @param value Value of the modifier.
*/
public Modifier (int value) {
--- 28,93 ----
/**
! * 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 object 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. <p>
*/
public class Modifier extends Object {
+ /*
+ * TODO: The type of modifier values should probably be <code>short
+ * int</code>. For some reason though , Java programmers don't seem to
+ * like any integer type except plain old <code>int</code>. <p>
+ */
+
+ private int value = 0;
/**
! * An event that allows observers to determine the previous value of
! * the modifier. <em>Modifier events must be created before the
! * modifier value is changed so the event can store the previous
! * value!</em>
*/
public class Event extends EventObject {
! private int value;
/**
! * 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.
*/
Event (Modifier modifier) {
+ /*
+ * TODO: Make constructor visible only to Modifier.setValue()
+ * method if possible.
+ */
super ((java.lang.Object) modifier);
! this.value = modifier.getValue ();
}
/**
! * Determine the previous value of the modifier.
*
! * @return Previous value of the modifier.
*/
public int getPreviousValue () {
! return (this.value);
}
}
/**
! * Create a new modifier. The value of the new modifier is zero (0).
*/
public Modifier () {
! this.value = 0;
}
/**
! * Create a new modifier with a specified value.
*
! * @param value Value of this modifier.
*/
public Modifier (int value) {
***************
*** 81,87 ****
/**
! * Determine the value of the modifier.
*
! * @return Value of the modifier.
*/
public int getValue () {
--- 96,102 ----
/**
! * Determine the value of this modifier.
*
! * @return Value of this modifier.
*/
public int getValue () {
***************
*** 90,96 ****
/**
! * Change the value of the modifier. Notifies listeners.
*
! * @param value Value of the modifier.
*/
public void setValue (int value) {
--- 105,112 ----
/**
! * Change the value of this modifier. This method notifies
! * listeners of this modifier with a modifier event.
*
! * @param value Value of this modifier.
*/
public void setValue (int value) {
***************
*** 99,103 ****
notifyListeners (event);
}
-
}
--- 115,118 ----
Index: Modifiers.java
===================================================================
RCS file: /cvsroot/ogs/dist/java/ogs/core/Modifiers.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Modifiers.java 7 Jan 2003 07:20:33 -0000 1.1
--- Modifiers.java 15 May 2003 02:14:55 -0000 1.2
***************
*** 23,26 ****
--- 23,27 ----
package ogs.core;
+ import java.util.EventObject;
import java.util.Vector;
***************
*** 29,42 ****
/**
! * A list of modifiers.
*/
public class Modifiers extends ogs.support.Object {
! private Vector vector;
! private int value;
/**
! * Add a modifier to this list of modifiers. The total value is
! * updated accordingly and observers are notified.
*
* @param modifier A modifier.
--- 30,128 ----
/**
! * 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.
*/
public class Modifiers extends ogs.support.Object {
! private Vector vector = null;
! private int value = 0;
/**
! * An event that allows observers to determine changes to the list.
! * The changes to a modifiers list include the previous total value of
! * the list, the type of event (whether a modifier changed, was added,
! * or removed), and the modifier described by the event type.
! * <em>Modifier list events must be created before the list is changed
! * so the event can store this information!</em>
! */
! public class Event extends EventObject {
!
! private int value;
! private int type;
! private Modifier modifier;
!
! /** A constant that indicates a modifier was added to the list. */
! public static final int ADDED = 1;
!
! /** A constant that indicates a modifier was removed from the list. */
! public static final int REMOVED = 2;
!
! /** A constant that indicates a modifier in the list changed value. */
! public static final int CHANGED = 3;
!
! /**
! * 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.
! * @param type Type of this event.
! * @param modifier Modifier referenced by this event.
! */
! public Event (Modifiers modifiers, int type, Modifier modifier) {
! super ((java.lang.Object) modifiers);
! this.value = modifiers.getValue ();
! this.type = type;
! this.modifier = modifier;
! }
!
! /**
! * Determine the previous value of this list of modifiers.
! *
! * @return Previous value of the list of modifiers.
! */
! public int getPreviousValue () {
! return (this.value);
! }
!
! /**
! * Determine the type of this event. The modifier that caused this
! * type of event can be determined using the getModifier() method.
! *
! * @return Type of this event.
! */
! public int getType () {
! return (this.type);
! }
!
! /**
! * Determine the modifier described by the type of this event. The
! * type of modifier event can be determined using the getType()
! * method.
! *
! * @return Modifier described by the type of this event.
! */
! public Modifier getModifier () {
! return (this.modifier);
! }
! }
!
! /**
! * Create an empty list of modifiers.
! */
! public Modifiers () {
! this.vector = new Vector ();
! this.value = 0;
! }
!
! /**
! * 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.
***************
*** 44,60 ****
public void addModifier (Modifier modifier) {
// Add modifier to list.
! if (! vector.contains ((Object) modifier)) {
! modifier.addListener ((Object) this);
! vector.add ((Object) modifier);
! // Update total value of modifiers.
! this.value += modifier.getValue ();
! notifyListeners (null);
! }
}
/**
! * Remove a modifier from this list of modifiers. The total value is
! * updated accordingly and observers are notified.
*
* @param modifier A modifier.
--- 130,145 ----
public void addModifier (Modifier modifier) {
// Add modifier to list.
! modifier.addListener ((Object) this);
! vector.add ((Object) modifier);
! // Update total value of modifiers.
! Event event = new Event (this, Event.ADDED, modifier);
! this.value += modifier.getValue ();
! notifyListeners (event);
}
/**
! * 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.
***************
*** 66,71 ****
// Update total value of modifiers.
this.value -= modifier.getValue ();
! notifyListeners (null);
}
}
--- 151,157 ----
// Update total value of modifiers.
+ Event event = new Event (this, Event.REMOVED, modifier);
this.value -= modifier.getValue ();
! notifyListeners (event);
}
}
***************
*** 81,90 ****
/**
! * Update the total value when a modifier changes value.
*
! * @param event An event.
*/
! public void handleEvent (Modifier.Event event) {
}
}
--- 167,194 ----
/**
! * Update the total value for this list of modifiers. The total value
! * is updated when the value of a modifier in the list changes values.
! * Events other than modifier events are ignored.
*
! * @param eventObject An event object.
*/
! public void handleEvent (java.util.EventObject eventObject) {
! try {
! Modifier.Event event = (Modifier.Event) eventObject;
! Modifier modifier = (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.
+ */
+ Modifiers.Event newEvent =
+ new Modifiers.Event (this, Event.CHANGED, modifier);
+ this.value -= event.getPreviousValue ();
+ this.value += modifier.getValue ();
+ notifyListeners (newEvent);
+ } catch (ClassCastException exception) {
+ // Event is not a modifier event. Ignore it.
+ }
}
}
|
|
From: <ele...@us...> - 2003-05-15 02:14:57
|
Update of /cvsroot/ogs/dist/java In directory sc8-pr-cvs1:/tmp/cvs-serv378 Modified Files: ChangeLog configure.in Log Message: See Java ChangeLog (May 14) for details. Index: ChangeLog =================================================================== RCS file: /cvsroot/ogs/dist/java/ChangeLog,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ChangeLog 18 Apr 2003 20:39:45 -0000 1.7 --- ChangeLog 15 May 2003 02:14:54 -0000 1.8 *************** *** 1,3 **** --- 1,9 ---- + Thu May 15 02:07:06 UTC 2003 Eric Lemings <ele...@us...> + + * configure.in: Changed AC_PATH_PROG to AC_CHECK_PROG. + + * ogs/core/Modifier*: Minor changes and doc updates from C++. + Fri Apr 18 20:33:43 UTC 2003 Eric Lemings <ele...@us...> Index: configure.in =================================================================== RCS file: /cvsroot/ogs/dist/java/configure.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** configure.in 4 Apr 2003 20:22:47 -0000 1.4 --- configure.in 15 May 2003 02:14:54 -0000 1.5 *************** *** 44,51 **** dnl Checks for programs. ! AC_PATH_PROG(JAVAC, javac, no) ! AC_PATH_PROG(JAR, jar, no) ! AC_PATH_PROG(JAVADOC, javadoc, no) ! AC_PATH_PROG(ANT, ant, no) AC_OUTPUT([ --- 44,51 ---- dnl Checks for programs. ! AC_CHECK_PROG(JAVAC, javac, no) ! AC_CHECK_PROG(JAR, jar, no) ! AC_CHECK_PROG(JAVADOC, javadoc, no) ! AC_CHECK_PROG(ANT, ant, no) AC_OUTPUT([ |
|
From: <ele...@us...> - 2003-05-02 19:13:26
|
Update of /cvsroot/ogs/dist/c++/doc In directory sc8-pr-cvs1:/tmp/cvs-serv4706 Modified Files: Doxyfile.in Log Message: Added core/moves and creatures/undeads namespaces. Index: Doxyfile.in =================================================================== RCS file: /cvsroot/ogs/dist/c++/doc/Doxyfile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Doxyfile.in 15 Apr 2003 16:58:28 -0000 1.2 --- Doxyfile.in 2 May 2003 19:13:23 -0000 1.3 *************** *** 360,363 **** --- 360,364 ---- INPUT += @top_srcdir@/ogs/core INPUT += @top_srcdir@/ogs/core/details + INPUT += @top_srcdir@/ogs/core/moves #INPUT += @top_srcdir@/ogs/combat #INPUT += @top_srcdir@/ogs/combat/actions *************** *** 368,371 **** --- 369,373 ---- INPUT += @top_srcdir@/ogs/creatures INPUT += @top_srcdir@/ogs/creatures/humanoids + INPUT += @top_srcdir@/ogs/creatures/undeads INPUT += @top_srcdir@/ogs/feats INPUT += @top_srcdir@/ogs/items |
|
From: <ele...@us...> - 2003-05-02 19:09:02
|
Update of /cvsroot/ogs/dist/c++/ogs/magic In directory sc8-pr-cvs1:/tmp/cvs-serv1789 Removed Files: Component.cpp LevelRange.cpp Log Message: Forgot to remove old source files. --- Component.cpp DELETED --- --- LevelRange.cpp DELETED --- |
|
From: <ele...@us...> - 2003-05-02 19:07:10
|
Update of /cvsroot/ogs/dist/c++/ogs/spells
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/spells
Modified Files:
Abjuration.h Conjuration.h Divination.h Enchantment.h
Evocation.h Illusion.h Makefile.am Namespace.h Necromancy.h
Transmutation.h Universal.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Abjuration.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Abjuration.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Abjuration.h 25 Feb 2003 19:40:28 -0000 1.3
--- Abjuration.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_SPELLS_ABJURATION_H
+ # include <cassert>
+
# include <ogs/magic/Spell.h>
# include <ogs/spells/Namespace.h>
***************
*** 31,34 ****
--- 33,39 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Abjuration school. This class is the abstract base
***************
*** 36,55 ****
*/
class Abjuration: public ogs::magic::Spell {
! public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Abjuration spells
! * are in the Abjuration school.
! *
! * @return Abjuration school.
*/
! inline const ogs::magic::School& Abjuration::getSchool () const {
! // If school needs to be visible outside this function, promote school
! // to a private static member.
! using ogs::magic::School;
! static School school (School::ABJURATION);
! return (school);
}
--- 41,59 ----
*/
class Abjuration: public ogs::magic::Spell {
! protected:
! Abjuration (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new abjuration spell.
*/
! inline
! Abjuration::Abjuration (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::ABJURATION), components, range, descriptors) {
! // empty constructor body
}
Index: Conjuration.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Conjuration.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Conjuration.h 25 Feb 2003 19:40:29 -0000 1.3
--- Conjuration.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_SPELLS_CONJURATION_H
+ # include <cassert>
+
# include <ogs/magic/Spell.h>
# include <ogs/spells/Namespace.h>
***************
*** 31,34 ****
--- 33,39 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Conjuration school. This class is the abstract base
***************
*** 36,55 ****
*/
class Conjuration: public ogs::magic::Spell {
! public:
! virtual const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school (or subschool) for this type of spell. All
! * Conjuration spells are in the Conjuration school or a Conjuration
! * subschool. Derived classes may override this function to return a
! * Conjuration subschool.
! *
! * @return Conjuration school.
*/
! inline const ogs::magic::School& Conjuration::getSchool () const {
! using ogs::magic::School;
! static School school (School::CONJURATION);
! return (school);
}
--- 41,69 ----
*/
class Conjuration: public ogs::magic::Spell {
! protected:
! Conjuration (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school = School (School::CONJURATION),
! Descriptors descriptors = Descriptors ());
! virtual ~Conjuration () = 0;
};
/**
! * Create a new conjuration spell. The school of the new conjuration
! * spell is the conjuration school by default but derived classes can
! * specify a conjuration subschool instead.
*/
! inline
! Conjuration::Conjuration (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school,
! Descriptors descriptors):
! Spell (school, components, range, descriptors) {
! assert (school.getType () == School::CONJURATION);
! }
!
! inline
! Conjuration::~Conjuration () {
! // empty destructor body
}
Index: Divination.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Divination.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Divination.h 25 Feb 2003 19:40:29 -0000 1.3
--- Divination.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,34 ****
--- 31,37 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Divination school. This class is the abstract base
***************
*** 36,53 ****
*/
class Divination: public ogs::magic::Spell {
! public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Divination spells
! * are in the Divination school.
! *
! * @return Divination school.
*/
! inline const ogs::magic::School& Divination::getSchool () const {
! using ogs::magic::School;
! static School school (School::DIVINATION);
! return (school);
}
--- 39,57 ----
*/
class Divination: public ogs::magic::Spell {
! protected:
! Divination (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new divination spell.
*/
! inline
! Divination::Divination (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::DIVINATION), components, range, descriptors) {
! // empty constructor body
}
Index: Enchantment.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Enchantment.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Enchantment.h 25 Feb 2003 19:40:30 -0000 1.3
--- Enchantment.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_SPELLS_ENCHANTMENT_H
+ # include <cassert>
+
# include <ogs/magic/Spell.h>
# include <ogs/spells/Namespace.h>
***************
*** 31,34 ****
--- 33,39 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Enchantment school. This class is the abstract base
***************
*** 36,55 ****
*/
class Enchantment: public ogs::magic::Spell {
! public:
! virtual const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school (or subschool) for this type of spell. All
! * Enchantment spells are in the Enchantment school or an Enchantment
! * subschool. Derived classes may override this function to return an
! * Enchantment subschool.
! *
! * @return Enchantment school.
*/
! inline const ogs::magic::School& Enchantment::getSchool () const {
! using ogs::magic::School;
! static School school (School::ENCHANTMENT);
! return (school);
}
--- 41,63 ----
*/
class Enchantment: public ogs::magic::Spell {
! protected:
! Enchantment (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school = School (School::ENCHANTMENT),
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new enchantment spell. The school of the new enchantment
! * spell is the enchantment school by default but derived classes can
! * specify a enchantment subschool instead.
*/
! inline
! Enchantment::Enchantment (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school,
! Descriptors descriptors):
! Spell (school, components, range, descriptors) {
! assert (school.getType () == School::ENCHANTMENT);
}
Index: Evocation.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Evocation.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Evocation.h 25 Feb 2003 19:40:31 -0000 1.3
--- Evocation.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,34 ****
--- 31,37 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Evocation school. This class is the abstract base
***************
*** 37,53 ****
class Evocation: public ogs::magic::Spell {
public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Evocation spells
! * are in the Evocation school.
! *
! * @return Evocation school.
*/
! inline const ogs::magic::School& Evocation::getSchool () const {
! using ogs::magic::School;
! static School school (School::EVOCATION);
! return (school);
}
--- 40,57 ----
class Evocation: public ogs::magic::Spell {
public:
! Evocation (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new evocation spell.
*/
! inline
! Evocation::Evocation (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::EVOCATION), components, range, descriptors) {
! // empty constructor body
}
Index: Illusion.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Illusion.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Illusion.h 25 Feb 2003 19:40:32 -0000 1.3
--- Illusion.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_SPELLS_ILLUSION_H
+ # include <cassert>
+
# include <ogs/magic/Spell.h>
# include <ogs/spells/Namespace.h>
***************
*** 31,34 ****
--- 33,39 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Illusion school. This class is the abstract base
***************
*** 36,55 ****
*/
class Illusion: public ogs::magic::Spell {
! public:
! virtual const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school (or subschool) for this type of spell. All
! * Illusion spells are in the Illusion school or an Illusion subschool.
! * Derived classes may override this function to return an Illusion
! * subschool.
! *
! * @return Illusion school.
*/
! inline const ogs::magic::School& Illusion::getSchool () const {
! using ogs::magic::School;
! static School school (School::ILLUSION);
! return (school);
}
--- 41,63 ----
*/
class Illusion: public ogs::magic::Spell {
! protected:
! Illusion (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school = School (School::ILLUSION),
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new illusion spell. The school of the new illusion
! * spell is the illusion school by default but derived classes can
! * specify a illusion subschool instead.
*/
! inline
! Illusion::Illusion (ogs::magic::Components components,
! const ogs::magic::Range& range,
! const School& school,
! Descriptors descriptors):
! Spell (school, components, range, descriptors) {
! assert (school.getType () == School::ILLUSION);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 23 Mar 2003 22:14:36 -0000 1.5
--- Makefile.am 2 May 2003 19:06:35 -0000 1.6
***************
*** 56,60 ****
libogs_spells_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_spells_la_DEPENDENCIES = \
! $(top_builddir)/ogs/magic/libogs-magic.la
libogs_spells_la_SOURCES =
--- 56,63 ----
libogs_spells_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_spells_la_DEPENDENCIES = \
! $(top_builddir)/ogs/magic/libogs-magic.la \
! conjurations/libogs-conjurations.la
libogs_spells_la_SOURCES =
+ libogs_spells_la_LIBADD = \
+ conjurations/libogs-conjurations.la
Index: Namespace.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Namespace.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Namespace.h 18 Apr 2003 01:41:07 -0000 1.3
--- Namespace.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,44 ****
* @namespace ogs::spells
*
! * Abstract base classes for spells in each school of magic. A campaign
! * set in a magical game world can literally have hundreds of different
! * spells. For this reason, grouping the spells by school is a good way
! * to organize the spell classes. The classes in this package are used
! * as the base classes for these spells.
! *
! * @todo
! * Change the school and subschool virtual functions into data members
! * of the @c Spell class passed in by the constructor. Remove the base
! * classes for spells.
*/
# define OGS_BEGIN_SPELLS_NAMESPACE \
--- 31,39 ----
* @namespace ogs::spells
*
! * Abstract base classes for spells in each school of magic. A magical
! * campaign setting can literally have hundreds of different spells.
! * To partition this class hierarchy, this namespace provides base
! * classes for spells in each school rather than deriving hundreds of
! * spells directly from the @c Spell class.
*/
# define OGS_BEGIN_SPELLS_NAMESPACE \
Index: Necromancy.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Necromancy.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Necromancy.h 25 Feb 2003 19:40:33 -0000 1.3
--- Necromancy.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,34 ****
--- 31,37 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Necromancy school. This class is the abstract base
***************
*** 37,53 ****
class Necromancy: public ogs::magic::Spell {
public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Necromancy spells
! * are in the Necromancy school.
! *
! * @return Necromancy school.
*/
! inline const ogs::magic::School& Necromancy::getSchool () const {
! using ogs::magic::School;
! static School school (School::NECROMANCY);
! return (school);
}
--- 40,57 ----
class Necromancy: public ogs::magic::Spell {
public:
! Necromancy (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new necromancy spell.
*/
! inline
! Necromancy::Necromancy (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::NECROMANCY), components, range, descriptors) {
! // empty constructor body
}
Index: Transmutation.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Transmutation.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Transmutation.h 25 Feb 2003 19:40:34 -0000 1.3
--- Transmutation.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,34 ****
--- 31,37 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Transmutation school. This class is the abstract base
***************
*** 37,53 ****
class Transmutation: public ogs::magic::Spell {
public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Transmutation
! * spells are in the Transmutation school.
! *
! * @return Transmutation school.
*/
! inline const ogs::magic::School& Transmutation::getSchool () const {
! using ogs::magic::School;
! static School school (School::TRANSMUTATION);
! return (school);
}
--- 40,57 ----
class Transmutation: public ogs::magic::Spell {
public:
! Transmutation (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new transmutation spell.
*/
! inline
! Transmutation::Transmutation (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::TRANSMUTATION), components, range, descriptors) {
! // empty constructor body
}
Index: Universal.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/spells/Universal.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Universal.h 25 Feb 2003 19:40:34 -0000 1.3
--- Universal.h 2 May 2003 19:06:35 -0000 1.4
***************
*** 31,34 ****
--- 31,37 ----
OGS_BEGIN_SPELLS_NAMESPACE
+ using ogs::magic::School;
+ using ogs::magic::Descriptors;
+
/**
* A spell in the Universal school. This class is the abstract base
***************
*** 37,53 ****
class Universal: public ogs::magic::Spell {
public:
! const ogs::magic::School& getSchool () const;
};
/**
! * Determine the school for this type of spell. All Universal spells
! * are in the Universal school.
! *
! * @return Universal school.
*/
! inline const ogs::magic::School& Universal::getSchool () const {
! using ogs::magic::School;
! static School school (School::UNIVERSAL);
! return (school);
}
--- 40,57 ----
class Universal: public ogs::magic::Spell {
public:
! Universal (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors = Descriptors ());
};
/**
! * Create a new universal spell.
*/
! inline
! Universal::Universal (ogs::magic::Components components,
! const ogs::magic::Range& range,
! Descriptors descriptors):
! Spell (School (School::UNIVERSAL), components, range, descriptors) {
! // empty constructor body
}
|
|
From: <ele...@us...> - 2003-05-02 19:07:09
|
Update of /cvsroot/ogs/dist/c++/ogs/magic
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/magic
Modified Files:
AbsoluteRange.h Component.h Descriptors.h LevelRange.h
Makefile.am PhysicalComponent.h Range.h School.cpp School.h
Spell.cpp Spell.h Subschool.cpp Subschool.h Types.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: AbsoluteRange.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/AbsoluteRange.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AbsoluteRange.h 18 Apr 2003 01:41:06 -0000 1.2
--- AbsoluteRange.h 2 May 2003 19:06:32 -0000 1.3
***************
*** 37,48 ****
class AbsoluteRange: public Range {
public:
! AbsoluteRange (float distance);
! float getDistance () const;
protected:
/** Maximum distance of this spell range. */
! float distance;
! AbsoluteRange (Range::Type type, float distance);
};
--- 37,52 ----
class AbsoluteRange: public Range {
public:
! /** A floating-point type representing distance. */
! typedef double Distance;
!
! AbsoluteRange (Distance distance);
! Distance getDistance () const;
! virtual Range* createCopy () const;
protected:
/** Maximum distance of this spell range. */
! Distance _distance;
! AbsoluteRange (Range::Type type, Distance distance);
};
***************
*** 52,58 ****
* @param distance Maximum distance of absolute range.
*/
! inline AbsoluteRange::AbsoluteRange (float distance):
! Range (Range::ABSOLUTE) {
! this->distance = distance;
}
--- 56,64 ----
* @param distance Maximum distance of absolute range.
*/
! inline
! AbsoluteRange::AbsoluteRange (Distance distance):
! Range (Range::ABSOLUTE),
! _distance (distance) {
! // empty constructor body
}
***************
*** 60,69 ****
* Create a new absolute range based on caster level.
*
! * @param type Type of spell range: CLOSE, MEDIUM, or LONG.
* @param distance Maximum distance of absolute range.
*/
! inline AbsoluteRange::AbsoluteRange (Range::Type type, float distance):
! Range (type) {
! this->distance = distance;
}
--- 66,87 ----
* Create a new absolute range based on caster level.
*
! * @param type Type of spell range (CLOSE, MEDIUM, or LONG).
* @param distance Maximum distance of absolute range.
*/
! inline
! AbsoluteRange::AbsoluteRange (Range::Type type, Distance distance):
! Range (type),
! _distance (distance) {
! // empty constructor body
! }
!
! /**
! * Create a copy of this absolute range.
! *
! * @return A pointer to a copy of this absolute range.
! */
! inline Range*
! AbsoluteRange::createCopy () const {
! return (new AbsoluteRange (*this));
}
***************
*** 73,78 ****
* @return Distance of absolute range.
*/
! inline float AbsoluteRange::getDistance () const {
! return (this->distance);
}
--- 91,97 ----
* @return Distance of absolute range.
*/
! inline AbsoluteRange::Distance
! AbsoluteRange::getDistance () const {
! return (this->_distance);
}
Index: Component.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Component.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Component.h 27 Feb 2003 22:42:17 -0000 1.2
--- Component.h 2 May 2003 19:06:32 -0000 1.3
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_MAGIC_COMPONENT_H
+ # include <sstream>
+ # include <stdexcept>
# include <string>
***************
*** 104,108 ****
* @return Verbal spell component.
*/
! inline Component Component::Verbal () {
return (Component (Component::VERBAL));
}
--- 106,111 ----
* @return Verbal spell component.
*/
! inline Component
! Component::Verbal () {
return (Component (Component::VERBAL));
}
***************
*** 113,117 ****
* @return Somantic spell component.
*/
! inline Component Component::Somantic () {
return (Component (Component::SOMANTIC));
}
--- 116,121 ----
* @return Somantic spell component.
*/
! inline Component
! Component::Somantic () {
return (Component (Component::SOMANTIC));
}
***************
*** 122,126 ****
* @return Spell component with Divine Focus type.
*/
! inline Component Component::DivineFocus () {
return (Component (Component::DIVINE_FOCUS));
}
--- 126,131 ----
* @return Spell component with Divine Focus type.
*/
! inline Component
! Component::DivineFocus () {
return (Component (Component::DIVINE_FOCUS));
}
***************
*** 131,135 ****
* @return Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
*/
! inline Component::Type Component::getType () const {
return (this->_type);
}
--- 136,141 ----
* @return Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
*/
! inline Component::Type
! Component::getType () const {
return (this->_type);
}
***************
*** 140,144 ****
* @return Abbreviation for this type of component.
*/
! inline std::string Component::getAbbreviation () const {
return (this->_type == VERBAL? "V":
this->_type == SOMANTIC? "S":
--- 146,151 ----
* @return Abbreviation for this type of component.
*/
! inline std::string
! Component::getAbbreviation () const {
return (this->_type == VERBAL? "V":
this->_type == SOMANTIC? "S":
***************
*** 150,153 ****
--- 157,176 ----
/**
+ * Create a new component.
+ *
+ * @param type Type of component (VERBAL, SOMANTIC, MATERIAL, etc.)
+ * @throws std::invalid_argument If type is not a valid component type.
+ */
+ inline
+ Component::Component (Type type):
+ _type (type) {
+ if (! isValid (type)) {
+ std::ostringstream ostr;
+ ostr << "invalid component type (" << int (type) << ")";
+ throw std::invalid_argument (ostr.str ());
+ }
+ }
+
+ /**
* Determine if an integer value is a valid type of component.
*
***************
*** 155,159 ****
* @return True if integer value is a valid type of component.
*/
! inline bool Component::isValid (int value) {
return (value == VERBAL ||
value == SOMANTIC ||
--- 178,183 ----
* @return True if integer value is a valid type of component.
*/
! inline bool
! Component::isValid (int value) {
return (value == VERBAL ||
value == SOMANTIC ||
Index: Descriptors.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Descriptors.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Descriptors.h 7 Jan 2003 07:41:33 -0000 1.1
--- Descriptors.h 2 May 2003 19:06:32 -0000 1.2
***************
*** 48,53 ****
* type can be used as bit positions in the @c std::bitset class.
* If this class is extended, values ranging from 0 to 16 are
! * reserved. This type is explicitly named in case the underlying
! * type should changes in the future.
*/
typedef size_t Type;
--- 48,52 ----
* type can be used as bit positions in the @c std::bitset class.
* If this class is extended, values ranging from 0 to 16 are
! * reserved.
*/
typedef size_t Type;
Index: LevelRange.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/LevelRange.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LevelRange.h 13 Apr 2003 05:27:50 -0000 1.3
--- LevelRange.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 23,28 ****
#ifdef __cplusplus
! # ifndef OGS_MAGIC_LEVELRANGE_H
! # define OGS_MAGIC_LEVELRANGE_H
# include <ogs/core/Experience.h>
--- 23,28 ----
#ifdef __cplusplus
! # ifndef OGS_MAGIC_LEVEL_RANGE_H
! # define OGS_MAGIC_LEVEL_RANGE_H
# include <ogs/core/Experience.h>
***************
*** 32,37 ****
OGS_BEGIN_MAGIC_NAMESPACE
- using ogs::core::XP;
-
/**
* An absolute range that is based on caster level. Level-based spell
--- 32,35 ----
***************
*** 44,72 ****
class LevelRange: public AbsoluteRange {
public:
! static LevelRange Close (XP::Level casterLevel);
! static LevelRange Medium (XP::Level casterLevel);
! static LevelRange Long (XP::Level casterLevel);
! XP::Level getCasterLevel () const;
private:
! XP::Level casterLevel;
! LevelRange (Range::Type type, float distance,
! XP::Level casterLevel);
};
/**
* Determine the caster level for this level-based range.
*
* @return Caster level.
*/
! inline XP::Level LevelRange::getCasterLevel () const {
! return (this->casterLevel);
}
OGS_END_MAGIC_NAMESPACE
! # endif /* !defined OGS_MAGIC_LEVELRANGE_H */
#endif /* defined __cplusplus */
--- 42,136 ----
class LevelRange: public AbsoluteRange {
public:
! static LevelRange Close (ogs::core::XP::Level casterLevel);
! static LevelRange Medium (ogs::core::XP::Level casterLevel);
! static LevelRange Long (ogs::core::XP::Level casterLevel);
! ogs::core::XP::Level getCasterLevel () const;
!
! Range* createCopy () const;
private:
! ogs::core::XP::Level _casterLevel;
! LevelRange (Range::Type type,
! Distance distance,
! ogs::core::XP::Level casterLevel);
};
/**
+ * Create a close spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Close (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 25.0 + (5.0 * (casterLevel / 2));
+ return (LevelRange (Range::CLOSE, distance, casterLevel));
+ }
+
+ /**
+ * Create a medium spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Medium (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 100.0 + (10.0 * casterLevel);
+ return (LevelRange (Range::MEDIUM, distance, casterLevel));
+ }
+
+ /**
+ * Create a long spell range.
+ *
+ * @param casterLevel Level of spell caster.
+ */
+ inline LevelRange
+ LevelRange::Long (ogs::core::XP::Level casterLevel) {
+ // TODO: Change feet into locale dependent unit.
+ Distance distance = 400.0 + (40.0 * casterLevel);
+ return (LevelRange (Range::LONG, distance, casterLevel));
+ }
+
+ /**
* Determine the caster level for this level-based range.
*
* @return Caster level.
*/
! inline ogs::core::XP::Level
! LevelRange::getCasterLevel () const {
! return (this->_casterLevel);
! }
!
! /**
! * Create a copy of this level-based range.
! *
! * @return A pointer to a copy of this level-based range.
! */
! inline Range*
! LevelRange::createCopy () const {
! return (new LevelRange (*this));
! }
!
! /**
! * Create a new level-based range.
! *
! * @param type Type of spell range (CLOSE, MEDIUM, or LONG).
! * @param distance Maximum distance of range.
! * @param casterLevel Experience level of spell caster.
! */
! inline
! LevelRange::LevelRange (Range::Type type,
! Distance distance,
! ogs::core::XP::Level casterLevel):
! AbsoluteRange (type, distance),
! _casterLevel (casterLevel) {
! // empty constructor body
}
OGS_END_MAGIC_NAMESPACE
! # endif /* !defined OGS_MAGIC_LEVEL_RANGE_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Makefile.am 18 Apr 2003 03:24:42 -0000 1.8
--- Makefile.am 2 May 2003 19:06:32 -0000 1.9
***************
*** 58,63 ****
libogs_magic_la_SOURCES = \
Ability.cpp \
- Component.cpp \
- LevelRange.cpp \
MetamagicFeat.cpp \
School.cpp \
--- 58,61 ----
Index: PhysicalComponent.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/PhysicalComponent.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PhysicalComponent.h 28 Feb 2003 11:11:25 -0000 1.3
--- PhysicalComponent.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 41,55 ****
class PhysicalComponent: public Component {
public:
static PhysicalComponent
Material (const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
static PhysicalComponent
Focus (const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
const std::string& getDetails () const;
! float getCost () const;
bool useDivineFocus () const;
--- 41,61 ----
class PhysicalComponent: public Component {
public:
+ /**
+ * A floating-point type representing the monetary cost of a
+ * physical component.
+ */
+ typedef double Cost;
+
static PhysicalComponent
Material (const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
static PhysicalComponent
Focus (const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
const std::string& getDetails () const;
! Cost getCost () const;
bool useDivineFocus () const;
***************
*** 57,66 ****
PhysicalComponent (Component::Type type,
const std::string& details,
! float cost = 0.0,
bool useDivineFocus = false);
private:
std::string _details;
! float _cost;
bool _useDivineFocus;
};
--- 63,72 ----
PhysicalComponent (Component::Type type,
const std::string& details,
! Cost cost = 0.0,
bool useDivineFocus = false);
private:
std::string _details;
! Cost _cost;
bool _useDivineFocus;
};
***************
*** 77,81 ****
inline PhysicalComponent
PhysicalComponent::Material (const std::string& details,
! float cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::MATERIAL, details,
--- 83,87 ----
inline PhysicalComponent
PhysicalComponent::Material (const std::string& details,
! Cost cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::MATERIAL, details,
***************
*** 94,98 ****
inline PhysicalComponent
PhysicalComponent::Focus (const std::string& details,
! float cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::FOCUS, details,
--- 100,104 ----
inline PhysicalComponent
PhysicalComponent::Focus (const std::string& details,
! Cost cost,
bool useDivineFocus) {
return (PhysicalComponent (Component::FOCUS, details,
***************
*** 105,109 ****
* @return Details of component.
*/
! inline const std::string& PhysicalComponent::getDetails () const {
return (this->_details);
}
--- 111,116 ----
* @return Details of component.
*/
! inline const std::string&
! PhysicalComponent::getDetails () const {
return (this->_details);
}
***************
*** 114,118 ****
* @return Cost in standard monetary units.
*/
! inline float PhysicalComponent::getCost () const {
return (this->_cost);
}
--- 121,126 ----
* @return Cost in standard monetary units.
*/
! inline PhysicalComponent::Cost
! PhysicalComponent::getCost () const {
return (this->_cost);
}
***************
*** 124,128 ****
* @return True if divine fcous is required for divine spell.
*/
! inline bool PhysicalComponent::useDivineFocus () const {
return (this->_useDivineFocus);
}
--- 132,137 ----
* @return True if divine fcous is required for divine spell.
*/
! inline bool
! PhysicalComponent::useDivineFocus () const {
return (this->_useDivineFocus);
}
***************
*** 140,146 ****
PhysicalComponent::PhysicalComponent (Component::Type type,
const std::string& details,
! float cost,
bool useDivineFocus):
! Component (type), _details (details), _cost (cost),
_useDivineFocus (useDivineFocus) {
// empty body
--- 149,157 ----
PhysicalComponent::PhysicalComponent (Component::Type type,
const std::string& details,
! Cost cost,
bool useDivineFocus):
! Component (type),
! _details (details),
! _cost (cost),
_useDivineFocus (useDivineFocus) {
// empty body
Index: Range.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Range.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Range.h 29 Mar 2003 02:10:39 -0000 1.3
--- Range.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 74,77 ****
--- 74,78 ----
Type getType () const;
+ virtual Range* createCopy () const;
protected:
***************
*** 87,91 ****
* @return Spell range with Personal type.
*/
! inline Range Range::Personal () {
return (Range (Range::PERSONAL));
}
--- 88,93 ----
* @return Spell range with Personal type.
*/
! inline Range
! Range::Personal () {
return (Range (Range::PERSONAL));
}
***************
*** 96,100 ****
* @return Spell range with Touch type.
*/
! inline Range Range::Touch () {
return (Range (Range::TOUCH));
}
--- 98,103 ----
* @return Spell range with Touch type.
*/
! inline Range
! Range::Touch () {
return (Range (Range::TOUCH));
}
***************
*** 105,109 ****
* @return Spell range with Unlimited type.
*/
! inline Range Range::Unlimited () {
return (Range (Range::UNLIMITED));
}
--- 108,113 ----
* @return Spell range with Unlimited type.
*/
! inline Range
! Range::Unlimited () {
return (Range (Range::UNLIMITED));
}
***************
*** 114,118 ****
* @param type Type of range.
*/
! inline Range::Range (Type type): _type (type) {
// empty constructor body
}
--- 118,123 ----
* @param type Type of range.
*/
! inline Range::Range (Type type):
! _type (type) {
// empty constructor body
}
***************
*** 123,129 ****
* @return Type of spell range.
*/
! inline Range::Type Range::getType () const {
return (this->_type);
};
OGS_END_MAGIC_NAMESPACE
--- 128,145 ----
* @return Type of spell range.
*/
! inline
! Range::Type Range::getType () const {
return (this->_type);
};
+
+ /**
+ * Create a copy of this range.
+ *
+ * @return A pointer to a copy of this range.
+ */
+ inline Range*
+ Range::createCopy () const {
+ return (new Range (*this));
+ }
OGS_END_MAGIC_NAMESPACE
Index: School.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/School.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** School.cpp 25 Mar 2003 06:13:13 -0000 1.2
--- School.cpp 2 May 2003 19:06:32 -0000 1.3
***************
*** 1,4 ****
/*
! * School.cpp -- class implementation for School magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * School.cpp -- class implementation for arcane magic schools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 34,43 ****
* @throw invalid_argument If type is invalid.
*/
! inline School::School (Type type) {
! if (isValid (type)) {
! this->type = type;
! } else {
std::ostringstream ostr;
! ostr << "Invalid subschool type: " << type;
throw std::invalid_argument (ostr.str ());
}
--- 34,42 ----
* @throw invalid_argument If type is invalid.
*/
! School::School (Type type):
! _type (type) {
! if (! isValid (type)) {
std::ostringstream ostr;
! ostr << "invalid school type (" << int (type) << ")";
throw std::invalid_argument (ostr.str ());
}
***************
*** 47,62 ****
* Determine name of this school.
*
! * @return "Universal", "Abjuration", ...
*/
std::string School::getName () const {
! return (type == UNIVERSAL? "Universal":
! type == ABJURATION? "Abjuration":
! type == CONJURATION? "Conjuration":
! type == DIVINATION? "Divination":
! type == ENCHANTMENT? "Enchantment":
! type == EVOCATION? "Evocation":
! type == ILLUSION? "Illusion":
! type == NECROMANCY? "Necromancy":
! type == TRANSMUTATION? "Transmutation": "");
}
--- 46,61 ----
* Determine name of this school.
*
! * @return Name of school ("Universal", "Abjuration", etc.)
*/
std::string School::getName () const {
! return (this->_type == UNIVERSAL? "Universal":
! this->_type == ABJURATION? "Abjuration":
! this->_type == CONJURATION? "Conjuration":
! this->_type == DIVINATION? "Divination":
! this->_type == ENCHANTMENT? "Enchantment":
! this->_type == EVOCATION? "Evocation":
! this->_type == ILLUSION? "Illusion":
! this->_type == NECROMANCY? "Necromancy":
! this->_type == TRANSMUTATION? "Transmutation": "");
}
Index: School.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/School.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** School.h 23 Mar 2003 22:14:36 -0000 1.3
--- School.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 1,4 ****
/*
! * School.h -- class interface for schools of arcane magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * School.h -- class interface for arcane magic schools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 29,32 ****
--- 29,33 ----
# include <ogs/magic/Namespace.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
***************
*** 34,38 ****
/**
* A school of arcance magic. Each type of spell belongs to exactly one
! * school. The Wizard cclass may specialize in one of these schools.
*/
class School {
--- 35,40 ----
/**
* A school of arcance magic. Each type of spell belongs to exactly one
! * school. The Wizard cclass may specialize in one of these schools
! * (except the Universal school).
*/
class School {
***************
*** 43,47 ****
* Spells that deal with magic in general.
*/
! UNIVERSAL = 0,
/**
--- 45,49 ----
* Spells that deal with magic in general.
*/
! UNIVERSAL = 1,
/**
***************
*** 51,55 ****
* Transmutation; or both Divination and Necromancy.
*/
! ABJURATION = 1,
/**
--- 53,57 ----
* Transmutation; or both Divination and Necromancy.
*/
! ABJURATION,
/**
***************
*** 60,64 ****
* schools.
*/
! CONJURATION = 2,
/**
--- 62,66 ----
* schools.
*/
! CONJURATION,
/**
***************
*** 67,71 ****
* the wizard's choice.
*/
! DIVINATION = 3,
/**
--- 69,73 ----
* the wizard's choice.
*/
! DIVINATION,
/**
***************
*** 75,79 ****
* Divination and Necromancy.
*/
! ENCHANTMENT = 4,
/**
--- 77,81 ----
* Divination and Necromancy.
*/
! ENCHANTMENT,
/**
***************
*** 84,88 ****
* schools.
*/
! EVOCATION = 5,
/**
--- 86,90 ----
* schools.
*/
! EVOCATION,
/**
***************
*** 92,96 ****
* Transmutation; or both Divination and Necromancy.
*/
! ILLUSION = 6,
/**
--- 94,98 ----
* Transmutation; or both Divination and Necromancy.
*/
! ILLUSION,
/**
***************
*** 99,103 ****
* the wizard's choice.
*/
! NECROMANCY = 7,
/**
--- 101,105 ----
* the wizard's choice.
*/
! NECROMANCY,
/**
***************
*** 107,120 ****
* Enchantment, and Illusion; or (d) any three schools.
*/
! TRANSMUTATION = 8
};
School (Type type);
Type getType () const;
! std::string getName () const;
private:
! Type type;
! static bool isValid (Type type);
};
--- 109,124 ----
* Enchantment, and Illusion; or (d) any three schools.
*/
! TRANSMUTATION
};
School (Type type);
Type getType () const;
! virtual std::string getName () const;
! virtual School* createCopy () const;
private:
! Type _type;
!
! static bool isValid (int i);
};
***************
*** 124,147 ****
* @return Type of school.
*/
! inline School::Type School::getType () const {
! return (this->type);
}
/**
! * Determine if type is a valid school of magic.
*
! * @param type
! * @return True if type is a valid school of magic.
*/
! inline bool School::isValid (Type type) {
! return (type == UNIVERSAL ||
! type == ABJURATION ||
! type == CONJURATION ||
! type == DIVINATION ||
! type == ENCHANTMENT ||
! type == EVOCATION ||
! type == ILLUSION ||
! type == NECROMANCY ||
! type == TRANSMUTATION);
}
--- 128,163 ----
* @return Type of school.
*/
! inline School::Type
! School::getType () const {
! return (this->_type);
}
/**
! * Determine if an integer value is a valid school of magic.
*
! * @param i An integer value.
! * @return True if integer value is a valid school of magic.
*/
! inline bool
! School::isValid (int i) {
! return (i == UNIVERSAL ||
! i == ABJURATION ||
! i == CONJURATION ||
! i == DIVINATION ||
! i == ENCHANTMENT ||
! i == EVOCATION ||
! i == ILLUSION ||
! i == NECROMANCY ||
! i == TRANSMUTATION);
! }
!
! /**
! * Create a new copy of this school.
! *
! * @return A pointer to a copy of this school.
! */
! inline School*
! School::createCopy () const {
! return (new School (*this));
}
Index: Spell.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Spell.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Spell.cpp 4 Apr 2003 20:22:46 -0000 1.4
--- Spell.cpp 2 May 2003 19:06:32 -0000 1.5
***************
*** 30,45 ****
* Attach a metamagic feat to this spell.
*
! * @param metamagicFeat A metamagic feat.
* @return True if metamagic feat is attached to this spell.
*/
bool Spell::attachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool success = false;
! if (metamagicFeat.attachObject (*this)) {
! this->_metamagicFeats.push_back (&metamagicFeat);
! success = true;
}
! return (success);
}
--- 30,60 ----
* Attach a metamagic feat to this spell.
*
! * @param metamagicFeat A metamagic feat to attach to this spell.
* @return True if metamagic feat is attached to this spell.
*/
bool Spell::attachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool attached = metamagicFeat.attachSpell (*this);
! if (attached) {
! this->_metamagicFeats.push_back (MetamagicFeatPtr (&metamagicFeat));
}
! return (attached);
! }
!
! /**
! * Detach a metamgaic feat from this spell.
! *
! * @param metamagicFeat A metamagic feat to detach from this spell.
! * @param True if metamagic feat is detached from this spell.
! */
! bool Spell::detachMetamagicFeat (MetamagicFeat& metamagicFeat) {
! bool detached = metamagicFeat.detachSpell ();
!
! if (detached) {
! this->_metamagicFeats.remove (MetamagicFeatPtr (&metamagicFeat));
! }
!
! return (detached);
}
Index: Spell.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Spell.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Spell.h 4 Apr 2003 20:22:47 -0000 1.5
--- Spell.h 2 May 2003 19:06:32 -0000 1.6
***************
*** 27,38 ****
# include <list>
- # include <vector>
# include <ogs/support/Object.h>
- # include <ogs/magic/Component.h>
# include <ogs/magic/Descriptors.h>
# include <ogs/magic/Namespace.h>
# include <ogs/magic/Range.h>
# include <ogs/magic/School.h>
OGS_BEGIN_MAGIC_NAMESPACE
--- 27,37 ----
# include <list>
# include <ogs/support/Object.h>
# include <ogs/magic/Descriptors.h>
# include <ogs/magic/Namespace.h>
# include <ogs/magic/Range.h>
# include <ogs/magic/School.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
***************
*** 45,109 ****
class Spell: public ogs::support::Object {
public:
! /** A list of spell components. */
! typedef std::list<Component> Components;
!
! /**
! * Determine the school (and subschool if applicable) that this
! * spell belongs to.
! *
! * @return School (and subschool) of this spell.
! */
! virtual const School& getSchool () const = 0;
!
! virtual Descriptors getDescriptors () const;
!
! /**
! * Determine the components needed to cast this spell. The
! * components of a spell may vary from plain versions of the spell
! * due to metamagic feats.
! *
! * @return Array of components for this spell.
! */
! virtual Components getComponents () const = 0;
!
! /**
! * Determine the range of this spell. The range of a spell may vary
! * from normal versions of the spell due to metamagic feats.
! *
! * @return Range of this spell.
! */
! virtual Range getRange () const = 0;
virtual bool attachMetamagicFeat (MetamagicFeat& metamagicFeat);
virtual ~Spell () { }
protected:
! Spell ();
private:
! typedef std::vector<MetamagicFeat*> MetamagicFeats;
MetamagicFeats _metamagicFeats;
};
/**
! * Determine descriptors for this spell. Many spells have no
! * descriptors. Therefore, this function returns an empty set of
! * descriptors by default. Derived classes must override this function
! * if the spell has @em any descriptors.
*
* @return Descriptors for this spell.
*/
! inline Descriptors Spell::getDescriptors () const {
! Descriptors descriptors;
! return (descriptors);
}
/**
! * Create a new spell. This constructor is protected so only this class
! * and derived classes can use it. All it does is create an empty array
! * of metamagic feats.
*/
! inline Spell::Spell (): _metamagicFeats () { }
OGS_END_MAGIC_NAMESPACE
--- 44,134 ----
class Spell: public ogs::support::Object {
public:
! const School& getSchool () const;
! Descriptors getDescriptors () const;
! Components getComponents () const;
! const Range& getRange () const;
+ MetamagicFeats getMetamagicFeats () const;
virtual bool attachMetamagicFeat (MetamagicFeat& metamagicFeat);
+ virtual bool detachMetamagicFeat (MetamagicFeat& metamagicFeat);
+
+ virtual void castSpell () = 0;
virtual ~Spell () { }
protected:
! Spell (const School& school,
! Components components,
! const Range& range,
! Descriptors descriptors = Descriptors ());
private:
! SchoolPtr _school;
! Components _components;
! RangePtr _range;
! Descriptors _descriptors;
MetamagicFeats _metamagicFeats;
};
/**
! * Determine the school or subschool of this spell.
! *
! * @return School or subschool of this spell.
! */
! inline const School&
! Spell::getSchool () const {
! return (*(this->_school));
! }
!
! /**
! * Determine the descriptors for this spell.
*
* @return Descriptors for this spell.
*/
! inline Descriptors
! Spell::getDescriptors () const {
! return (this->_descriptors);
}
/**
! * Determine the components needed to cast this spell. The components
! * of a spell may vary from normal versions of the spell due to
! * metamagic feats.
! *
! * @return Array of components needed for this spell.
*/
! inline Components
! Spell::getComponents () const {
! return (this->_components);
! }
!
! /**
! * Determine the range of this spell. The range of a spell may vary
! * from normal versions of the spell due to metamagic feats.
! *
! * @return Range of this spell.
! */
! inline const Range&
! Spell::getRange () const {
! return (*(this->_range));
! }
!
! /**
! * Create a new spell. This constructor creates a spell with the given
! * values. Most spells have no descriptors so this is the default value
! * The new spell has no metamagic feats when initially created.
! */
! inline
! Spell::Spell (const School& school,
! Components components,
! const Range& range,
! Descriptors descriptors):
! _school (school.createCopy ()),
! _components (components),
! _range (range.createCopy ()),
! _descriptors (descriptors),
! _metamagicFeats () {
! // empty constructor body
! }
OGS_END_MAGIC_NAMESPACE
Index: Subschool.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Subschool.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Subschool.cpp 25 Mar 2003 06:13:13 -0000 1.2
--- Subschool.cpp 2 May 2003 19:06:32 -0000 1.3
***************
*** 1,4 ****
/*
! * Subschool.cpp -- class implementation for subschools of arcane magic
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
--- 1,4 ----
/*
! * Subschool.cpp -- class implementation for arcane magic subschools
* Copyright (C) 2002 Eric Lemings <ele...@us...>
*
***************
*** 24,45 ****
#include <stdexcept>
#include "ogs/magic/Subschool.h"
using ogs::magic::Subschool;
/**
! * Create a new subschool.
*
* @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @throw invalid_argument If type is invalid.
*/
! inline Subschool::Subschool (Type type): School (getSchool (type)) {
! if (isValid (type)) {
! this->type = type;
! } else {
std::ostringstream ostr;
! ostr << "Invalid subschool type: " << type;
throw std::invalid_argument (ostr.str ());
}
}
--- 24,106 ----
#include <stdexcept>
+ #include "ogs/magic/School.h"
#include "ogs/magic/Subschool.h"
+ using ogs::magic::School;
using ogs::magic::Subschool;
/**
! * Determine the name of this subschool.
! *
! * @return Name of this subschool (e.g., "Illusion (Glamer)")
! */
! std::string Subschool::getName () const {
! std::string s (School::getName ());
!
! switch (this->_type) {
! case CALLING:
! s += " (Calling)";
! break;
! case CREATION:
! s += " (Creation)";
! break;
! case HEALING:
! s += " (Healing)";
! break;
! case SUMMONING:
! s += " (Summoning)";
! break;
! case CHARM:
! s += " (Charm)";
! break;
! case COMPULSION:
! s += " (Compulsion)";
! break;
! case FIGMENT:
! s += " (Figment)";
! break;
! case GLAMER:
! s += " (Glamer)";
! break;
! case PATTERN:
! s += " (Pattern)";
! break;
! case PHANTASM:
! s += " (Phantasm)";
! break;
! case SHADOW:
! s += " (Shadow)";
! break;
! }
!
! return (s);
! }
!
!
! /**
! * Determine the school that a subschool belongs to.
*
* @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @return Type of school that subschool belongs to.
! * @throw std::invalid_argument If type is an invalid subschool.
*/
! School::Type Subschool::getSchool (Type type) {
! if (! isValid (type)) {
std::ostringstream ostr;
! ostr << "invalid subschool type (" << int (type) << ")";
throw std::invalid_argument (ostr.str ());
}
+
+ return (type == CALLING ||
+ type == CREATION ||
+ type == HEALING ||
+ type == SUMMONING? CONJURATION:
+ type == CHARM ||
+ type == COMPULSION? ENCHANTMENT:
+ type == FIGMENT ||
+ type == GLAMER ||
+ type == PATTERN ||
+ type == PHANTASM ||
+ type == SHADOW? ILLUSION: School::Type (0));
}
Index: Subschool.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Subschool.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Subschool.h 25 Feb 2003 19:40:27 -0000 1.3
--- Subschool.h 2 May 2003 19:06:32 -0000 1.4
***************
*** 30,38 ****
# include <ogs/magic/Namespace.h>
# include <ogs/magic/School.h>
OGS_BEGIN_MAGIC_NAMESPACE
/**
! * A subschool of arcance magic.
*/
class Subschool: public School {
--- 30,40 ----
# include <ogs/magic/Namespace.h>
# include <ogs/magic/School.h>
+ # include <ogs/magic/Types.h>
OGS_BEGIN_MAGIC_NAMESPACE
/**
! * A subschool of arcance magic. Each subschool belongs to exactly one
! * school. Not all schools have subschools.
*/
class Subschool: public School {
***************
*** 45,76 ****
/** The Creation subschool of the Conjuration school. */
! CREATION = 2,
/** The Healing subschool of the Conjuration school. */
! HEALING = 3,
/** The Summoning subschool of the Conjuration school. */
! SUMMONING = 4,
/** The Charm subschool of the Enchantment school. */
! CHARM = 5,
/** The Compulsion subschool of the Enchantment school. */
! COMPULSION = 6,
/** The Figment subschool of the Illusion school. */
! FIGMENT = 7,
/** The Glamer subschool of the Illusion school. */
! GLAMER = 8,
/** The Pattern subschool of the Illusion school. */
! PATTERN = 9,
/** The Phantasm subschool of the Illusion school. */
! PHANTASM = 10,
/** The Shadow subschool of the Illusion school. */
! SHADOW = 11
};
--- 47,78 ----
/** The Creation subschool of the Conjuration school. */
! CREATION,
/** The Healing subschool of the Conjuration school. */
! HEALING,
/** The Summoning subschool of the Conjuration school. */
! SUMMONING,
/** The Charm subschool of the Enchantment school. */
! CHARM,
/** The Compulsion subschool of the Enchantment school. */
! COMPULSION,
/** The Figment subschool of the Illusion school. */
! FIGMENT,
/** The Glamer subschool of the Illusion school. */
! GLAMER,
/** The Pattern subschool of the Illusion school. */
! PATTERN,
/** The Phantasm subschool of the Illusion school. */
! PHANTASM,
/** The Shadow subschool of the Illusion school. */
! SHADOW
};
***************
*** 78,116 ****
Type getType () const;
std::string getName () const;
private:
! Type type;
! static bool isValid (Type type);
static School::Type getSchool (Type type);
};
/**
* Determine type of this subschool.
*
* @return Type of subschool ((CALLING, CHARM, FIGMENT, ...).
*/
! inline Subschool::Type Subschool::getType () const {
! return (this->type);
}
/**
! * Determine school for this subschool.
*
! * @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
! * @return School::Type or 0 if type is invalid.
*/
! inline School::Type Subschool::getSchool (Type type) {
! return (type == CALLING ||
! type == CREATION ||
! type == HEALING ||
! type == SUMMONING? School::CONJURATION:
! type == CHARM ||
! type == COMPULSION? School::ENCHANTMENT:
! type == FIGMENT ||
! type == GLAMER ||
! type == PATTERN ||
! type == PHANTASM ||
! type == SHADOW? School::ILLUSION: School::Type (0));
}
--- 80,144 ----
Type getType () const;
std::string getName () const;
+ School* createCopy () const;
private:
! Type _type;
! static bool isValid (int i);
static School::Type getSchool (Type type);
};
/**
+ * Create a new subschool.
+ *
+ * @param type Type of subschool (CALLING, CHARM, FIGMENT, ...)
+ * @throw std::invalid_argument If type is an invalid subschool.
+ */
+ inline
+ Subschool::Subschool (Type type):
+ School (getSchool (type)),
+ _type (type) {
+ // empty constructor body
+ }
+
+ /**
* Determine type of this subschool.
*
* @return Type of subschool ((CALLING, CHARM, FIGMENT, ...).
*/
! inline Subschool::Type
! Subschool::getType () const {
! return (this->_type);
}
/**
! * Create a copy of this subschool.
*
! * @return A pointer to a copy of this subschool.
*/
! inline School*
! Subschool::createCopy () const {
! return (new Subschool (*this));
! }
!
! /**
! * Determine if an integer value is a valid subschool type.
! *
! * @param i An integer value.
! * @return True if integer value is a valid subschool type.
! */
! inline bool
! Subschool::isValid (int i) {
! return (i == CALLING ||
! i == CREATION ||
! i == HEALING ||
! i == SUMMONING ||
! i == CHARM ||
! i == COMPULSION ||
! i == FIGMENT ||
! i == GLAMER ||
! i == PATTERN ||
! i == PHANTASM ||
! i == SHADOW);
}
Index: Types.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/magic/Types.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Types.h 18 Apr 2003 03:40:09 -0000 1.1
--- Types.h 2 May 2003 19:06:32 -0000 1.2
***************
*** 26,35 ****
--- 26,43 ----
# define OGS_MAGIC_TYPES_H
+ # include <list>
# include <vector>
+ # include <boost/shared_ptr.hpp>
+
# include <ogs/magic/Namespace.h>
OGS_BEGIN_MAGIC_NAMESPACE
+ class Component;
+ class MetamagicFeat;
+ class Range;
+ class School;
+
/** An unsigned integer type that represents spell level. */
typedef unsigned short SpellLevel;
***************
*** 44,47 ****
--- 52,73 ----
*/
typedef std::vector<unsigned> SpellCounts;
+
+ /** A smart pointer to a school or subshcool. */
+ typedef boost::shared_ptr<School> SchoolPtr;
+
+ /** A smart pointer that holds a spell component. */
+ typedef boost::shared_ptr<Component> ComponentPtr;
+
+ /** A list of spell components. */
+ typedef std::list<ComponentPtr> Components;
+
+ /** A smart pointer to a spell range. */
+ typedef boost::shared_ptr<Range> RangePtr;
+
+ /** A smart pointer that holds a metamagic feat. */
+ typedef boost::shared_ptr<MetamagicFeat> MetamagicFeatPtr;
+
+ /** A list of spell components. */
+ typedef std::list<MetamagicFeatPtr> MetamagicFeats;
OGS_END_MAGIC_NAMESPACE
|
|
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 = \
|
|
From: <ele...@us...> - 2003-05-02 19:07:08
|
Update of /cvsroot/ogs/dist/c++/ogs/creatures/undeads
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/creatures/undeads
Modified Files:
Wraith.cpp Wraith.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Wraith.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/undeads/Wraith.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Wraith.cpp 15 Apr 2003 16:58:40 -0000 1.1
--- Wraith.cpp 2 May 2003 19:06:31 -0000 1.2
***************
*** 23,29 ****
#include "ogs/core/Abilities.h"
#include "ogs/core/Die.h"
- #include "ogs/core/Modifier.h"
#include "ogs/core/Skill.h"
#include "ogs/core/details/Alignment.h"
#include "ogs/Skills.h"
#include "ogs/feats/Alertness.h"
--- 23,30 ----
#include "ogs/core/Abilities.h"
#include "ogs/core/Die.h"
#include "ogs/core/Skill.h"
#include "ogs/core/details/Alignment.h"
+ #include "ogs/core/moves/Walk.h"
+ #include "ogs/core/moves/Fly.h"
#include "ogs/Skills.h"
#include "ogs/feats/Alertness.h"
***************
*** 36,40 ****
using ogs::core::Abilities;
using ogs::core::Die;
! using ogs::core::Modifier;
using ogs::core::Skill;
using ogs::creatures::undeads::Wraith;
--- 37,41 ----
using ogs::core::Abilities;
using ogs::core::Die;
! using ogs::core::Moves;
using ogs::core::Skill;
using ogs::creatures::undeads::Wraith;
***************
*** 60,63 ****
--- 61,78 ----
/**
+ * Create a list of default movement rates for this type of creature.
+ *
+ * @return A list of default movement rates.
+ */
+ Moves Wraith::createMoves () {
+ using ogs::core::moves::Walk;
+ using ogs::core::MovePtr;
+ Moves moves (1, MovePtr (new Walk (30)));
+ using ogs::core::moves::Fly;
+ moves.push_back (MovePtr (new Fly (60, Fly::GOOD)));
+ return (moves);
+ }
+
+ /**
* Create a set of abilities for this type of creature.
*
***************
*** 84,88 ****
*/
Wraith::Wraith (Die::Count hitDieCount):
! Undead (createHitDice (hitDieCount), createAbilities ()) {
using ogs::skills::CommonSkills;
--- 99,108 ----
*/
Wraith::Wraith (Die::Count hitDieCount):
! Undead (createMoves (),
! createAbilities (),
! ogs::core::Size::MEDIUM,
! createHitDice (hitDieCount)) {
! // incorporeal touch +5 melee
! // 1d4 damage and 1d6 permanent constitution drain
using ogs::skills::CommonSkills;
Index: Wraith.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/undeads/Wraith.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Wraith.h 15 Apr 2003 16:58:40 -0000 1.1
--- Wraith.h 2 May 2003 19:06:31 -0000 1.2
***************
*** 62,65 ****
--- 62,66 ----
static Die createHitDice (Die::Count hitDieCount);
+ static ogs::core::Moves createMoves ();
static ogs::core::Abilities createAbilities ();
};
|
|
From: <ele...@us...> - 2003-05-02 19:07:08
|
Update of /cvsroot/ogs/dist/c++/ogs/feats
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/feats
Modified Files:
Makefile.am Toughness.h
Added Files:
Toughness.cpp
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Makefile.am 15 Apr 2003 16:58:45 -0000 1.7
--- Makefile.am 2 May 2003 19:06:31 -0000 1.8
***************
*** 49,52 ****
ImprovedInitiative.cpp \
ImprovedSave.cpp \
! SingleWeapon.cpp
--- 49,53 ----
ImprovedInitiative.cpp \
ImprovedSave.cpp \
! SingleWeapon.cpp \
! Toughness.cpp
Index: Toughness.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/feats/Toughness.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Toughness.h 15 Apr 2003 16:58:45 -0000 1.3
--- Toughness.h 2 May 2003 19:06:31 -0000 1.4
***************
*** 40,44 ****
bool attachObject (Object& object);
! bool dettachObject ();
};
--- 40,44 ----
bool attachObject (Object& object);
! bool detachObject ();
};
|
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
|
|
From: <ele...@us...> - 2003-05-02 19:07:04
|
Update of /cvsroot/ogs/dist/c++/ogs/creatures/humanoids
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/creatures/humanoids
Modified Files:
Human.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Human.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/humanoids/Human.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Human.h 13 Apr 2003 05:25:21 -0000 1.3
--- Human.h 2 May 2003 19:06:31 -0000 1.4
***************
*** 65,70 ****
* Create a new human.
*/
! inline Human::Human ():
! Humanoid (ogs::core::Die (HIT_DIE, 1), createAbilities ()) {
// empty constructor body
}
--- 65,69 ----
* Create a new human.
*/
! inline Human::Human () {
// empty constructor body
}
|
|
From: <ele...@us...> - 2003-05-02 19:07:04
|
Update of /cvsroot/ogs/dist/c++/ogs/creatures
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/creatures
Modified Files:
Humanoid.h Undead.h Undeads.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Humanoid.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Humanoid.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Humanoid.h 15 Apr 2003 16:58:37 -0000 1.5
--- Humanoid.h 2 May 2003 19:06:31 -0000 1.6
***************
*** 31,34 ****
--- 31,35 ----
# include <ogs/core/Size.h>
# include <ogs/core/Skill.h>
+ # include <ogs/core/moves/Walk.h>
# include <ogs/creatures/Namespace.h>
***************
*** 48,75 ****
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 parts An array of body part types.
*/
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
}
--- 49,108 ----
static const ogs::core::Skill::Points SKILL_RATE = 1;
+ static ogs::core::Moves createMoves ();
static Parts createParts ();
+ virtual ~Humanoid () = 0;
+
protected:
! Humanoid (ogs::core::Size::Type size = ogs::core::Size::MEDIUM,
! ogs::core::Die hitDice = ogs::core::Die (HIT_DIE),
! ogs::core::Moves moves = createMoves (),
! ogs::core::Attacks attacks = ogs::core::Attacks (1),
! ogs::core::Abilities abilities = ogs::core::Abilities (),
Parts parts = createParts ());
};
/**
! * Create a common list of moves. The list of moves contains one walk
! * move with a speed of 30.
*
+ * @return A list of moves.
+ */
+ inline ogs::core::Moves
+ Humanoid::createMoves () {
+ using ogs::core::moves::Walk;
+ using ogs::core::MovePtr;
+ using ogs::core::Moves;
+ return (Moves (1, MovePtr (new Walk (30))));
+ }
+
+ /**
+ * Create a new humanoid creature. The constructor parameters are
+ * ordered according to their appearance in a statistics block. The
+ * default values are Medium size, 1d8 for hit dice, 30 ft. walk move,
+ * one attack (no weapon specified), a complete set of abilities rolled
+ * with the standard method, and a humanoid body.
+ *
+ * @param size Size of creature.
* @param hitDice Hit dice of creature.
+ * @param moves A list of moves.
+ * @param attacks An array of attacks.
* @param abilities Ability scores of creature.
* @param parts An array of body part types.
*/
inline
! Humanoid::Humanoid (ogs::core::Size::Type size,
! ogs::core::Die hitDice,
! ogs::core::Moves moves,
! ogs::core::Attacks attacks,
ogs::core::Abilities abilities,
! Parts parts):
! Creature (hitDice, moves, attacks, abilities, size, parts) {
// empty constructor body
+ }
+
+ inline
+ Humanoid::~Humanoid () {
+ // empty destructor body
}
Index: Undead.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Undead.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Undead.h 15 Apr 2003 16:58:38 -0000 1.4
--- Undead.h 2 May 2003 19:06:31 -0000 1.5
***************
*** 50,57 ****
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 ());
};
--- 50,61 ----
static const ogs::core::Die::Sides HIT_DIE = ogs::core::Die::d12;
+ virtual ~Undead () = 0;
+
protected:
! Undead (ogs::core::Moves moves,
ogs::core::Abilities abilities,
ogs::core::Size::Type size = ogs::core::Size::MEDIUM,
+ ogs::core::Die hitDice = ogs::core::Die (HIT_DIE),
+ ogs::core::Attacks attacks = ogs::core::Attacks (1),
Parts parts = Parts ());
};
***************
*** 67,76 ****
*/
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
}
--- 71,87 ----
*/
inline
! Undead::Undead (ogs::core::Moves moves,
ogs::core::Abilities abilities,
ogs::core::Size::Type size,
+ ogs::core::Die hitDice,
+ ogs::core::Attacks attacks,
Parts parts):
! Creature (hitDice, moves, attacks, abilities, size, parts) {
// empty constructor body
+ }
+
+ inline
+ Undead::~Undead () {
+ // empty destructor body
}
Index: Undeads.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/creatures/Undeads.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Undeads.h 15 Apr 2003 16:58:39 -0000 1.1
--- Undeads.h 2 May 2003 19:06:31 -0000 1.2
***************
*** 31,34 ****
--- 31,35 ----
//# include <ogs/creatures/undeads/Mummy.h>
//# include <ogs/creatures/undeads/Skeleton.h>
+ //# include <ogs/creatures/undeads/Spectre.h>
//# include <ogs/creatures/undeads/Vampire.h>
//# include <ogs/creatures/undeads/Wight.h>
|
Update of /cvsroot/ogs/dist/c++/ogs/combat/actions
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/combat/actions
Modified Files:
FullAttack.cpp FullAttack.h Makefile.am NormalAttack.cpp
NormalAttack.h
Added Files:
TotalDefense.h
Log Message:
See C++ ChangeLog (May 2) for details.
--- NEW FILE: TotalDefense.h ---
/*
* TotalDefense.h -- class interface for Total Defense actions
* 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: TotalDefense.h,v 1.1 2003/05/02 19:06:29 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_COMBAT_ACTIONS_TOTAL_DEFENSE_H
# define OGS_COMBAT_ACTIONS_TOTAL_DEFENSE_H
# include <ogs/combat/Action.h>
# include <ogs/combat/actions/Namespace.h>
OGS_BEGIN_COMBAT_ACTIONS_NAMESPACE
/**
* A standard action that provides +4 bonus to defense.
*/
class TotalDefense: public ogs::combat::Action {
public:
private:
};
OGS_END_COMBAT_ACTIONS_NAMESPACE
# endif /* !defined OGS_COMBAT_ACTIONS_TOTAL_DEFENSE_H */
#endif /* defined __cplusplus */
Index: FullAttack.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/actions/FullAttack.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FullAttack.cpp 5 Feb 2003 06:01:27 -0000 1.2
--- FullAttack.cpp 2 May 2003 19:06:29 -0000 1.3
***************
*** 21,38 ****
*/
! #include "FullAttack.h"
using ogs::combat::actions::FullAttack;
-
- /**
- * Create a new Full Attack action.
- *
- * @param attacker Creature performing the attack.
- * @param defender Creature defending against the attack.
- */
- FullAttack::FullAttack (Creature& attacker, Creature& defender):
- _attacker (attacker), _defender (&defender) {
- // empty
- }
/**
--- 21,27 ----
*/
! #include "ogs/combat/actions/FullAttack.h"
using ogs::combat::actions::FullAttack;
/**
Index: FullAttack.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/actions/FullAttack.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FullAttack.h 5 Feb 2003 06:01:27 -0000 1.2
--- FullAttack.h 2 May 2003 19:06:29 -0000 1.3
***************
*** 26,29 ****
--- 26,31 ----
# define OGS_COMBAT_ACTIONS_FULL_ATTACK_H
+ # include <cassert>
+
# include <ogs/core/Creature.h>
# include <ogs/combat/Action.h>
***************
*** 32,35 ****
--- 34,38 ----
OGS_BEGIN_COMBAT_ACTIONS_NAMESPACE
+ class ogs::core::Creature;
using ogs::core::Creature;
***************
*** 51,65 ****
void setDefender (Creature& defender);
private:
! Creature& _attacker;
Creature* _defender;
};
/**
* A Full Attack aciton is a full-round action.
*
* @return Action::FULL_ROUND.
*/
! inline Action::Type FullAttack::getType () const {
return (Action::FULL_ROUND);
}
--- 54,88 ----
void setDefender (Creature& defender);
+ bool isDefensive () const;
+ void setDefensive (bool defensive = true);
+
private:
! Creature* _attacker;
Creature* _defender;
+ bool _defensive;
};
/**
+ * Create a new Full Attack action. The new Full Attack action is not
+ * fighting defensively when initially created.
+ *
+ * @param attacker Creature performing the attack.
+ * @param defender Creature defending against the attack.
+ */
+ inline
+ FullAttack::FullAttack (Creature& attacker, Creature& defender):
+ _attacker (&attacker),
+ _defender (&defender),
+ _defensive (false) {
+ // empty constructor body
+ }
+
+ /**
* A Full Attack aciton is a full-round action.
*
* @return Action::FULL_ROUND.
*/
! inline Action::Type
! FullAttack::getType () const {
return (Action::FULL_ROUND);
}
***************
*** 70,74 ****
* @return False.
*/
! inline bool FullAttack::provokeAttack () const {
return (false);
}
--- 93,98 ----
* @return False.
*/
! inline bool
! FullAttack::provokeAttack () const {
return (false);
}
***************
*** 80,84 ****
* @return True.
*/
! inline bool FullAttack::isComplete () const {
return (true);
}
--- 104,109 ----
* @return True.
*/
! inline bool
! FullAttack::isComplete () const {
return (true);
}
***************
*** 89,94 ****
* @return Attacker.
*/
! inline Creature& FullAttack::getAttacker () const {
! return (_attacker);
}
--- 114,121 ----
* @return Attacker.
*/
! inline Creature&
! FullAttack::getAttacker () const {
! assert (this->_attacker != NULL);
! return (*(this->_attacker));
}
***************
*** 98,103 ****
* @return Defender.
*/
! inline Creature& FullAttack::getDefender () const {
! return (*_defender);
}
--- 125,152 ----
* @return Defender.
*/
! inline Creature&
! FullAttack::getDefender () const {
! assert (this->_defender != NULL);
! return (*(this->_defender));
! }
!
! /**
! * Determine if this Full Attack action is fighting defensively.
! *
! * @return True if this action is fighting defensively.
! */
! inline bool
! FullAttack::isDefensive () const {
! return (this->_defensive);
! }
!
! /**
! * Change the fighting defensively state for this Full Attack action.
! *
! * @param defensive True if this action is fighting defensively.
! */
! inline void
! FullAttack::setDefensive (bool defensive) {
! this->_defensive = defensive;
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/actions/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am 4 Mar 2003 03:24:41 -0000 1.3
--- Makefile.am 2 May 2003 19:06:29 -0000 1.4
***************
*** 28,32 ****
Namespace.h \
NormalAttack.h \
! Refocus.h
INCLUDES = \
--- 28,33 ----
Namespace.h \
NormalAttack.h \
! Refocus.h \
! TotalDefense.h
INCLUDES = \
Index: NormalAttack.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/actions/NormalAttack.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NormalAttack.cpp 8 Jan 2003 22:28:34 -0000 1.1
--- NormalAttack.cpp 2 May 2003 19:06:29 -0000 1.2
***************
*** 25,26 ****
--- 25,33 ----
using ogs::combat::actions::NormalAttack;
+ /**
+ * Perform this action.
+ */
+ void NormalAttack::performAction () {
+ // TODO: Implement this function.
+ }
+
Index: NormalAttack.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/combat/actions/NormalAttack.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NormalAttack.h 5 Feb 2003 06:01:27 -0000 1.2
--- NormalAttack.h 2 May 2003 19:06:29 -0000 1.3
***************
*** 44,62 ****
bool provokeAttack () const;
! void startAction ();
bool isComplete () const;
void continueAction ();
private:
! Creature& attacker;
! Creature* defender;
};
/**
* A normal attack is a standard action.
*
* @return Action::STANDARD.
*/
! inline Action::Type NormalAttack::getType () const {
return (Action::STANDARD);
}
--- 44,86 ----
bool provokeAttack () const;
! void performAction ();
bool isComplete () const;
void continueAction ();
+ Creature& getAttacker () const;
+ Creature& getDefender () const;
+ void setDefender (Creature& defender);
+
+ bool isDefensive () const;
+ void setDefensive (bool defensive = true);
+
private:
! Creature* _attacker;
! Creature* _defender;
! bool _defensive;
};
/**
+ * Create a new Normal Attack action. The new Normal Attack action is
+ * not fighting defensively when initially created.
+ *
+ * @param attacker Creature performing the attack.
+ * @param defender Creature defending against the attack.
+ */
+ inline
+ NormalAttack::NormalAttack (Creature& attacker, Creature& defender):
+ _attacker (&attacker),
+ _defender (&defender),
+ _defensive (false) {
+ // empty constructor body
+ }
+
+ /**
* A normal attack is a standard action.
*
* @return Action::STANDARD.
*/
! inline Action::Type
! NormalAttack::getType () const {
return (Action::STANDARD);
}
***************
*** 67,71 ****
* @return False.
*/
! inline bool NormalAttack::provokeAttack () const {
return (false);
}
--- 91,96 ----
* @return False.
*/
! inline bool
! NormalAttack::provokeAttack () const {
return (false);
}
***************
*** 77,82 ****
* @return True.
*/
! inline bool NormalAttack::isComplete () const {
return (true);
}
--- 102,151 ----
* @return True.
*/
! inline bool
! NormalAttack::isComplete () const {
return (true);
+ }
+
+ /**
+ * Determine the attacker of this Normal Attack action.
+ *
+ * @return Attacker.
+ */
+ inline Creature&
+ NormalAttack::getAttacker () const {
+ assert (this->_attacker != NULL);
+ return (*(this->_attacker));
+ }
+
+ /**
+ * Determine the defender of this Normal Attack action.
+ *
+ * @return Defender.
+ */
+ inline Creature&
+ NormalAttack::getDefender () const {
+ assert (this->_defender != NULL);
+ return (*(this->_defender));
+ }
+
+ /**
+ * Determine if this Normal Attack action is fighting defensively.
+ *
+ * @return True if this action is fighting defensively.
+ */
+ inline bool
+ NormalAttack::isDefensive () const {
+ return (this->_defensive);
+ }
+
+ /**
+ * Change the fighting defensively posture for this Normal Attack
+ * action.
+ *
+ * @param defensive True if this action is fighting defensively.
+ */
+ inline void
+ NormalAttack::setDefensive (bool defensive) {
+ this->_defensive = defensive;
}
|
|
From: <ele...@us...> - 2003-05-02 19:07:03
|
Update of /cvsroot/ogs/dist/c++/ogs/cclasses
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/cclasses
Modified Files:
Barbarian.h Bard.h Cleric.h Druid.h Fighter.h Makefile.am
Monk.h Paladin.cpp Paladin.h Ranger.h Rogue.h Sorcerer.h
Wizard.h
Removed Files:
Commoner.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Barbarian.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Barbarian.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Barbarian.h 13 Apr 2003 05:24:49 -0000 1.3
--- Barbarian.h 2 May 2003 19:06:29 -0000 1.4
***************
*** 26,29 ****
--- 26,30 ----
# define OGS_CCLASSES_BARBARIAN_H
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 81,85 ****
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),
--- 82,86 ----
inline Barbarian::Barbarian (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getStrongBonus (xpLevel),
ogs::core::Saves::getStrongBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
***************
*** 96,100 ****
inline ogs::core::Modifier::Value
Barbarian::getBaseAttackValue () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
--- 97,101 ----
inline ogs::core::Modifier::Value
Barbarian::getBaseAttackValue () const {
! return (ogs::core::Attack::getStrongBonus (getLevel ()));
}
Index: Bard.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Bard.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Bard.h 18 Apr 2003 01:41:00 -0000 1.5
--- Bard.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 87,91 ****
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),
--- 88,92 ----
inline Bard::Bard (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getStrongBonus (xpLevel),
Index: Cleric.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Cleric.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Cleric.h 18 Apr 2003 01:41:00 -0000 1.5
--- Cleric.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 86,90 ****
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),
--- 87,91 ----
inline Cleric::Cleric (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getStrongBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
Index: Druid.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Druid.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Druid.h 18 Apr 2003 01:41:00 -0000 1.5
--- Druid.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 88,92 ****
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),
--- 89,93 ----
inline Druid::Druid (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getStrongBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
Index: Fighter.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Fighter.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Fighter.h 13 Apr 2003 05:24:49 -0000 1.8
--- Fighter.h 2 May 2003 19:06:29 -0000 1.9
***************
*** 26,29 ****
--- 26,30 ----
# define OGS_CCLASSES_FIGHTER_H
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 79,83 ****
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),
--- 80,84 ----
inline Fighter::Fighter (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getStrongBonus (xpLevel),
ogs::core::Saves::getStrongBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
***************
*** 95,99 ****
inline ogs::core::Modifier::Value
Fighter::getBaseAttack () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
--- 96,100 ----
inline ogs::core::Modifier::Value
Fighter::getBaseAttack () const {
! return (ogs::core::Attack::getStrongBonus (getLevel ()));
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/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:29 -0000 1.4
***************
*** 27,31 ****
Bard.h \
Cleric.h \
- Commoner.h \
Druid.h \
Fighter.h \
--- 27,30 ----
Index: Monk.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Monk.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Monk.h 18 Apr 2003 01:41:00 -0000 1.4
--- Monk.h 2 May 2003 19:06:29 -0000 1.5
***************
*** 26,29 ****
--- 26,30 ----
# define OGS_CCLASSES_MONK_H
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 91,95 ****
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),
--- 92,96 ----
inline Monk::Monk (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
Index: Paladin.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Paladin.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Paladin.cpp 18 Apr 2003 01:41:00 -0000 1.7
--- Paladin.cpp 2 May 2003 19:06:29 -0000 1.8
***************
*** 44,48 ****
Paladin::Paladin (XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! XP::getStrongAttack (xpLevel),
Saves::getStrongBonus (xpLevel),
Saves::getWeakBonus (xpLevel),
--- 44,48 ----
Paladin::Paladin (XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! Attack::getStrongBonus (xpLevel),
Saves::getStrongBonus (xpLevel),
Saves::getWeakBonus (xpLevel),
Index: Paladin.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Paladin.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Paladin.h 18 Apr 2003 01:41:01 -0000 1.5
--- Paladin.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
Index: Ranger.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Ranger.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Ranger.h 18 Apr 2003 01:41:01 -0000 1.5
--- Ranger.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 89,93 ****
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),
--- 90,94 ----
inline Ranger::Ranger (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
***************
*** 104,108 ****
inline ogs::core::Modifier::Value
Ranger::getBaseAttackValue () const {
! return (ogs::core::XP::getStrongAttack (getLevel ()));
}
--- 105,109 ----
inline ogs::core::Modifier::Value
Ranger::getBaseAttackValue () const {
! return (ogs::core::Attack::getStrongBonus (getLevel ()));
}
Index: Rogue.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Rogue.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Rogue.h 13 Apr 2003 05:24:49 -0000 1.3
--- Rogue.h 2 May 2003 19:06:29 -0000 1.4
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 75,79 ****
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),
--- 76,80 ----
inline Rogue::Rogue (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
Index: Sorcerer.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Sorcerer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Sorcerer.h 18 Apr 2003 01:41:01 -0000 1.5
--- Sorcerer.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 76,80 ****
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),
--- 77,81 ----
inline Sorcerer::Sorcerer (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
***************
*** 91,95 ****
inline ogs::core::Modifier::Value
Sorcerer::getBaseAttackValue () const {
! return (ogs::core::XP::getWeakAttack (getLevel ()));
}
--- 92,96 ----
inline ogs::core::Modifier::Value
Sorcerer::getBaseAttackValue () const {
! return (ogs::core::Attack::getWeakBonus (getLevel ()));
}
Index: Wizard.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/cclasses/Wizard.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Wizard.h 18 Apr 2003 01:41:01 -0000 1.5
--- Wizard.h 2 May 2003 19:06:29 -0000 1.6
***************
*** 28,31 ****
--- 28,32 ----
# include <vector>
+ # include <ogs/core/Attack.h>
# include <ogs/core/CClass.h>
# include <ogs/core/Die.h>
***************
*** 97,101 ****
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),
--- 98,102 ----
inline Wizard::Wizard (ogs::core::XP::Level xpLevel):
CClass (HIT_DIE, SKILL_RATE, xpLevel,
! ogs::core::Attack::getAverageBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
ogs::core::Saves::getWeakBonus (xpLevel),
***************
*** 112,116 ****
inline ogs::core::Modifier::Value
Wizard::getBaseAttackValue () const {
! return (ogs::core::XP::getWeakAttack (getLevel ()));
}
--- 113,117 ----
inline ogs::core::Modifier::Value
Wizard::getBaseAttackValue () const {
! return (ogs::core::Attack::getWeakBonus (getLevel ()));
}
--- Commoner.h DELETED ---
|
|
From: <ele...@us...> - 2003-05-02 19:07:02
|
Update of /cvsroot/ogs/dist/c++/ogs In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs Modified Files: Core.h Log Message: See C++ ChangeLog (May 2) for details. Index: Core.h =================================================================== RCS file: /cvsroot/ogs/dist/c++/ogs/Core.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Core.h 13 Apr 2003 05:28:46 -0000 1.4 --- Core.h 2 May 2003 19:06:29 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- # include <ogs/core/Ability.h> # include <ogs/core/Abilities.h> + # include <ogs/core/Attack.h> # include <ogs/core/CClass.h> # include <ogs/core/Character.h> *************** *** 40,47 **** --- 41,51 ---- # include <ogs/core/Modifier.h> # include <ogs/core/Modifiers.h> + # include <ogs/core/Move.h> + # include <ogs/core/Moves.h> # include <ogs/core/Saves.h> # include <ogs/core/Size.h> # include <ogs/core/Skill.h> # include <ogs/core/Types.h> + # include <ogs/core/Weapon.h> #endif /* !defined OGS_CORE_H */ |
|
From: <ele...@us...> - 2003-05-02 19:07:01
|
Update of /cvsroot/ogs/dist/c++ In directory sc8-pr-cvs1:/tmp/cvs-serv32451 Modified Files: ChangeLog configure.in Log Message: See C++ ChangeLog (May 2) for details. Index: ChangeLog =================================================================== RCS file: /cvsroot/ogs/dist/c++/ChangeLog,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ChangeLog 19 Apr 2003 18:37:40 -0000 1.20 --- ChangeLog 2 May 2003 19:06:28 -0000 1.21 *************** *** 1,3 **** --- 1,54 ---- + Fri May 2 18:35:41 UTC 2003 Eric Lemings <ele...@us...> + + * ogs/support/Object.*, ogs/support/Observer.h: Changed + notifyObservers() to const function. + + * configure.in, ogs/Core.h, ogs/core/Creature.*, + ogs/core/Makefile.am, ogs/core/Types.h: Added new types, + members, namespace, and header files for attacks and moves. + + * ogs/core/CClass.cpp, ogs/cclasses/*.h: Updated base attack + bonus function names. + * ogs/core/Details.h, ogs/core/details/Makefile.am: Added + subdual damage and visions. + * ogs/core/Die.*: Minor updates. + * ogs/core/Entity.cpp: Verify cur hp <= max hp. + * ogs/core/Experience.h: Moved base attack bonus functions to + Attack.h header. + * ogs/core/Modifier*: Minor updates. + + * ogs/combat/actions/*: Changed reference members to pointers. + Added "fighting defensively" flag. Other minor updates. + + * ogs/magic/AbsoluteRange.h, ogs/magic/LevelRange.h: Added + Distance type and virtual constructor. Inlined constructors. + * ogs/magic/Range.h: Added virtual constructor. + * ogs/magic/Component.h: Inlined constructor. Removed source file. + * ogs/magic/PhysicalComponent.h: Added Cost type. + * ogs/magic/School.h: Added virtual constructor. + * ogs/magic/Subschool.h: Added virtual constructor, getName() + function. Validate subschool in getSchool() function. + * ogs/magic/Spell.*: Changed metamagic feats, schools, ranges + into smart pointers. Changed virtual functions into data + members passed into constructors. + * ogs/magic/Types.h: Added smart pointer and polymorphic + container types. + + * ogs/cclasses/Makefile.am: Removed Commoner cclass. + + * ogs/creatures/*.h, ogs/creatures/humnaoids/Human.*, + ogs/creatures/undeads/*: Expanded constructors for moves and + attacks. + + * ogs/feats/Toughness.*: Finished implementing Toughness feat. + + * ogs/spells/*.h, ogs/spells/conjurations/CureWounds.*: Replaced + virtual functions with constructors. Fixed a couple of named + constructors in CureWounds. + + * test/Makefile.am, test/MagicTest.cpp: Added test driver for + magic system. + Sat Apr 19 18:32:35 UTC 2003 Eric Lemings <ele...@us...> Index: configure.in =================================================================== RCS file: /cvsroot/ogs/dist/c++/configure.in,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** configure.in 15 Apr 2003 16:58:28 -0000 1.14 --- configure.in 2 May 2003 19:06:28 -0000 1.15 *************** *** 110,113 **** --- 110,114 ---- ogs/core/Makefile ogs/core/details/Makefile + ogs/core/moves/Makefile ogs/combat/Makefile ogs/combat/actions/Makefile |
|
From: <ele...@us...> - 2003-05-02 19:06:42
|
Update of /cvsroot/ogs/dist/c++/test
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/test
Modified Files:
Makefile.am
Added Files:
MagicTest.cpp
Log Message:
See C++ ChangeLog (May 2) for details.
--- NEW FILE: MagicTest.cpp ---
/*
* MagicTest.cpp -- test driver for magic system
* 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: MagicTest.cpp,v 1.1 2003/05/02 19:06:38 elemings Exp $
*/
// Need to add configure checks before using <mcheck.h> and mtrace().
//#include <mcheck.h>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <iostream>
#include <ogs/Support.h>
#include <ogs/Magic.h>
#include <ogs/Creatures.h>
#include <ogs/Spells.h>
using std::cout;
using std::endl;
using namespace ogs::support;
using namespace ogs::magic;
#define TEST_DRIVER "MagicTest"
/** Run various tests on schools and subschools. */
void testSchools () {
try {
School school (School::Type (382));
assert ("Should not be here." == NULL);
} catch (std::exception& exception) {
cout << "Exception caught: " << exception.what () << endl;
}
try {
Subschool school (Subschool::Type (841));
assert ("Should not be here." == NULL);
} catch (std::exception& exception) {
cout << "Exception caught: " << exception.what () << endl;
}
cout << "sizeof (School) = " << sizeof (School) << endl;
School illusion (School::ILLUSION);
cout << "&illusion = " << &illusion << endl;
cout << "sizeof (Subschool) = " << sizeof (Subschool) << endl;
Subschool phantasm (Subschool::PHANTASM);
cout << "&phantasm = " << &phantasm << endl;
const School& school = phantasm;
assert (school.getType () == School::ILLUSION);
cout << "school.getName () = \"" << school.getName () << "\"" << endl;
assert (school.getName () == "Illusion (Phantasm)");
const Subschool& subschool = dynamic_cast<const Subschool&> (school);
assert (subschool.getType () == Subschool::PHANTASM);
cout << endl;
}
#define printDescriptor(type) \
std::cout << "Descriptors::getName (Descriptors::" #type ") = \"" \
<< Descriptors::getName (Descriptors::type) \
<< "\"" << std::endl;
void testDescriptors () {
cout << "sizeof (Descriptors) = " << sizeof (Descriptors) << endl;
printDescriptor (ACID);
printDescriptor (TELEPORTATION);
cout << "Descriptors::getName (20) = \""
<< Descriptors::getName (20) << "\"" << endl;
// Do some tests on a brand new set of descriptors.
Descriptors d1;
cout << "&d1 = " << &d1 << endl;
assert (d1.none ());
assert (!d1.any ());
assert (d1.count () == 0);
cout << "d1 = " << d1 << endl;
// Phantasmal Killer spell...Fear and Mind-Affecting descriptors.
d1.set (Descriptors::FEAR);
assert (!d1.none ());
assert (d1.any ());
assert (d1.count () == 1);
cout << "d1 = " << d1 << endl;
d1.set (Descriptors::MIND_AFFECTING);
assert (!d1.none ());
assert (d1.any ());
assert (d1.count () == 2);
cout << "d1 = " << d1 << endl;
assert (!d1.test (Descriptors::ACID));
assert (!d1.test (Descriptors::CHAOTIC));
assert (!d1.test (Descriptors::COLD));
assert (!d1.test (Descriptors::DARKNESS));
assert (d1.test (Descriptors::FEAR));
assert (!d1.test (Descriptors::FIRE));
assert (d1.test (Descriptors::MIND_AFFECTING));
cout << endl;
}
void testCureWounds () {
// Do some checks on a cure wounds spell.
using ogs::spells::conjurations::CureWounds;
CureWounds* inflictLightWounds = CureWounds::createLight (4, true);
const School& school = inflictLightWounds->getSchool ();
assert (school.getType () == School::CONJURATION);
const Subschool* subschool = dynamic_cast<const Subschool*> (&school);
assert (subschool != NULL);
assert (subschool->getType () == Subschool::HEALING);
Descriptors descriptors = inflictLightWounds->getDescriptors ();
assert (descriptors.none ());
Components components = inflictLightWounds->getComponents ();
assert (components.size () == 2);
// TODO: Verify components are verbal and somantic.
const Range& range = inflictLightWounds->getRange ();
assert (range.getType () == Range::TOUCH);
assert (inflictLightWounds->getDegree () == CureWounds::LIGHT);
assert (inflictLightWounds->getTarget () == NULL);
assert (inflictLightWounds->inflictsWounds ());
inflictLightWounds->castSpell ();
// Cast a Inflict Light Wounds spell on a healthy human.
using ogs::creatures::humanoids::Human;
Human human;
using ogs::core::Entity;
Entity::Health health = human.getHealth ();
cout << "Human: hp " << health.first << "/"
<< health.second << "." << endl;
inflictLightWounds->setTarget (human);
cout << "Casting Inflict Light Wounds on human..." << endl;
inflictLightWounds->castSpell ();
health = human.getHealth ();
cout << "Human: hp " << health.first << "/"
<< health.second << "." << endl;
// Cast a Cure Light Wounds spell on a dying human.
CureWounds* cureLightWounds = CureWounds::createLight (8);
assert (! cureLightWounds->inflictsWounds ());
cureLightWounds->setTarget (human);
cout << "Casting Cure Light Wounds on human..." << endl;
cureLightWounds->castSpell ();
health = human.getHealth ();
cout << "Human: hp " << health.first << "/"
<< health.second << "." << endl;
// Cast a Cure Critical Wounds spell on a healthy wraith.
using ogs::creatures::undeads::Wraith;
Wraith wraith;
CureWounds* cureCriticalWounds = CureWounds::createCritical (8);
health = wraith.getHealth ();
cout << "Wraith: hp " << health.first << "/"
<< health.second << "." << endl;
cureCriticalWounds->setTarget (wraith);
cout << "Casting Cure Critical Wounds on wraith..." << endl;
cureCriticalWounds->castSpell ();
health = wraith.getHealth ();
cout << "Wraith: hp " << health.first << "/"
<< health.second << "." << endl;
delete cureLightWounds;
delete inflictLightWounds;
delete cureCriticalWounds;
cout << endl;
}
int main (void) {
//mtrace ();
cout << "BEGIN: " TEST_DRIVER "\n\n";
// Seed random number generator with current time.
std::srand (std::time (NULL));
testSchools ();
testDescriptors ();
testCureWounds ();
cout << "END: " TEST_DRIVER "\n";
//muntrace ();
return (0);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/test/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 15 Apr 2003 16:58:54 -0000 1.5
--- Makefile.am 2 May 2003 19:06:38 -0000 1.6
***************
*** 38,42 ****
AbilitiesTest \
CreatureTest \
! CombatTest01
SupportTest_SOURCES = \
--- 38,43 ----
AbilitiesTest \
CreatureTest \
! CombatTest01 \
! MagicTest
SupportTest_SOURCES = \
***************
*** 52,55 ****
--- 53,58 ----
CombatTest01_SOURCES = \
CombatTest01.cpp
+ MagicTest_SOURCES = \
+ MagicTest.cpp
# These programs are also executed when the check target is run.
|
|
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;
}
|
|
From: <ele...@us...> - 2003-05-02 19:06:41
|
Update of /cvsroot/ogs/dist/c++/ogs/support
In directory sc8-pr-cvs1:/tmp/cvs-serv32451/ogs/support
Modified Files:
Attachable.h Object.cpp Object.h Observer.h Utility.h
Log Message:
See C++ ChangeLog (May 2) for details.
Index: Attachable.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Attachable.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Attachable.h 15 Apr 2003 16:58:50 -0000 1.2
--- Attachable.h 2 May 2003 19:06:37 -0000 1.3
***************
*** 39,43 ****
* reversible when (and if) the attachable is detached from the subject.
* Attachable objects that do not modify the subject simply add
! * additional detail to the object.
*/
class Attachable {
--- 39,48 ----
* reversible when (and if) the attachable is detached from the subject.
* Attachable objects that do not modify the subject simply add
! * additional detail to the object. <P>
! *
! * Note that this interface is designed only for one to one or one to
! * many relationships depending on the object that an Attachable is
! * attached to. Many to many relationships would require a much more
! * complicated interface.
*/
class Attachable {
Index: Object.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Object.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Object.cpp 18 Apr 2003 01:41:07 -0000 1.4
--- Object.cpp 2 May 2003 19:06:37 -0000 1.5
***************
*** 41,45 ****
Observers::iterator end = this->_observers.end ();
if (std::find (this->_observers.begin (), end, &observer) == end) {
! _observers.push_front (&observer);
}
}
--- 41,45 ----
Observers::iterator end = this->_observers.end ();
if (std::find (this->_observers.begin (), end, &observer) == end) {
! this->_observers.push_front (&observer);
}
}
***************
*** 62,67 ****
* @param event The event that occurred.
*/
! void Object::notifyObservers (Event& event) {
! Observers::iterator itor = this->_observers.begin ();
while (itor != this->_observers.end ()) {
--- 62,67 ----
* @param event The event that occurred.
*/
! void Object::notifyObservers (Event& event) const {
! Observers::const_iterator itor = this->_observers.begin ();
while (itor != this->_observers.end ()) {
Index: Object.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Object.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Object.h 18 Apr 2003 01:41:07 -0000 1.3
--- Object.h 2 May 2003 19:06:37 -0000 1.4
***************
*** 58,62 ****
typedef std::list<Observer*> Observers;
Observers getObservers () const;
! virtual void notifyObservers (Event& event);
private:
--- 58,62 ----
typedef std::list<Observer*> Observers;
Observers getObservers () const;
! virtual void notifyObservers (Event& event) const;
private:
Index: Observer.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Observer.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Observer.h 13 Apr 2003 05:28:46 -0000 1.2
--- Observer.h 2 May 2003 19:06:37 -0000 1.3
***************
*** 52,56 ****
virtual void handleEvent (Event& event) = 0;
! friend void Object::notifyObservers (Event& event);
};
--- 52,56 ----
virtual void handleEvent (Event& event) = 0;
! friend void Object::notifyObservers (Event& event) const;
};
Index: Utility.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Utility.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Utility.h 13 Apr 2003 05:28:46 -0000 1.1
--- Utility.h 2 May 2003 19:06:37 -0000 1.2
***************
*** 31,40 ****
/**
! * 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;
--- 31,38 ----
/**
! * A function object for the delete operator. Objects of this structure
! * are intended to be with standard library algorithms.
*/
! struct Delete {
template <typename T>
void operator() (const T* t) const;
***************
*** 42,46 ****
/**
! * 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.
--- 40,44 ----
/**
! * Delete allocated memory. The allocated memory is deleted by
* calling the delete operator on a pointer of type T. The type T is
* specified by the template parameter.
***************
*** 49,55 ****
*/
template <typename T>
! void Destroy::operator() (const T* t) const {
delete t;
}
OGS_END_SUPPORT_NAMESPACE
--- 47,81 ----
*/
template <typename T>
! inline void
! Delete::operator() (const T* t) const {
delete t;
}
+
+ /**
+ * A predicate for the dynamic cast operator. This predicate determines
+ * if a value <code>x</code> of type <code>T1</code> can be dynamically
+ * cast to type <code>T2>.
+ */
+ template <class T>
+ struct DynamicCast
+ {
+ typedef bool result_type;
+
+ /**
+ * Determine if a value can be dynamically cast to another type.
+ *
+ * @param p A pointer to an object of type <code>U</code>.
+ * @return True if the pointer can be cast to type <code>T*</code>.
+ */
+ template <class U>
+ bool operator() (U* p) const {
+ return (dynamic_cast<T const volatile*> (p) != 0);
+ }
+
+ template <class U>
+ bool operator() (U& p) const {
+ return (dynamic_cast<T const volatile*> (&p) != 0);
+ }
+ };
OGS_END_SUPPORT_NAMESPACE
|