4 * Created on: Aug 9, 2012
8 #include "TargetSelection.h"
10 #include "BattleState.h"
11 #include "../common/TargetingMode.h"
15 TargetSelection::TargetSelection(BattleState *battle, bool multiple, bool atEnemy)
17 , selected(battle ? (battle->MaxMonsters() > battle->NumHeroes() ? battle->MaxMonsters() : battle->NumHeroes()) : 0, State())
22 if (battle && enemy) {
28 void TargetSelection::ReadMode(const common::TargetingMode &tm) {
29 if (tm.TargetsEnemy()) {
34 if (tm.TargetsSingle()) {
36 } else if (tm.TargetsMultiple()) {
42 void TargetSelection::SelectMonsters() {
43 if (TargetsMonsters()) return;
50 void TargetSelection::SelectHeroes() {
51 if (TargetsHeroes()) return;
58 void TargetSelection::Reset() {
61 if (TargetsMonsters()) {
67 void TargetSelection::MoveUp() {
68 if (TargetsMonsters()) return;
76 void TargetSelection::MoveRight() {
77 if (TargetsMonsters()) {
78 cursor = (cursor + 1) % battle->MaxMonsters();
79 while (!battle->MonsterPositionOccupied(cursor)) {
80 cursor = (cursor + 1) % battle->MaxMonsters();
83 cursor = (cursor + 1) % battle->NumHeroes();
87 void TargetSelection::MoveDown() {
88 if (TargetsMonsters()) {
92 int newCursor((cursor + 2) % 4);
93 if (newCursor < battle->NumHeroes()) {
98 void TargetSelection::MoveLeft() {
99 if (TargetsMonsters()) {
100 cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters();
103 cursor = (cursor + battle->NumHeroes() - 1) % battle->NumHeroes();
107 void TargetSelection::FindNextEnemy() {
109 while (!battle->MonsterPositionOccupied(cursor)) {
110 cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters();
111 if (cursor == start) break;