1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef RY_COMBAT_ACTION_H
20 #define RY_COMBAT_ACTION_H
22 #include "nel/misc/types_nl.h"
24 #include "game_share/egs_sheets/egs_static_brick.h"
32 * \author David Fleury
33 * \author Nevrax France
40 CCombatAction() : _CombatPhrase(NULL
)
44 virtual bool build( const TDataSetRow
& actorRowId
, const std::vector
< const CStaticBrick
* >& bricks
, uint
&brickIndex
, CCombatPhrase
* phrase
) = 0;
46 /// validate the combat action
47 virtual bool validate(CCombatPhrase
*phrase
, std::string
&errorCode
) { return true; }
49 /// apply combat action effects
50 virtual void apply(CCombatPhrase
*phrase
) {}
53 inline void setTarget( const TDataSetRow
&entityRowId
) { _TargetRowId
= entityRowId
; }
56 TDataSetRow _ActorRowId
;
57 TDataSetRow _TargetRowId
;
58 CCombatPhrase
*_CombatPhrase
;
65 * \author David Fleury
66 * \author Nevrax France
70 class CCombatActionFactory
73 /// clear the class factory
77 * Build the desired step from a primitive node
78 * \param prim : the primitive node used to build the step
79 * \return a pointer on the built step (NULL if failure)
81 /* inline static CCombatAction * buildAction( const TDataSetRow & actorRowId, const TDataSetRow &targetRowId, const std::vector< const CStaticBrick* >& bricks, uint & brickIndex, CCombatPhrase * phrase )
83 //get appropriate factory
84 for ( uint i = 0; i < Factories->size(); i++ )
86 if ( (*Factories)[i].first == bricks[brickIndex]->Family )
88 return (*Factories)[i].second->build( actorRowId, bricks, brickIndex, phrase);
91 nlwarning( "<CCombatActionFactory buildAction> the brick family %s has no corresponding magic action class", BRICK_FAMILIES::toString( bricks[0]->Family ).c_str() );
95 ///\init the factories
96 inline static void init()
99 // Factories = new std::vector< std::pair< BRICK_FAMILIES::TBrickFamily , CCombatActionFactory* > >;
102 * Create a step from parameters
103 * \param params : a vector of vector of strings describing the step params
104 * \return a pointer on the built step (NULL if failure)
106 // virtual IMagicAction * build( const TDataSetRow & actorRowId, const std::vector< const CStaticBrick* >& brickIds, uint & index, CMagicPhrase * phrase ) = 0;
108 ///the phrase factories. We use a pointer here because we cant control the order inwhich ctor of static members are called
109 // static std::vector< std::pair< BRICK_FAMILIES::TBrickFamily , CCombatActionFactory* > >* Factories;
115 * Combat action template factory
116 * \author David Fleury
117 * \author Nevrax France
121 template <class T> class CCombatActionTFactory : public CCombatActionFactory
125 T *build( const TDataSetRow & actorRowId, const TDataSetRow &targetRowId, const std::vector< const CStaticBrick* >& bricks, uint &brickIndex, CCombatPhrase * phrase )
130 nlwarning("<CCombatActionFactory> failed to allocate element of template type");
133 if ( !instance->build(actorRowId, targetRowId, bricks, brickIndex, phrase) )
147 #endif // RY_COMBAT_ACTION_H
149 /* End of combat_action.h */