[ogs-changes] dist/c++/ogs/combat/actions TotalDefense.h,NONE,1.1 FullAttack.cpp,1.2,1.3 FullAttack.
Status: Alpha
Brought to you by:
elemings
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; } |