]> git.localhorst.tv Git - l2e.git/blob - src/battle/TargetSelection.h
removed useless comments
[l2e.git] / src / battle / TargetSelection.h
1 #ifndef BATTLE_TARGETSELECTION_H_
2 #define BATTLE_TARGETSELECTION_H_
3
4 namespace common {
5         class TargetingMode;
6 }
7
8 #include <vector>
9
10 namespace battle {
11
12 class BattleState;
13
14 class TargetSelection {
15
16 public:
17         explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
18
19 public:
20         bool TargetsMonsters() const { return enemy; }
21         bool TargetsHeroes() const { return !TargetsMonsters(); }
22         bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; }
23         bool HasSelected() const { return selection >= 0; }
24         int SingleSelection() const { return selection; }
25
26         bool SelectMultiple() const { return multiple; }
27         void SetMultiple() { multiple = true; }
28         bool SelectSingle() const { return !SelectMultiple(); }
29         void SetSingle() { multiple = false; }
30
31         void ReadMode(const common::TargetingMode &);
32
33         void SelectMonsters();
34         void SelectHeroes();
35         void Select(int index) { selected[index].type = State::SELECTED; selection = index; }
36         void Unselect(int index) { selected[index].type = State::IGNORE; }
37         void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
38
39         void Reset();
40         void Resize(int num) { selected.resize(num); }
41
42         void MoveUp();
43         void MoveRight();
44         void MoveDown();
45         void MoveLeft();
46         void Select() { Select(cursor); }
47         void Unselect() { Unselect(cursor); }
48         int Current() const { return cursor; }
49         bool CurrentIsSelected() { return IsSelected(cursor); }
50
51         void SetMiss(int index) { selected[index].type = State::MISS; }
52         void SetFull(int index) { selected[index].type = State::FULL; }
53         void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
54         void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
55         int GetAmount(int index) const { return selected[index].number; }
56         bool Missed(int index) const { return selected[index].type == State::MISS; }
57         bool IsGood(int index) const { return selected[index].type == State::GOOD; }
58         bool IsBad(int index) const { return selected[index].type == State::BAD; }
59
60 private:
61         void FindNextEnemy();
62
63 private:
64         struct State {
65                 enum Type {
66                         IGNORE,
67                         SELECTED,
68                         MISS,
69                         FULL,
70                         GOOD,
71                         BAD,
72                 } type;
73                 int number;
74                 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
75         };
76         BattleState *battle;
77         std::vector<State> selected;
78         int selection;
79         int cursor;
80         bool multiple;
81         bool enemy;
82
83 };
84
85 }
86
87 #endif