File: PossiblePlayerBattleAction.h

package info (click to toggle)
vcmi 1.6.5%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 32,060 kB
  • sloc: cpp: 238,971; python: 265; sh: 224; xml: 157; ansic: 78; objc: 61; makefile: 49
file content (84 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download
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