4 * Created on: Aug 9, 2012
8 #ifndef BATTLE_TARGETSELECTION_H_
9 #define BATTLE_TARGETSELECTION_H_
12 #include "../common/fwd.h"
18 class TargetSelection {
21 explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
24 bool TargetsMonsters() const { return enemy; }
25 bool TargetsHeroes() const { return !TargetsMonsters(); }
26 bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; }
27 bool HasSelected() const { return selection >= 0; }
28 int SingleSelection() const { return selection; }
30 bool SelectMultiple() const { return multiple; }
31 void SetMultiple() { multiple = true; }
32 bool SelectSingle() const { return !SelectMultiple(); }
33 void SetSingle() { multiple = false; }
35 void ReadMode(const common::TargetingMode &);
37 void SelectMonsters();
39 void Select(int index) { selected[index].type = State::SELECTED; selection = index; }
40 void Unselect(int index) { selected[index].type = State::IGNORE; }
41 void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
44 void Resize(int num) { selected.resize(num); }
50 void Select() { Select(cursor); }
51 void Unselect() { Unselect(cursor); }
52 int Current() const { return cursor; }
53 bool CurrentIsSelected() { return IsSelected(cursor); }
55 void SetMiss(int index) { selected[index].type = State::MISS; }
56 void SetFull(int index) { selected[index].type = State::FULL; }
57 void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
58 void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
59 int GetAmount(int index) const { return selected[index].number; }
60 bool Missed(int index) const { return selected[index].type == State::MISS; }
61 bool IsGood(int index) const { return selected[index].type == State::GOOD; }
62 bool IsBad(int index) const { return selected[index].type == State::BAD; }
78 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
81 std::vector<State> selected;
91 #endif /* BATTLE_TARGETSELECTION_H_ */