2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2010-12-25 03:43:40 +02:00
|
|
|
#include "BattleAction.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2010-12-25 21:23:30 +02:00
|
|
|
#include "BattleState.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2010-12-25 03:43:40 +02:00
|
|
|
|
2013-02-04 00:05:44 +03:00
|
|
|
using namespace Battle;
|
|
|
|
|
2010-12-25 03:43:40 +02:00
|
|
|
BattleAction::BattleAction()
|
|
|
|
{
|
|
|
|
side = -1;
|
|
|
|
stackNumber = -1;
|
|
|
|
actionType = INVALID;
|
|
|
|
destinationTile = -1;
|
|
|
|
additionalInfo = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BattleAction BattleAction::makeDefend(const CStack *stack)
|
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = !stack->attackerOwned;
|
|
|
|
ba.actionType = DEFEND;
|
|
|
|
ba.stackNumber = stack->ID;
|
|
|
|
return ba;
|
|
|
|
}
|
|
|
|
|
2011-01-08 20:33:40 +02:00
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, BattleHex attackFrom /*= BattleHex::INVALID*/)
|
2010-12-25 03:43:40 +02:00
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = !stack->attackerOwned;
|
2011-01-07 12:48:31 +02:00
|
|
|
ba.actionType = WALK_AND_ATTACK;
|
2010-12-25 03:43:40 +02:00
|
|
|
ba.stackNumber = stack->ID;
|
2011-01-08 20:33:40 +02:00
|
|
|
ba.destinationTile = attackFrom;
|
2011-01-07 12:48:31 +02:00
|
|
|
ba.additionalInfo = attacked->position;
|
2010-12-25 03:43:40 +02:00
|
|
|
return ba;
|
|
|
|
|
2011-01-08 20:33:40 +02:00
|
|
|
}
|
2010-12-25 03:43:40 +02:00
|
|
|
BattleAction BattleAction::makeWait(const CStack *stack)
|
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = !stack->attackerOwned;
|
|
|
|
ba.actionType = WAIT;
|
|
|
|
ba.stackNumber = stack->ID;
|
|
|
|
return ba;
|
|
|
|
}
|
|
|
|
|
|
|
|
BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *target)
|
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = !shooter->attackerOwned;
|
|
|
|
ba.actionType = SHOOT;
|
|
|
|
ba.stackNumber = shooter->ID;
|
|
|
|
ba.destinationTile = target->position;
|
|
|
|
return ba;
|
|
|
|
}
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
BattleAction BattleAction::makeMove(const CStack *stack, BattleHex dest)
|
2010-12-25 03:43:40 +02:00
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = !stack->attackerOwned;
|
|
|
|
ba.actionType = WALK;
|
|
|
|
ba.stackNumber = stack->ID;
|
|
|
|
ba.destinationTile = dest;
|
|
|
|
return ba;
|
2011-02-12 18:12:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BattleAction BattleAction::makeEndOFTacticPhase(ui8 side)
|
|
|
|
{
|
|
|
|
BattleAction ba;
|
|
|
|
ba.side = side;
|
|
|
|
ba.actionType = END_TACTIC_PHASE;
|
|
|
|
return ba;
|
|
|
|
}
|