]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/TargetSelection.h
removed useless comments
[l2e.git] / src / battle / TargetSelection.h
index 664e9607e86caaf374f53d5f1f6d2a3151f59554..3c70518f21613540c7c0cc2dd029acb02f95cdf2 100644 (file)
@@ -1,13 +1,10 @@
-/*
- * TargetSelection.h
- *
- *  Created on: Aug 9, 2012
- *      Author: holy
- */
-
 #ifndef BATTLE_TARGETSELECTION_H_
 #define BATTLE_TARGETSELECTION_H_
 
+namespace common {
+       class TargetingMode;
+}
+
 #include <vector>
 
 namespace battle {
@@ -20,9 +17,9 @@ 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 TargetsMonsters() const { return enemy; }
+       bool TargetsHeroes() const { return !TargetsMonsters(); }
+       bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; }
        bool HasSelected() const { return selection >= 0; }
        int SingleSelection() const { return selection; }
 
@@ -31,14 +28,16 @@ public:
        bool SelectSingle() const { return !SelectMultiple(); }
        void SetSingle() { multiple = false; }
 
-       void SelectEnemies();
+       void ReadMode(const common::TargetingMode &);
+
+       void SelectMonsters();
        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 Select(int index) { selected[index].type = State::SELECTED; selection = index; }
+       void Unselect(int index) { selected[index].type = State::IGNORE; }
+       void UnselectAll() { selected.assign(selected.size(), State()); selection = -1; }
 
        void Reset();
-       void Resize(int num) { selected.resize(num, false); }
+       void Resize(int num) { selected.resize(num); }
 
        void MoveUp();
        void MoveRight();
@@ -49,12 +48,33 @@ public:
        int Current() const { return cursor; }
        bool CurrentIsSelected() { return IsSelected(cursor); }
 
+       void SetMiss(int index) { selected[index].type = State::MISS; }
+       void SetFull(int index) { selected[index].type = State::FULL; }
+       void SetGood(int index, int amount) { selected[index].type = State::GOOD; selected[index].number = amount; }
+       void SetBad(int index, int amount) { selected[index].type = State::BAD; selected[index].number = amount; }
+       int GetAmount(int index) const { return selected[index].number; }
+       bool Missed(int index) const { return selected[index].type == State::MISS; }
+       bool IsGood(int index) const { return selected[index].type == State::GOOD; }
+       bool IsBad(int index) const { return selected[index].type == State::BAD; }
+
 private:
        void FindNextEnemy();
 
 private:
+       struct State {
+               enum Type {
+                       IGNORE,
+                       SELECTED,
+                       MISS,
+                       FULL,
+                       GOOD,
+                       BAD,
+               } type;
+               int number;
+               explicit State(Type type = IGNORE, int num = 0) : type(type), number(num) { }
+       };
        BattleState *battle;
-       std::vector<bool> selected;
+       std::vector<State> selected;
        int selection;
        int cursor;
        bool multiple;
@@ -64,4 +84,4 @@ private:
 
 }
 
-#endif /* BATTLE_TARGETSELECTION_H_ */
+#endif