1 #ifndef BATTLE_TARGETSELECTION_H_
2 #define BATTLE_TARGETSELECTION_H_
14 class TargetSelection {
17 explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
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; }
26 bool SelectMultiple() const { return multiple; }
27 void SetMultiple() { multiple = true; }
28 bool SelectSingle() const { return !SelectMultiple(); }
29 void SetSingle() { multiple = false; }
31 void ReadMode(const common::TargetingMode &);
33 void SelectMonsters();
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; }
40 void Resize(int num) { selected.resize(num); }
46 void Select() { Select(cursor); }
47 void Unselect() { Unselect(cursor); }
48 int Current() const { return cursor; }
49 bool CurrentIsSelected() { return IsSelected(cursor); }
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; }
74 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
77 std::vector<State> selected;