]> git.localhorst.tv Git - l2e.git/blob - src/battle/TargetSelection.h
moved attack order to battle 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].type != State::IGNORE; }
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].type = State::SELECTED; selection = index; }
37         void Unselect(int index) { selected[index].type = State::IGNORE; }
38         void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
39
40         void Reset();
41         void Resize(int num) { selected.resize(num); }
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         void SetMiss(int index) { selected[index].type = State::MISS; }
53         void SetFull(int index) { selected[index].type = State::FULL; }
54         void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
55         void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
56         int GetAmount(int index) const { return selected[index].number; }
57
58 private:
59         void FindNextEnemy();
60
61 private:
62         struct State {
63                 enum Type {
64                         IGNORE,
65                         SELECTED,
66                         MISS,
67                         FULL,
68                         GOOD,
69                         BAD,
70                 } type;
71                 int number;
72                 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
73         };
74         BattleState *battle;
75         std::vector<State> selected;
76         int selection;
77         int cursor;
78         bool multiple;
79         bool enemy;
80
81 };
82
83 }
84
85 #endif /* BATTLE_TARGETSELECTION_H_ */