1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/*
* PossiblePlayerBattleAction.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
*
*/
#pragma once
#include "../GameConstants.h"
VCMI_LIB_NAMESPACE_BEGIN
class PossiblePlayerBattleAction // actions performed at l-click
{
public:
enum Actions {
INVALID = -1,
CREATURE_INFO,
HERO_INFO,
MOVE_TACTICS,
CHOOSE_TACTICS_STACK,
MOVE_STACK,
ATTACK,
WALK_AND_ATTACK,
ATTACK_AND_RETURN,
SHOOT,
CATAPULT,
HEAL,
RANDOM_GENIE_SPELL, // random spell on a friendly creature
NO_LOCATION, // massive spells that affect every possible target, automatic casts
ANY_LOCATION,
OBSTACLE,
TELEPORT,
SACRIFICE,
FREE_LOCATION, // used with Force Field and Fire Wall - all tiles affected by spell must be free
AIMED_SPELL_CREATURE, // spell targeted at creature
};
private:
Actions action;
SpellID spellToCast;
public:
bool spellcast() const
{
return action == ANY_LOCATION || action == NO_LOCATION || action == OBSTACLE || action == TELEPORT ||
action == SACRIFICE || action == FREE_LOCATION || action == AIMED_SPELL_CREATURE;
}
Actions get() const
{
return action;
}
SpellID spell() const
{
return spellToCast;
}
PossiblePlayerBattleAction(Actions action, SpellID spellToCast = SpellID::NONE):
action(static_cast<Actions>(action)),
spellToCast(spellToCast)
{
assert((spellToCast != SpellID::NONE) == spellcast());
}
bool operator == (const PossiblePlayerBattleAction & other) const
{
return action == other.action && spellToCast == other.spellToCast;
}
bool operator != (const PossiblePlayerBattleAction & other) const
{
return action != other.action || spellToCast != other.spellToCast;
}
};
VCMI_LIB_NAMESPACE_END
|