/*!
-* @file GameEngine.cpp
-* @brief \83Q\81[\83\80\83G\83\93\83W\83\93\82Ì\8eÀ\91\95
-* @date 2013/12/17
-* @author Deskull
-* 2014 Sikabane Works.
-*/
+ * @file GameEngine.cpp
+ * @brief \83Q\81[\83\80\83G\83\93\83W\83\93\82Ì\8eÀ\91\95
+ * @date 2013/12/17
+ * @author Deskull
+ * 2014 Sikabane Works.
+ */
#pragma once
#include "stdafx.h"
#include "GameEngine.h"
+#include "HaveGameTime.h"
+#include "Creature.h"
+#include "GameCampaign.h"
+#include "GameLogger.h"
namespace Deeangband
{
{
gameWorld = new GameWorld();
gameSurface = new GameSurfaceSDL(gameWorld);
- gameSurface->SetFloor(gameWorld->GetFloor(0));
- gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0));
+ gameLogger = new GameLogger();
+
+ GameElement::GameWorldPtr = gameWorld;
+ GameElement::GameSurfacePtr = gameSurface;
+ GameElement::GameLoggerPtr = gameLogger;
+
+ Dice::Initialize();
+ gameWorld->Initialize();
+
+ this->gameSurface->SetField(gameWorld->GetField(0));
+ this->gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0));
+ this->gameLogger->PutLog("GameEngine\8aJ\8en");
+ Direction::Initialize();
+ }
+
+ GameEngine::~GameEngine()
+ {
+ delete(gameLogger);
+ delete(gameSurface);
+ delete(gameWorld);
}
PLAY_EXIT_CODE GameEngine::PlayLoop(void)
{
GAME_COMMAND commandID;
PLAY_EXIT_CODE code = PLAY_EXIT_NONE;
- gameSurface->Redraw();
+ ACTION_IT actionIt;
+ HaveGameTime *currentHaveGameTimeObject;
+ gameSurface->Draw(gameWorld->GetPlayerCreature());
while(code == PLAY_EXIT_NONE)
{
- commandID = gameSurface->GetCommand();
+ currentHaveGameTimeObject = this->gameWorld->GetNextActionObject();
+ currentHaveGameTimeObject->TurnProcess();
+ this->gameSurface->UpdateTimeStatus(this->gameWorld->GetGameTime());
+ //actionIt = this->toNextProcess();
+ commandID = gameSurface->GetCommand(gameWorld->GetPlayerCreature());
code = DoGameCommand(commandID);
+ this->gameSurface->FocusField(gameWorld->GetPlayerCreature()->second->GetPosition());
+
+ this->gameSurface->UpdateSideCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
+ ProcessDeadCreatures();
+ if(!gameWorld->GetPlayerCreature()->second->IsAlive())
+ {
+ code = PLAY_EXIT_DEAD;
+ gameSurface->SystemMessage("\82 \82È\82½\82Í\8e\80\82É\82Ü\82µ\82½\81B");
+ }
}
return PLAY_EXIT_QUIT;
PLAY_EXIT_CODE GameEngine::DoGameCommand(GAME_COMMAND command)
{
+ CREATURE_IT playerIt = gameWorld->GetPlayerCreature();
+
switch(command)
{
case GAME_COMMAND_VIEW_PLAYER_STATUS:
- gameSurface->ViewCreatureStatus(gameWorld->GetCreature(0));
+ gameSurface->ViewCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
break;
case GAME_COMMAND_REDRAW:
- gameSurface->Redraw();
+ gameSurface->Draw(playerIt);
break;
case GAME_COMMAND_DEBUG_XML_SAVE:
gameWorld->XMLSave();
- gameSurface->Message("XML\82É\95Û\91¶\82µ\82Ü\82µ\82½\81B");
+ gameSurface->SystemMessage("XML\82É\95Û\91¶\82µ\82Ü\82µ\82½\81B");
break;
case GAME_COMMAND_DEBUG_XML_LOAD:
- gameSurface->Redraw();
+ gameSurface->Draw(playerIt);
gameWorld->XMLLoad();
- gameSurface->Message("XML\82©\82ç\8cÄ\82Ñ\8fo\82µ\82Ü\82µ\82½\81B");
+ gameSurface->SystemMessage("XML\82©\82ç\8cÄ\82Ñ\8fo\82µ\82Ü\82µ\82½\81B");
break;
case GAME_COMMAND_EXIT:
return PLAY_EXIT_QUIT;
break;
case GAME_COMMAND_NORTH:
+ playerIt->second.get()->Walk(DIRECTION_NORTH);
break;
case GAME_COMMAND_NORTH_EAST:
+ playerIt->second.get()->Walk(DIRECTION_NORTH_EAST);
break;
case GAME_COMMAND_EAST:
+ playerIt->second.get()->Walk(DIRECTION_EAST);
break;
case GAME_COMMAND_SOUTH_EAST:
+ playerIt->second.get()->Walk(DIRECTION_SOUTH_EAST);
break;
case GAME_COMMAND_SOUTH:
+ playerIt->second.get()->Walk(DIRECTION_SOUTH);
break;
case GAME_COMMAND_SOUTH_WEST:
+ playerIt->second.get()->Walk(DIRECTION_SOUTH_WEST);
break;
case GAME_COMMAND_WEST:
+ playerIt->second.get()->Walk(DIRECTION_WEST);
break;
case GAME_COMMAND_NORTH_WEST:
+ playerIt->second.get()->Walk(DIRECTION_NORTH_WEST);
break;
}
return PLAY_EXIT_NONE;
}
+
+ bool GameEngine::CombatCreatures(Creature *attackerPtr, Creature *targetPtr)
+ {
+ attackerPtr->Melee(targetPtr);
+ return true;
+ }
+
+ int GameEngine::ProcessDeadCreatures()
+ {
+ int deadNum = 0;
+ CREATURE_IT creatureIt, creatureItCurrent;
+ CREATURE_LIST *creatureList = gameWorld->GetCreatureList();
+
+ creatureIt = creatureList->begin();
+
+ while(creatureIt != creatureList->end())
+ {
+ creatureItCurrent = creatureIt;
+ creatureIt++;
+ if(!creatureItCurrent->second->IsAlive())
+ {
+ //!< @note \83v\83\8c\83C\83\84\81[\82Ì\8e\80\96S\82È\82ç\82Î\95Ê\93r\8f\88\97\9d\82·\82é\82Ì\82Å\83X\83L\83b\83v\81A\82³\82à\82È\82\82Î\83N\83\8a\81[\83`\83\83\81[\82Ì\8fÁ\96Å\81B
+ if(gameWorld->GetPlayerCreature() != creatureItCurrent)
+ {
+ gameSurface->GameMessage(creatureItCurrent->second->GetName() + "\82Í\8e\80\82ñ\82¾\81B");
+ creatureList->erase(creatureItCurrent);
+ }
+ deadNum++;
+ }
+ }
+
+ return deadNum;
+ }
}