# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/battle/AttackChoice.cpp \
../src/battle/AttackTypeMenu.cpp \
../src/battle/BattleState.cpp \
../src/battle/Hero.cpp \
../src/battle/PartyLayout.cpp
OBJS += \
+./src/battle/AttackChoice.o \
./src/battle/AttackTypeMenu.o \
./src/battle/BattleState.o \
./src/battle/Hero.o \
./src/battle/PartyLayout.o
CPP_DEPS += \
+./src/battle/AttackChoice.d \
./src/battle/AttackTypeMenu.d \
./src/battle/BattleState.d \
./src/battle/Hero.d \
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/battle/AttackChoice.cpp \
../src/battle/AttackTypeMenu.cpp \
../src/battle/BattleState.cpp \
../src/battle/Hero.cpp \
../src/battle/PartyLayout.cpp
OBJS += \
+./src/battle/AttackChoice.o \
./src/battle/AttackTypeMenu.o \
./src/battle/BattleState.o \
./src/battle/Hero.o \
./src/battle/PartyLayout.o
CPP_DEPS += \
+./src/battle/AttackChoice.d \
./src/battle/AttackTypeMenu.d \
./src/battle/BattleState.d \
./src/battle/Hero.d \
--- /dev/null
+/*
+ * AttackChoice.cpp
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#include "AttackChoice.h"
+
+namespace battle {
+
+}
--- /dev/null
+/*
+ * AttackChoice.h
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_ATTACKCHOICE_H_
+#define BATTLE_ATTACKCHOICE_H_
+
+namespace battle {
+
+class AttackChoice {
+
+public:
+ enum Type {
+ SWORD,
+ MAGIC,
+ DEFEND,
+ IKARI,
+ ITEM,
+ UNDECIDED
+ };
+
+public:
+ AttackChoice() : type(UNDECIDED) { }
+ ~AttackChoice() { }
+
+public:
+ Type GetType() const { return type; }
+ void SetType(Type t) { type = t; }
+
+private:
+ Type type;
+
+};
+
+}
+
+#endif /* BATTLE_ATTACKCHOICE_H_ */
Vector<int> ikariOffset(IconWidth(), 2 * IconHeight());
Vector<int> itemOffset(0, IconHeight());
- icons->Draw(screen, position + swordOffset, SWORD, (selected == SWORD) ? 1 : 0);
- icons->Draw(screen, position + magicOffset, MAGIC, (selected == MAGIC) ? 1 : 0);
- icons->Draw(screen, position + defendOffset, DEFEND, (selected == DEFEND) ? 1 : 0);
- icons->Draw(screen, position + ikariOffset, IKARI, (selected == IKARI) ? 1 : 0);
- icons->Draw(screen, position + itemOffset, ITEM, (selected == ITEM) ? 1 : 0);
+ icons->Draw(screen, position + swordOffset, AttackChoice::SWORD, (selected == AttackChoice::SWORD) ? 1 : 0);
+ icons->Draw(screen, position + magicOffset, AttackChoice::MAGIC, (selected == AttackChoice::MAGIC) ? 1 : 0);
+ icons->Draw(screen, position + defendOffset, AttackChoice::DEFEND, (selected == AttackChoice::DEFEND) ? 1 : 0);
+ icons->Draw(screen, position + ikariOffset, AttackChoice::IKARI, (selected == AttackChoice::IKARI) ? 1 : 0);
+ icons->Draw(screen, position + itemOffset, AttackChoice::ITEM, (selected == AttackChoice::ITEM) ? 1 : 0);
}
}
#ifndef BATTLE_ATTACKTYPEMENU_H_
#define BATTLE_ATTACKTYPEMENU_H_
+#include "AttackChoice.h"
#include "../geometry/Point.h"
#include "../graphics/Sprite.h"
class AttackTypeMenu {
-public:
- enum Icon {
- SWORD,
- MAGIC,
- DEFEND,
- IKARI,
- ITEM
- };
-
public:
explicit AttackTypeMenu(const graphics::Sprite *icons)
- : icons(icons), selected(SWORD) { }
+ : icons(icons), selected(AttackChoice::SWORD) { }
public:
- void Select(Icon i) { selected = i; }
- Icon Selected() const { return selected; }
+ void Select(AttackChoice::Type t) { selected = t; }
+ AttackChoice::Type Selected() const { return selected; }
void Render(SDL_Surface *screen, const geometry::Point<int> &position);
int Width() const { return 3 * IconWidth(); }
private:
const graphics::Sprite *icons;
- Icon selected;
+ AttackChoice::Type selected;
};
, heroesLayout(&heroesLayout)
, attackTypeMenu(attackIcons)
, moveMenu(moveIcons)
- , moveChoice(-1)
- , activeHero(0) { }
+ , activeHero(-1) { }
public:
void AddMonster(const Monster &);
AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
MoveMenu &GetMoveMenu() { return moveMenu; }
+ bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
+ void NextHero() { ++activeHero; }
+
public:
geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
return geometry::Vector<int>(
std::vector<Monster> monsters;
std::vector<Hero> heroes;
std::vector<HeroTag> heroTags;
- int moveChoice;
int activeHero;
};
#include "SelectAttackType.h"
+#include "../AttackChoice.h"
#include "../BattleState.h"
#include "../../app/Input.h"
#include "../../geometry/operators.h"
+#include <stdexcept>
+
using app::Input;
using geometry::Point;
using geometry::Vector;
void SelectAttackType::HandleInput(const Input &input) {
if (input.IsDown(Input::PAD_UP)) {
- battle->GetAttackTypeMenu().Select(AttackTypeMenu::MAGIC);
+ battle->GetAttackTypeMenu().Select(AttackChoice::MAGIC);
} else if (input.IsDown(Input::PAD_RIGHT)) {
- battle->GetAttackTypeMenu().Select(AttackTypeMenu::DEFEND);
+ battle->GetAttackTypeMenu().Select(AttackChoice::DEFEND);
} else if (input.IsDown(Input::PAD_DOWN)) {
- battle->GetAttackTypeMenu().Select(AttackTypeMenu::IKARI);
+ battle->GetAttackTypeMenu().Select(AttackChoice::IKARI);
} else if (input.IsDown(Input::PAD_LEFT)) {
- battle->GetAttackTypeMenu().Select(AttackTypeMenu::ITEM);
+ battle->GetAttackTypeMenu().Select(AttackChoice::ITEM);
} else {
- battle->GetAttackTypeMenu().Select(AttackTypeMenu::SWORD);
+ battle->GetAttackTypeMenu().Select(AttackChoice::SWORD);
}
if (input.JustPressed(Input::ACTION_A)) {
switch (battle->GetAttackTypeMenu().Selected()) {
- case AttackTypeMenu::SWORD:
+ case AttackChoice::SWORD:
// TODO: switch to next character
break;
- case AttackTypeMenu::MAGIC:
+ case AttackChoice::MAGIC:
// TODO: switch to spell select
break;
- case AttackTypeMenu::DEFEND:
+ case AttackChoice::DEFEND:
// TODO: switch to next character
break;
- case AttackTypeMenu::IKARI:
+ case AttackChoice::IKARI:
// TODO: switch to ikari attack select
break;
- case AttackTypeMenu::ITEM:
+ case AttackChoice::ITEM:
// TODO: switch to item select
break;
+ default:
+ throw std::logic_error("selected invalid attack type");
}
}
}
switch (battle->GetMoveMenu().Selected()) {
case MoveMenu::ATTACK:
ctrl->ChangeState(new SelectAttackType(battle));
+ battle->NextHero();
break;
case MoveMenu::CHANGE:
// TODO: switch to change state