/*Copyright (C) 2010 Deveaux Duncan

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "GameEngine.hpp"

GameEngine::GameEngine(sf::RenderWindow *renderWindow) : m_renderWindow(renderWindow), m_exited(false)
{
    m_mainMenu = new MainMenu(this);
    m_charactersMenu = new CharactersMenu(this);
    m_fight = new Fight(this);
}

GameEngine::~GameEngine()
{
    delete m_mainMenu;
    delete m_charactersMenu;
    delete m_fight;
}

void GameEngine::initMainMenu()
{
    setNextScreen(m_mainMenu);
}

void GameEngine::confCMPlayersNo(int playersNo)
{
    m_charactersMenu->setPlayersNo(playersNo);
}

void GameEngine::initCharactersMenu()
{
    setNextScreen(m_charactersMenu);
}

void GameEngine::confFightPlayers(const std::vector<std::string> &playersName)
{
    m_fight->clearPlayers();
    
    for (int i=0; i < playersName.size(); i++)
    {
        m_fight->addPlayer(playersName[i]);
    }
}

void GameEngine::initFight()
{
    setNextScreen(m_fight);
}

void GameEngine::setNextScreen(Screen *nextScreen)
{
    m_nextScreen = nextScreen;
}

void GameEngine::launchNextScreen()
{
    m_nextScreen->run();
}

void GameEngine::exit()
{
    m_exited = true;
}

bool GameEngine::wasExited() const
{
    return m_exited;
}

//Get and set methods
sf::RenderWindow *GameEngine::getRenderWindow() const
{
    return m_renderWindow;
}