4 * Created on: Aug 9, 2012
8 #ifndef BATTLE_TARGETSELECTION_H_
9 #define BATTLE_TARGETSELECTION_H_
13 namespace common { class TargetingMode; }
19 class TargetSelection {
22 explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true);
25 bool TargetsMonsters() const { return enemy; }
26 bool TargetsHeroes() const { return !TargetsMonsters(); }
27 bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; }
28 bool HasSelected() const { return selection >= 0; }
29 int SingleSelection() const { return selection; }
31 bool SelectMultiple() const { return multiple; }
32 void SetMultiple() { multiple = true; }
33 bool SelectSingle() const { return !SelectMultiple(); }
34 void SetSingle() { multiple = false; }
36 void ReadMode(const common::TargetingMode &);
38 void SelectMonsters();
40 void Select(int index) { selected[index].type = State::SELECTED; selection = index; }
41 void Unselect(int index) { selected[index].type = State::IGNORE; }
42 void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
45 void Resize(int num) { selected.resize(num); }
51 void Select() { Select(cursor); }
52 void Unselect() { Unselect(cursor); }
53 int Current() const { return cursor; }
54 bool CurrentIsSelected() { return IsSelected(cursor); }
56 void SetMiss(int index) { selected[index].type = State::MISS; }
57 void SetFull(int index) { selected[index].type = State::FULL; }
58 void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
59 void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
60 int GetAmount(int index) const { return selected[index].number; }
61 bool Missed(int index) const { return selected[index].type == State::MISS; }
62 bool IsGood(int index) const { return selected[index].type == State::GOOD; }
63 bool IsBad(int index) const { return selected[index].type == State::BAD; }
79 explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
82 std::vector<State> selected;
92 #endif /* BATTLE_TARGETSELECTION_H_ */