2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* BattleAction.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
2017-06-24 16:42:05 +02:00
|
|
|
#pragma once
|
|
|
|
#include "BattleHex.h"
|
2017-07-01 10:34:00 +02:00
|
|
|
#include "../GameConstants.h"
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2010-12-25 03:43:40 +02:00
|
|
|
class CStack;
|
|
|
|
|
2017-06-24 16:42:05 +02:00
|
|
|
/// A struct which handles battle actions like defending, walking,... - represents a creature stack in a battle
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE BattleAction
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
ui8 side; //who made this action: false - left, true - right player
|
2017-06-26 18:50:35 +02:00
|
|
|
ui32 stackNumber; //stack ID, -1 left hero, -2 right hero,
|
2013-02-04 00:05:44 +03:00
|
|
|
Battle::ActionType actionType; //use ActionType enum for values
|
2011-12-22 16:05:19 +03:00
|
|
|
BattleHex destinationTile;
|
2009-04-16 14:14:13 +03:00
|
|
|
si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
|
2012-04-28 22:40:27 +03:00
|
|
|
si32 selectedStack; //spell subject for teleport / sacrifice
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & side;
|
|
|
|
h & stackNumber;
|
|
|
|
h & actionType;
|
|
|
|
h & destinationTile;
|
|
|
|
h & additionalInfo;
|
|
|
|
h & selectedStack;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2010-12-25 03:43:40 +02:00
|
|
|
|
|
|
|
BattleAction();
|
|
|
|
|
2017-06-26 18:50:35 +02:00
|
|
|
static BattleAction makeHeal(const CStack * healer, const CStack * healed);
|
|
|
|
static BattleAction makeDefend(const CStack * stack);
|
|
|
|
static BattleAction makeWait(const CStack * stack);
|
|
|
|
static BattleAction makeMeleeAttack(const CStack * stack, const CStack * attacked, BattleHex attackFrom = BattleHex::INVALID);
|
|
|
|
static BattleAction makeShotAttack(const CStack * shooter, const CStack * target);
|
|
|
|
static BattleAction makeMove(const CStack * stack, BattleHex dest);
|
2011-02-12 18:12:48 +02:00
|
|
|
static BattleAction makeEndOFTacticPhase(ui8 side);
|
2017-08-11 13:38:10 +02:00
|
|
|
|
|
|
|
std::string toString() const;
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2013-11-09 19:25:20 +03:00
|
|
|
|
2017-08-11 13:38:10 +02:00
|
|
|
DLL_EXPORT std::ostream & operator<<(std::ostream & os, const BattleAction & ba); //todo: remove
|