From d71217e2be1466726581146000a0f61620423e9b Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 4 Dec 2012 20:33:41 +0100 Subject: [PATCH] load capsule in battles created by MapState --- src/common/GameState.cpp | 1 + src/common/GameState.h | 4 ++++ src/main.cpp | 3 +++ src/map/MapState.cpp | 6 +++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common/GameState.cpp b/src/common/GameState.cpp index 2d9fd3e..b08724b 100644 --- a/src/common/GameState.cpp +++ b/src/common/GameState.cpp @@ -4,6 +4,7 @@ namespace common { GameState::GameState() : partySize(1) +, capsule(0) , money(0) , time(0) , messageSpeed(MESSAGE_SPEED_NORMAL) diff --git a/src/common/GameState.h b/src/common/GameState.h index bcaea52..4e2570d 100644 --- a/src/common/GameState.h +++ b/src/common/GameState.h @@ -1,6 +1,7 @@ #ifndef COMMON_GAMESTATE_H_ #define COMMON_GAMESTATE_H_ +#include "Capsule.h" #include "Hero.h" #include "Inventory.h" @@ -16,6 +17,9 @@ struct GameState { Hero *party[4]; int partySize; + Capsule capsules[7]; + Capsule *capsule; + Inventory inventory; Uint32 money; diff --git a/src/main.cpp b/src/main.cpp index 8c09991..2611a72 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -194,6 +194,9 @@ int main(int argc, char **argv) { gameState.party[3] = &gameState.heroes[3]; gameState.partySize = 4; + gameState.capsules[0] = *caster.GetCapsule("flash"); + gameState.capsule = gameState.capsules; + GameConfig gameConfig; gameConfig.state = &gameState; gameConfig.heroesLayout = caster.GetPartyLayout("heroesLayout"); diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index d678dab..35c0c5c 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -296,6 +296,9 @@ bool MapState::CheckMonster() { battleState->AddHero(*game->state->party[i]); } } + if (game->state->capsule) { + battleState->SetCapsule(game->state->capsule); + } for (battle::Monster **monster((*e)->MonstersBegin()); monster != (*e)->MonstersEnd(); ++monster) { battleState->AddMonster(**monster); } @@ -311,9 +314,6 @@ bool MapState::CheckMonster() { // TODO: move entity erase to happen after the transition or battle entities.erase(e); return true; - // needed information here: - // - battle background (from tile/area/map) - // - monsters + layout (from entity) } } } -- 2.39.2