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
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "Destination.h"
|
2017-07-01 10:34:00 +02:00
|
|
|
#include "../GameConstants.h"
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
class CBattleInfoCallback;
|
|
|
|
|
|
|
|
namespace battle
|
|
|
|
{
|
|
|
|
class Unit;
|
|
|
|
}
|
2010-12-25 03:43:40 +02:00
|
|
|
|
2017-06-24 16:42:05 +02:00
|
|
|
/// A struct which handles battle actions like defending, walking,... - represents a creature stack in a battle
|
2017-07-20 06:08:49 +02:00
|
|
|
class DLL_LINKAGE BattleAction
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
public:
|
|
|
|
ui8 side; //who made this action
|
2017-06-26 18:50:35 +02:00
|
|
|
ui32 stackNumber; //stack ID, -1 left hero, -2 right hero,
|
2017-07-20 06:08:49 +02:00
|
|
|
EActionType actionType; //use ActionType enum for values
|
|
|
|
|
|
|
|
si32 actionSubtype;
|
|
|
|
|
|
|
|
BattleAction();
|
|
|
|
|
|
|
|
static BattleAction makeHeal(const battle::Unit * healer, const battle::Unit * healed);
|
|
|
|
static BattleAction makeDefend(const battle::Unit * stack);
|
|
|
|
static BattleAction makeWait(const battle::Unit * stack);
|
|
|
|
static BattleAction makeMeleeAttack(const battle::Unit * stack, BattleHex destination, BattleHex attackFrom, bool returnAfterAttack = true);
|
|
|
|
static BattleAction makeShotAttack(const battle::Unit * shooter, const battle::Unit * target);
|
2019-05-04 05:42:55 +02:00
|
|
|
static BattleAction makeCreatureSpellcast(const battle::Unit * stack, const battle::Target & target, SpellID spellID);
|
2017-07-20 06:08:49 +02:00
|
|
|
static BattleAction makeMove(const battle::Unit * stack, BattleHex dest);
|
|
|
|
static BattleAction makeEndOFTacticPhase(ui8 side);
|
2022-10-14 10:24:29 +02:00
|
|
|
static BattleAction makeRetreat(ui8 side);
|
|
|
|
static BattleAction makeSurrender(ui8 side);
|
2012-04-28 22:40:27 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
void aimToHex(const BattleHex & destination);
|
|
|
|
void aimToUnit(const battle::Unit * destination);
|
|
|
|
|
|
|
|
battle::Target getTarget(const CBattleInfoCallback * cb) const;
|
|
|
|
void setTarget(const battle::Target & target_);
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & side;
|
|
|
|
h & stackNumber;
|
|
|
|
h & actionType;
|
2017-07-20 06:08:49 +02:00
|
|
|
h & actionSubtype;
|
|
|
|
h & target;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
private:
|
2010-12-25 03:43:40 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
struct DestinationInfo
|
|
|
|
{
|
|
|
|
int32_t unitValue;
|
|
|
|
BattleHex hexValue;
|
2010-12-25 03:43:40 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & unitValue;
|
|
|
|
h & hexValue;
|
|
|
|
}
|
|
|
|
};
|
2017-08-11 13:38:10 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::vector<DestinationInfo> target;
|
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
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|