4 * Created on: Aug 9, 2012
8 #ifndef BATTLE_TARGETSELECTION_H_
9 #define BATTLE_TARGETSELECTION_H_
17 class TargetSelection {
20 explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
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; }
29 bool SelectMultiple() const { return multiple; }
30 void SetMultiple() { multiple = true; }
31 bool SelectSingle() const { return !SelectMultiple(); }
32 void SetSingle() { multiple = false; }
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; }
41 void Resize(int num) { selected.resize(num); }
47 void Select() { Select(cursor); }
48 void Unselect() { Unselect(cursor); }
49 int Current() const { return cursor; }
50 bool CurrentIsSelected() { return IsSelected(cursor); }
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 bool Missed(int index) const { return selected[index].type == State::MISS; }
58 bool IsGood(int index) const { return selected[index].type == State::GOOD; }
59 bool IsBad(int index) const { return selected[index].type == State::BAD; }
75 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
78 std::vector<State> selected;
88 #endif /* BATTLE_TARGETSELECTION_H_ */