../src/battle/PartyLayout.cpp \
../src/battle/Resources.cpp \
../src/battle/SmallHeroTag.cpp \
-../src/battle/Stats.cpp \
../src/battle/TargetSelection.cpp
OBJS += \
./src/battle/PartyLayout.o \
./src/battle/Resources.o \
./src/battle/SmallHeroTag.o \
-./src/battle/Stats.o \
./src/battle/TargetSelection.o
CPP_DEPS += \
./src/battle/PartyLayout.d \
./src/battle/Resources.d \
./src/battle/SmallHeroTag.d \
-./src/battle/Stats.d \
./src/battle/TargetSelection.d
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/common/GameState.cpp \
+../src/common/Hero.cpp \
../src/common/Ikari.cpp \
../src/common/Inventory.cpp \
../src/common/Item.cpp \
../src/common/Spell.cpp \
+../src/common/Stats.cpp \
../src/common/TargetingMode.cpp
OBJS += \
+./src/common/GameState.o \
+./src/common/Hero.o \
./src/common/Ikari.o \
./src/common/Inventory.o \
./src/common/Item.o \
./src/common/Spell.o \
+./src/common/Stats.o \
./src/common/TargetingMode.o
CPP_DEPS += \
+./src/common/GameState.d \
+./src/common/Hero.d \
./src/common/Ikari.d \
./src/common/Inventory.d \
./src/common/Item.d \
./src/common/Spell.d \
+./src/common/Stats.d \
./src/common/TargetingMode.d
../src/battle/PartyLayout.cpp \
../src/battle/Resources.cpp \
../src/battle/SmallHeroTag.cpp \
-../src/battle/Stats.cpp \
../src/battle/TargetSelection.cpp
OBJS += \
./src/battle/PartyLayout.o \
./src/battle/Resources.o \
./src/battle/SmallHeroTag.o \
-./src/battle/Stats.o \
./src/battle/TargetSelection.o
CPP_DEPS += \
./src/battle/PartyLayout.d \
./src/battle/Resources.d \
./src/battle/SmallHeroTag.d \
-./src/battle/Stats.d \
./src/battle/TargetSelection.d
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/common/GameState.cpp \
+../src/common/Hero.cpp \
../src/common/Ikari.cpp \
../src/common/Inventory.cpp \
../src/common/Item.cpp \
../src/common/Spell.cpp \
+../src/common/Stats.cpp \
../src/common/TargetingMode.cpp
OBJS += \
+./src/common/GameState.o \
+./src/common/Hero.o \
./src/common/Ikari.o \
./src/common/Inventory.o \
./src/common/Item.o \
./src/common/Spell.o \
+./src/common/Stats.o \
./src/common/TargetingMode.o
CPP_DEPS += \
+./src/common/GameState.d \
+./src/common/Hero.d \
./src/common/Ikari.d \
./src/common/Inventory.d \
./src/common/Item.d \
./src/common/Spell.d \
+./src/common/Stats.d \
./src/common/TargetingMode.d
using common::Inventory;
using common::Item;
using common::Spell;
+using common::Stats;
using geometry::Vector;
using graphics::Menu;
#include "../app/fwd.h"
#include "../app/State.h"
#include "../common/fwd.h"
+#include "../common/Stats.h"
#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include "../graphics/fwd.h"
void LoadInventory();
void DecideMonsterAttack(Monster &) const;
- void CalculateDamage(const Stats &attackerStats, TargetSelection &targets) const;
- Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const;
+ void CalculateDamage(const common::Stats &attackerStats, TargetSelection &targets) const;
+ Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const;
private:
SDL_Surface *background;
#include "../common/Ikari.h"
#include "../common/Item.h"
#include "../common/Spell.h"
-#include "../loader/TypeDescription.h"
using common::Ikari;
using common::Spell;
-using loader::FieldDescription;
-using loader::TypeDescription;
using std::vector;
namespace battle {
Hero::Hero()
-: name("")
-, sprite(0)
-
-, weapon(0)
-, armor(0)
-, shield(0)
-, helmet(0)
-, ring(0)
-, jewel(0)
-
-, meleeAnimation(0)
-, attackAnimation(0)
-, spellAnimation(0)
-
-, maxHealth(0)
-, health(0)
-, maxMana(0)
-, mana(0)
-
-, level(0)
-, ip(0) {
+: master(0) {
}
-Hero::~Hero() {
+Hero::Hero(common::Hero &h)
+: master(&h)
+, stats(h.GetStats()) {
}
+Hero::~Hero() {
-void Hero::SubtractHealth(int amount) {
- if (amount > Health()) {
- health = 0;
- } else {
- health -= amount;
- int ipGain(amount * 255 / health);
- if (ip + ipGain > 255) {
- ip = 255;
- } else {
- ip += ipGain;
- }
- }
}
}
}
-
-void Hero::CreateTypeDescription() {
- Hero h;
-
- int animationId(TypeDescription::GetTypeId("Animation"));
- int numberId(TypeDescription::GetTypeId("Number"));
- int spriteId(TypeDescription::GetTypeId("Sprite"));
- int statsId(TypeDescription::GetTypeId("Stats"));
- int stringId(TypeDescription::GetTypeId("String"));
-
- TypeDescription &td(TypeDescription::CreateOrGet("Hero"));
- td.SetConstructor(&Construct);
- td.SetSize(sizeof(Hero));
-
- td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId, true));
- td.AddField("sprite", FieldDescription(((char *)&h.sprite) - ((char *)&h), spriteId, true));
- td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false));
-
- td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId, false));
- td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId, false));
- td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId, false));
- td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId, false));
- td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId, false));
- td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId, false));
-
- td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId, true));
- td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, true));
- td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, true));
-}
-
-void Hero::Construct(void *data) {
- new (data) Hero;
-}
-
}
#include "fwd.h"
#include "AttackChoice.h"
-#include "Stats.h"
#include "../common/fwd.h"
+#include "../common/Hero.h"
+#include "../common/Stats.h"
#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include "../graphics/fwd.h"
public:
Hero();
+ Hero(common::Hero &);
~Hero();
public:
- const char *Name() const { return name; }
- Uint8 Level() const { return level; }
- const graphics::Sprite *Sprite() const { return sprite; }
+ const char *Name() const { return master->Name(); }
+ Uint8 Level() const { return master->Level(); }
+ const graphics::Sprite *Sprite() const { return master->BattleSprite(); }
- const std::vector<const common::Spell *> &Spells() const { return spells; }
+ const std::vector<const common::Spell *> &Spells() const { return master->Spells(); }
- Uint16 MaxHealth() const { return maxHealth; }
- Uint16 Health() const { return health; }
+ Uint16 MaxHealth() const { return master->MaxHealth(); }
+ Uint16 Health() const { return master->Health(); }
int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
- void SubtractHealth(int amount);
+ void SubtractHealth(int amount) { master->SubtractHealth(amount); }
- Uint16 MaxMana() const { return maxMana; }
- Uint16 Mana() const { return mana; }
+ Uint16 MaxMana() const { return master->MaxMana(); }
+ Uint16 Mana() const { return master->Mana(); }
int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
bool CanUseMagic() const { return MaxMana() > 0; }
- Uint8 MaxIP() const { return 255; }
- Uint8 IP() const { return ip; }
+ Uint8 MaxIP() const { return master->MaxIP(); }
+ Uint8 IP() const { return master->IP(); }
int RelativeIP(int max) const { return IP() * max / MaxIP(); }
- Stats &GetStats() { return stats; }
- const Stats &GetStats() const { return stats; }
-
- common::Item *Weapon() { return weapon; }
- common::Item *Armor() { return armor; }
- common::Item *Shield() { return shield; }
- common::Item *Helmet() { return helmet; }
- common::Item *Ring() { return ring; }
- common::Item *Jewel() { return jewel; }
-
- const common::Item *Weapon() const { return weapon; }
- const common::Item *Armor() const { return armor; }
- const common::Item *Shield() const { return shield; }
- const common::Item *Helmet() const { return helmet; }
- const common::Item *Ring() const { return ring; }
- const common::Item *Jewel() const { return jewel; }
-
- bool HasWeapon() const { return weapon; }
- bool HasArmor() const { return armor; }
- bool HasShield() const { return shield; }
- bool HasHelmet() const { return helmet; }
- bool HasRing() const { return ring; }
- bool HasJewel() const { return jewel; }
+ common::Stats &GetStats() { return stats; }
+ const common::Stats &GetStats() const { return stats; }
+
+ common::Item *Weapon() { return master->Weapon(); }
+ common::Item *Armor() { return master->Armor(); }
+ common::Item *Shield() { return master->Shield(); }
+ common::Item *Helmet() { return master->Helmet(); }
+ common::Item *Ring() { return master->Ring(); }
+ common::Item *Jewel() { return master->Jewel(); }
+
+ const common::Item *Weapon() const { return master->Weapon(); }
+ const common::Item *Armor() const { return master->Armor(); }
+ const common::Item *Shield() const { return master->Shield(); }
+ const common::Item *Helmet() const { return master->Helmet(); }
+ const common::Item *Ring() const { return master->Ring(); }
+ const common::Item *Jewel() const { return master->Jewel(); }
+
+ bool HasWeapon() const { return master->HasWeapon(); }
+ bool HasArmor() const { return master->HasArmor(); }
+ bool HasShield() const { return master->HasShield(); }
+ bool HasHelmet() const { return master->HasHelmet(); }
+ bool HasRing() const { return master->HasRing(); }
+ bool HasJewel() const { return master->HasJewel(); }
graphics::AnimationRunner &GetAnimation() { return animation; }
const graphics::AnimationRunner &GetAnimation() const { return animation; }
void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
- const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
- const graphics::Animation *AttackAnimation() const { return attackAnimation; }
- const graphics::Animation *SpellAnimation() const { return spellAnimation; }
+ const graphics::Animation *MeleeAnimation() const { return master->MeleeAnimation(); }
+ const graphics::Animation *AttackAnimation() const { return master->AttackAnimation(); }
+ const graphics::Animation *SpellAnimation() const { return master->SpellAnimation(); }
geometry::Vector<int> &Position() { return position; }
const geometry::Vector<int> &Position() const { return position; }
void UpdateSpellMenu();
void UpdateIkariMenu(const Resources *);
-// temporary setters until loader is implemented
-public:
- void SetName(const char *n) { name = n; }
- void SetLevel(Uint8 l) { level = l; }
- void SetSprite(graphics::Sprite *s) { sprite = s; }
-
- void SetMaxHealth(Uint16 h) { maxHealth = h; }
- void SetHealth(Uint16 h) { health = h; }
- void SetMaxMana(Uint16 m) { maxMana = m; }
- void SetMana(Uint16 m) { mana = m; }
- void SetIP(Uint8 i) { ip = i; }
-
- void SetStats(const Stats &s) { stats = s; }
-
- void SetWeapon(common::Item *i) { weapon = i; }
- void SetArmor(common::Item *i) { armor = i; }
- void SetShield(common::Item *i) { shield = i; }
- void SetHelmet(common::Item *i) { helmet = i; }
- void SetRing(common::Item *i) { ring = i; }
- void SetJewel(common::Item *i) { jewel = i; }
-
- void AddSpell(const common::Spell *s) { spells.push_back(s); }
-
- void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
- void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
- void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
-
- static void CreateTypeDescription();
- static void Construct(void *);
-
private:
- const char *name;
- graphics::Sprite *sprite;
-
- common::Item *weapon;
- common::Item *armor;
- common::Item *shield;
- common::Item *helmet;
- common::Item *ring;
- common::Item *jewel;
-
- const graphics::Animation *meleeAnimation;
- const graphics::Animation *attackAnimation;
- const graphics::Animation *spellAnimation;
+ common::Hero *master;
graphics::AnimationRunner animation;
AttackChoice attackChoice;
- // TODO: vector does not seem to be a good choice
- std::vector<const common::Spell *> spells;
-
- int maxHealth, health;
- int maxMana, mana;
-
- Stats stats;
-
- int level;
- int ip;
+ common::Stats stats;
};
#define BATTLE_MONSTER_H_
#include "AttackChoice.h"
-#include "Stats.h"
#include "../common/fwd.h"
+#include "../common/Stats.h"
#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include "../graphics/fwd.h"
Uint16 Mana() const { return mana; }
int RelativeMana(int max) const { return mana * max / maxMana; }
- Stats &GetStats() { return stats; }
- const Stats &GetStats() const { return stats; }
+ common::Stats &GetStats() { return stats; }
+ const common::Stats &GetStats() const { return stats; }
Uint16 ExpReward() const { return expReward; }
Uint16 GoldReward() const { return goldReward; }
void SetHealth(Uint16 h) { health = h; }
void SetMaxMana(Uint16 m) { maxMana = m; }
void SetMana(Uint16 m) { mana = m; }
- void SetStats(const Stats &s) { stats = s; }
+ void SetStats(const common::Stats &s) { stats = s; }
void SetReward(Uint16 exp, Uint16 gold) { expReward = exp; goldReward = gold; }
void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
int maxHealth, health;
int maxMana, mana;
- Stats stats;
+ common::Stats stats;
int expReward, goldReward;
+++ /dev/null
-/*
- * Stats.cpp
- *
- * Created on: Aug 19, 2012
- * Author: holy
- */
-
-#include "Stats.h"
-
-#include "../loader/TypeDescription.h"
-
-using loader::FieldDescription;
-using loader::TypeDescription;
-
-namespace battle {
-
-Stats::Stats()
-: attack(0)
-, defense(0)
-, strength(0)
-, agility(0)
-, intelligence(0)
-, magicResistance(0)
-, gut(0) {
-
-}
-
-Stats::Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance)
-: attack(attack)
-, defense(defense)
-, strength(strength)
-, agility(agility)
-, intelligence(intelligence)
-, magicResistance(magicResistance)
-, gut(gut) {
-
-}
-
-
-void Stats::CreateTypeDescription() {
- Stats s;
-
- int numberId(TypeDescription::GetTypeId("Number"));
-
- TypeDescription &td(TypeDescription::CreateOrGet("Stats"));
- td.SetConstructor(&Construct);
- td.SetSize(sizeof(Stats));
-
- td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), numberId, false));
- td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), numberId, false));
- td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), numberId, false));
- td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), numberId, false));
- td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), numberId, false));
- td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), numberId, false));
- td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), numberId, false));
-}
-
-void Stats::Construct(void *data) {
- new (data) Stats;
-}
-
-}
+++ /dev/null
-/*
- * Stats.h
- *
- * Created on: Aug 19, 2012
- * Author: holy
- */
-
-#ifndef BATTLE_STATS_H_
-#define BATTLE_STATS_H_
-
-#include <SDL.h>
-
-namespace battle {
-
-class Stats {
-
-public:
- Stats();
- Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance);
-
-public:
- Uint16 Attack() const { return attack; }
- Uint16 Defense() const { return defense; }
- Uint16 Strength() const { return strength; }
- Uint16 Agility() const { return agility; }
- Uint16 Intelligence() const { return intelligence; }
- Uint8 Gut() const { return gut; }
- Uint16 MagicResistance() const { return magicResistance; }
-
- void SetAttack(Uint16 a) { attack = a; }
- void SetDefense(Uint16 d) { defense = d; }
- void SetStrength(Uint16 s) { strength = s; }
- void SetAgility(Uint16 a) { agility = a; }
- void SetIntelligence(Uint16 i) { intelligence = i; }
- void SetGut(Uint8 g) { gut = g; }
- void SetMagicResistance(Uint16 m) { magicResistance = m; }
-
- static void CreateTypeDescription();
- static void Construct(void *);
-
-private:
- int attack;
- int defense;
- int strength;
- int agility;
- int intelligence;
- int magicResistance;
- int gut;
-
-};
-
-}
-
-#endif /* BATTLE_STATS_H_ */
class SelectSpell;
class SelectTarget;
class SmallHeroTag;
-class Stats;
class SwapHeroes;
class TargetSelection;
--- /dev/null
+/*
+ * GameState.cpp
+ *
+ * Created on: Oct 7, 2012
+ * Author: holy
+ */
+
+#include "GameState.h"
+
+namespace common {
+
+GameState::GameState()
+: money(0) {
+ party[0] = heroes;
+ party[1] = 0;
+ party[2] = 0;
+ party[3] = 0;
+}
+
+}
--- /dev/null
+/*
+ * GameState.h
+ *
+ * Created on: Oct 7, 2012
+ * Author: holy
+ */
+
+#ifndef COMMON_GAMESTATE_H_
+#define COMMON_GAMESTATE_H_
+
+#include "Hero.h"
+
+#include <SDL.h>
+
+namespace common {
+
+struct GameState {
+
+ GameState();
+
+ Hero heroes[7];
+ Hero *party[4];
+
+ Uint32 money;
+
+};
+
+}
+
+#endif /* COMMON_GAMESTATE_H_ */
--- /dev/null
+/*
+ * Hero.cpp
+ *
+ * Created on: Oct 7, 2012
+ * Author: holy
+ */
+
+#include "Hero.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace common {
+
+Hero::Hero()
+: name(0)
+
+, maxHealth(0)
+, health(0)
+, maxMana(0)
+, mana(0)
+, ip(0)
+
+, level(0)
+
+, weapon(0)
+, armor(0)
+, shield(0)
+, helmet(0)
+, ring(0)
+, jewel(0)
+
+, battleSprite(0)
+, meleeAnimation(0)
+, attackAnimation(0)
+, spellAnimation(0)
+
+, mapSprite(0) {
+
+}
+
+
+void Hero::SubtractHealth(int amount) {
+ if (amount > Health()) {
+ health = 0;
+ } else {
+ health -= amount;
+ int ipGain(amount * 255 / health);
+ if (ip + ipGain > 255) {
+ ip = 255;
+ } else {
+ ip += ipGain;
+ }
+ }
+}
+
+
+void Hero::CreateTypeDescription() {
+ Hero h;
+
+ int animationId(TypeDescription::GetTypeId("Animation"));
+ int numberId(TypeDescription::GetTypeId("Number"));
+ int spriteId(TypeDescription::GetTypeId("Sprite"));
+ int statsId(TypeDescription::GetTypeId("Stats"));
+ int stringId(TypeDescription::GetTypeId("String"));
+
+ TypeDescription &td(TypeDescription::CreateOrGet("Hero"));
+ td.SetConstructor(&Construct);
+ td.SetSize(sizeof(Hero));
+
+ td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId, true));
+
+ td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId, false));
+ td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId, false));
+ td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId, false));
+ td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId, false));
+ td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId, false));
+
+ td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId, false));
+
+ td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false));
+
+ td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), spriteId, true));
+ td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId, true));
+ td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, true));
+ td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, true));
+
+ td.AddField("mapSprite", FieldDescription(((char *)&h.mapSprite) - ((char *)&h), spriteId, true));
+}
+
+void Hero::Construct(void *data) {
+ new (data) Hero;
+}
+
+}
--- /dev/null
+/*
+ * Hero.h
+ *
+ * Created on: Oct 7, 2012
+ * Author: holy
+ */
+
+#ifndef COMMON_HERO_H_
+#define COMMON_HERO_H_
+
+#include "fwd.h"
+#include "Stats.h"
+#include "../graphics/fwd.h"
+
+#include <vector>
+
+namespace common {
+
+class Hero {
+
+public:
+ Hero();
+ ~Hero() { }
+
+public:
+ const char *Name() const { return name; }
+
+ Uint16 MaxHealth() const { return maxHealth; }
+ Uint16 Health() const { return health; }
+ int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
+ void SubtractHealth(int amount);
+
+ Uint16 MaxMana() const { return maxMana; }
+ Uint16 Mana() const { return mana; }
+ int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
+ bool CanUseMagic() const { return MaxMana() > 0; }
+
+ Uint8 MaxIP() const { return 255; }
+ Uint8 IP() const { return ip; }
+ int RelativeIP(int max) const { return IP() * max / MaxIP(); }
+
+ Stats &GetStats() { return stats; }
+ const Stats &GetStats() const { return stats; }
+
+ Uint8 Level() const { return level; }
+
+ Item *Weapon() { return weapon; }
+ Item *Armor() { return armor; }
+ Item *Shield() { return shield; }
+ Item *Helmet() { return helmet; }
+ Item *Ring() { return ring; }
+ Item *Jewel() { return jewel; }
+
+ const Item *Weapon() const { return weapon; }
+ const Item *Armor() const { return armor; }
+ const Item *Shield() const { return shield; }
+ const Item *Helmet() const { return helmet; }
+ const Item *Ring() const { return ring; }
+ const Item *Jewel() const { return jewel; }
+
+ bool HasWeapon() const { return weapon; }
+ bool HasArmor() const { return armor; }
+ bool HasShield() const { return shield; }
+ bool HasHelmet() const { return helmet; }
+ bool HasRing() const { return ring; }
+ bool HasJewel() const { return jewel; }
+
+ const std::vector<const Spell *> &Spells() const { return spells; }
+
+ graphics::Sprite *BattleSprite() { return battleSprite; }
+ graphics::Animation *MeleeAnimation() { return meleeAnimation; }
+ graphics::Animation *AttackAnimation() { return attackAnimation; }
+ graphics::Animation *SpellAnimation() { return spellAnimation; }
+
+ graphics::Sprite *MapSprite() { return mapSprite; }
+
+ static void CreateTypeDescription();
+ static void Construct(void *);
+
+// temporary setters
+public:
+ void SetWeapon(common::Item *i) { weapon = i; }
+ void SetArmor(common::Item *i) { armor = i; }
+ void SetShield(common::Item *i) { shield = i; }
+ void SetHelmet(common::Item *i) { helmet = i; }
+ void SetRing(common::Item *i) { ring = i; }
+ void SetJewel(common::Item *i) { jewel = i; }
+
+ void AddSpell(Spell *s) { spells.push_back(s); }
+
+private:
+ const char *name;
+
+ int maxHealth, health;
+ int maxMana, mana;
+ int ip;
+
+ Stats stats;
+
+ int level;
+
+ Item *weapon;
+ Item *armor;
+ Item *shield;
+ Item *helmet;
+ Item *ring;
+ Item *jewel;
+
+ // TODO: vector does not seem to be a good choice
+ std::vector<const Spell *> spells;
+
+ graphics::Sprite *battleSprite;
+ graphics::Animation *meleeAnimation;
+ graphics::Animation *attackAnimation;
+ graphics::Animation *spellAnimation;
+
+ graphics::Sprite *mapSprite;
+
+};
+
+}
+
+#endif /* COMMON_HERO_H_ */
--- /dev/null
+/*
+ * Stats.cpp
+ *
+ * Created on: Aug 19, 2012
+ * Author: holy
+ */
+
+#include "Stats.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace common {
+
+Stats::Stats()
+: attack(0)
+, defense(0)
+, strength(0)
+, agility(0)
+, intelligence(0)
+, magicResistance(0)
+, gut(0) {
+
+}
+
+Stats::Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance)
+: attack(attack)
+, defense(defense)
+, strength(strength)
+, agility(agility)
+, intelligence(intelligence)
+, magicResistance(magicResistance)
+, gut(gut) {
+
+}
+
+
+void Stats::CreateTypeDescription() {
+ Stats s;
+
+ int numberId(TypeDescription::GetTypeId("Number"));
+
+ TypeDescription &td(TypeDescription::CreateOrGet("Stats"));
+ td.SetConstructor(&Construct);
+ td.SetSize(sizeof(Stats));
+
+ td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), numberId, false));
+ td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), numberId, false));
+ td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), numberId, false));
+ td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), numberId, false));
+ td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), numberId, false));
+ td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), numberId, false));
+ td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), numberId, false));
+}
+
+void Stats::Construct(void *data) {
+ new (data) Stats;
+}
+
+}
--- /dev/null
+/*
+ * Stats.h
+ *
+ * Created on: Aug 19, 2012
+ * Author: holy
+ */
+
+#ifndef COMMON_STATS_H_
+#define COMMON_STATS_H_
+
+#include <SDL.h>
+
+namespace common {
+
+class Stats {
+
+public:
+ Stats();
+ Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance);
+
+public:
+ Uint16 Attack() const { return attack; }
+ Uint16 Defense() const { return defense; }
+ Uint16 Strength() const { return strength; }
+ Uint16 Agility() const { return agility; }
+ Uint16 Intelligence() const { return intelligence; }
+ Uint8 Gut() const { return gut; }
+ Uint16 MagicResistance() const { return magicResistance; }
+
+ void SetAttack(Uint16 a) { attack = a; }
+ void SetDefense(Uint16 d) { defense = d; }
+ void SetStrength(Uint16 s) { strength = s; }
+ void SetAgility(Uint16 a) { agility = a; }
+ void SetIntelligence(Uint16 i) { intelligence = i; }
+ void SetGut(Uint8 g) { gut = g; }
+ void SetMagicResistance(Uint16 m) { magicResistance = m; }
+
+ static void CreateTypeDescription();
+ static void Construct(void *);
+
+private:
+ int attack;
+ int defense;
+ int strength;
+ int agility;
+ int intelligence;
+ int magicResistance;
+ int gut;
+
+};
+
+}
+
+#endif /* COMMON_STATS_H_ */
namespace common {
+struct GameState;
+class Hero;
class HeroGroup;
class Ikari;
class Inventory;
class Item;
class Spell;
+class Stats;
class TargetingMode;
}
#include "TypeDescription.h"
-using battle::Hero;
using battle::Monster;
using battle::PartyLayout;
+using common::Hero;
using common::Item;
using common::Spell;
using std::string;
public:
battle::Resources *GetBattleResources(const std::string &identifier);
- battle::Hero *GetHero(const std::string &identifier);
+ common::Hero *GetHero(const std::string &identifier);
common::Item *GetItem(const std::string &identifier);
battle::Monster *GetMonster(const std::string &identifier);
battle::PartyLayout *GetPartyLayout(const std::string &identifier);
#include "../common/Ikari.h"
#include "../common/Item.h"
#include "../common/Spell.h"
+#include "../common/Stats.h"
#include "../common/TargetingMode.h"
#include "../graphics/ComplexAnimation.h"
#include "../graphics/Font.h"
using battle::Hero;
using battle::Monster;
using battle::PartyLayout;
-using battle::Stats;
using common::Ikari;
using common::Item;
using common::Spell;
+using common::Stats;
using common::TargetingMode;
using graphics::Animation;
using graphics::Color;
#include "battle/Monster.h"
#include "battle/PartyLayout.h"
#include "battle/Resources.h"
-#include "battle/Stats.h"
+#include "common/Hero.h"
#include "common/Ikari.h"
#include "common/Inventory.h"
#include "common/Item.h"
#include "common/Spell.h"
+#include "common/Stats.h"
#include "geometry/Vector.h"
#include "graphics/ComplexAnimation.h"
#include "graphics/Font.h"
using app::Arguments;
using app::Input;
using battle::BattleState;
-using battle::Hero;
using battle::Monster;
using battle::PartyLayout;
-using battle::Stats;
+using common::Hero;
using common::Ikari;
using common::Inventory;
using common::Item;
using common::Spell;
+using common::Stats;
using geometry::Vector;
using graphics::ComplexAnimation;
using graphics::Font;
export Hero maxim {
name: "Maxim",
level: 1,
- sprite: maximSprite,
+ battleSprite: maximSprite,
maxHealth: 33,
health: 33,
maxMana: 20,
export Hero selan {
name: "Selan",
level: 1,
- sprite: selanSprite,
+ battleSprite: selanSprite,
maxHealth: 28,
health: 28,
maxMana: 23,
export Hero guy {
name: "Guy",
level: 1,
- sprite: guySprite,
+ battleSprite: guySprite,
maxHealth: 38,
health: 38,
maxMana: 0,
export Hero dekar {
name: "Dekar",
level: 1,
- sprite: dekarSprite,
+ battleSprite: dekarSprite,
maxHealth: 38,
health: 38,
maxMana: 0,