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]; }
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] = true; selection = index; }
37 void Unselect(int index) { selected[index] = false; }
38 void UnselectAll() { selected.assign(selected.size(), false); selection = -1; }
41 void Resize(int num) { selected.resize(num, false); }
47 void Select() { Select(cursor); }
48 void Unselect() { Unselect(cursor); }
49 int Current() const { return cursor; }
50 bool CurrentIsSelected() { return IsSelected(cursor); }
57 std::vector<bool> selected;
67 #endif /* BATTLE_TARGETSELECTION_H_ */