1 #ifndef BATTLE_TARGETSELECTION_H_
2 #define BATTLE_TARGETSELECTION_H_
5 #include "../common/fwd.h"
11 class TargetSelection {
14 explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
17 bool TargetsMonsters() const { return enemy; }
18 bool TargetsHeroes() const { return !TargetsMonsters(); }
19 bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; }
20 bool HasSelected() const { return selection >= 0; }
21 int SingleSelection() const { return selection; }
23 bool SelectMultiple() const { return multiple; }
24 void SetMultiple() { multiple = true; }
25 bool SelectSingle() const { return !SelectMultiple(); }
26 void SetSingle() { multiple = false; }
28 void ReadMode(const common::TargetingMode &);
30 void SelectMonsters();
32 void Select(int index) { selected[index].type = State::SELECTED; selection = index; }
33 void Unselect(int index) { selected[index].type = State::IGNORE; }
34 void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
37 void Resize(int num) { selected.resize(num); }
43 void Select() { Select(cursor); }
44 void Unselect() { Unselect(cursor); }
45 int Current() const { return cursor; }
46 bool CurrentIsSelected() { return IsSelected(cursor); }
48 void SetMiss(int index) { selected[index].type = State::MISS; }
49 void SetFull(int index) { selected[index].type = State::FULL; }
50 void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
51 void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
52 int GetAmount(int index) const { return selected[index].number; }
53 bool Missed(int index) const { return selected[index].type == State::MISS; }
54 bool IsGood(int index) const { return selected[index].type == State::GOOD; }
55 bool IsBad(int index) const { return selected[index].type == State::BAD; }
71 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
74 std::vector<State> selected;
84 #endif /* BATTLE_TARGETSELECTION_H_ */