/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#include "game.h"

#include "../physics/vector.h"

bool gameInit(game_t *game) {
  // Init the engine and the rendering pipeline
  engineInit(&game->engine, game);

  // Send off to the game instance
  #if SETTING_GAME == SETTING_GAME_POKER
    return pokerGameInit(game);
  #elif SETTING_GAME == SETTING_GAME_DAWN
    return dawnGameInit(game);
  #endif
}

bool gameUpdate(game_t *game, float platformDelta) {
  // Let the engine do its thing.
  engineUpdateStart(&game->engine, game, platformDelta);

  // Hand off to the game's logic
  #if SETTING_GAME == SETTING_GAME_POKER
    pokerGameUpdate(game);
  #elif SETTING_GAME == SETTING_GAME_DAWN
    dawnGameUpdate(game);
  #endif

  // Hand back to the engine.
  return engineUpdateEnd(&game->engine, game);
}

void gameDispose(game_t *game) {
  // Cleanup the game
  #if SETTING_GAME == SETTING_GAME_POKER
    pokerGameDispose(game);
  #elif SETTING_GAME == SETTING_GAME_DAWN
    dawnGameDispose(game);
  #endif

  engineDispose(&game->engine, game);
}