1 #include "TargetSelection.h"
3 #include "BattleState.h"
4 #include "../common/TargetingMode.h"
8 TargetSelection::TargetSelection(BattleState *battle, bool multiple, bool atEnemy)
10 , selected(battle ? (battle->MaxMonsters() > battle->NumHeroes() ? battle->MaxMonsters() : battle->NumHeroes()) : 0, State())
15 if (battle && enemy) {
21 void TargetSelection::ReadMode(const common::TargetingMode &tm) {
22 if (tm.TargetsEnemy()) {
27 if (tm.TargetsSingle()) {
29 } else if (tm.TargetsMultiple()) {
35 void TargetSelection::SelectMonsters() {
36 if (TargetsMonsters()) return;
43 void TargetSelection::SelectHeroes() {
44 if (TargetsHeroes()) return;
51 void TargetSelection::Reset() {
54 if (TargetsMonsters()) {
60 void TargetSelection::MoveUp() {
61 if (TargetsMonsters()) return;
69 void TargetSelection::MoveRight() {
71 if (TargetsMonsters()) {
72 cursor = (cursor + 1) % battle->MaxMonsters();
73 while (!battle->MonsterPositionOccupied(cursor)) {
74 cursor = (cursor + 1) % battle->MaxMonsters();
77 cursor = (cursor + 1) % battle->NumHeroes();
81 void TargetSelection::MoveDown() {
83 if (TargetsMonsters()) {
87 int newCursor((cursor + 2) % 4);
88 if (newCursor < battle->NumHeroes()) {
93 void TargetSelection::MoveLeft() {
95 if (TargetsMonsters()) {
96 cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters();
99 cursor = (cursor + battle->NumHeroes() - 1) % battle->NumHeroes();
103 void TargetSelection::FindNextEnemy() {
106 while (!battle->MonsterPositionOccupied(cursor)) {
107 cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters();
108 if (cursor == start) break;