]> git.localhorst.tv Git - l2e.git/blob - src/battle/TargetSelection.h
added attack targets selection state
[l2e.git] / src / battle / TargetSelection.h
1 /*
2  * TargetSelection.h
3  *
4  *  Created on: Aug 9, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_TARGETSELECTION_H_
9 #define BATTLE_TARGETSELECTION_H_
10
11 #include <vector>
12
13 namespace battle {
14
15 class BattleState;
16
17 class TargetSelection {
18
19 public:
20         explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
21
22 public:
23         bool TargetsEnemies() const { return enemy; }
24         bool TargetsHeroes() const { return !TargetsEnemies(); }
25         bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index]; }
26         bool HasSelected() const { return selection >= 0; }
27         int SingleSelection() const { return selection; }
28
29         bool SelectMultiple() const { return multiple; }
30         void SetMultiple() { multiple = true; }
31         bool SelectSingle() const { return !SelectMultiple(); }
32         void SetSingle() { multiple = false; }
33
34         void SelectEnemies();
35         void SelectHeroes();
36         void Select(int index) { selected[index] = true; selection = index; }
37         void Unselect(int index) { selected[index] = false; }
38         void UnselectAll() { selected.assign(selected.size(), false); selection = -1; }
39
40         void Reset();
41         void Resize(int num) { selected.resize(num, false); }
42
43         void MoveUp();
44         void MoveRight();
45         void MoveDown();
46         void MoveLeft();
47         void Select() { Select(cursor); }
48         void Unselect() { Unselect(cursor); }
49         int Current() const { return cursor; }
50         bool CurrentIsSelected() { return IsSelected(cursor); }
51
52 private:
53         void FindNextEnemy();
54
55 private:
56         BattleState *battle;
57         std::vector<bool> selected;
58         int selection;
59         int cursor;
60         bool multiple;
61         bool enemy;
62
63 };
64
65 }
66
67 #endif /* BATTLE_TARGETSELECTION_H_ */