+/*
+ * TargetSelection.h
+ *
+ * Created on: Aug 9, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_TARGETSELECTION_H_
+#define BATTLE_TARGETSELECTION_H_
+
+#include <vector>
+
+namespace battle {
+
+class BattleState;
+
+class TargetSelection {
+
+public:
+ explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
+
+public:
+ bool TargetsEnemies() const { return enemy; }
+ bool TargetsHeroes() const { return !TargetsEnemies(); }
+ bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index]; }
+ bool HasSelected() const { return selection >= 0; }
+ int SingleSelection() const { return selection; }
+
+ bool SelectMultiple() const { return multiple; }
+ void SetMultiple() { multiple = true; }
+ bool SelectSingle() const { return !SelectMultiple(); }
+ void SetSingle() { multiple = false; }
+
+ void SelectEnemies();
+ void SelectHeroes();
+ void Select(int index) { selected[index] = true; selection = index; }
+ void Unselect(int index) { selected[index] = false; }
+ void UnselectAll() { selected.assign(selected.size(), false); selection = -1; }
+
+ void Reset();
+ void Resize(int num) { selected.resize(num, false); }
+
+ void MoveUp();
+ void MoveRight();
+ void MoveDown();
+ void MoveLeft();
+ void Select() { Select(cursor); }
+ void Unselect() { Unselect(cursor); }
+ int Current() const { return cursor; }
+ bool CurrentIsSelected() { return IsSelected(cursor); }
+
+private:
+ void FindNextEnemy();
+
+private:
+ BattleState *battle;
+ std::vector<bool> selected;
+ int selection;
+ int cursor;
+ bool multiple;
+ bool enemy;
+
+};
+
+}
+
+#endif /* BATTLE_TARGETSELECTION_H_ */