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

#include "game.h"

bool gameInit(game_t *game) {
  // Init the game
  game->name = GAME_NAME;

  // Init the engine and the rendering pipeline
  engineInit(&game->engine, game);

  // Hand off to the poker logic.
  pokerInit(&game->poker, &game->engine.render);

  // char *text = "Ayy\nNice meme";
  // fonttextinfo_t info = fontGetTextInfo(&font, text);
  // fontmeasure_t *measure = fontTextMeasure(&font, text, &info);
  // fontTextInitFromMeasure(&font, &quad, text, &info, measure);
  // fontTextMeasureDispose(measure);

  return true;
}

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

  // Hand off to the poker logic
  pokerUpdate(&game->poker, &game->engine.render);

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

void gameDispose(game_t *game) {
  pokerDispose(&game->poker);
  engineDispose(&game->engine, game);
}