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

#include "pokergame.h"

bool pokerGameInit(game_t *game) {
  pokergame_t *pokerGame = &game->pokerGame;

  // Init the game
  game->name = POKER_GAME_NAME;

  // Load the Assets
  pokerGameAssetsInit(&pokerGame->assets);

  // Initialize the UI.
  pokerUiInit(pokerGame);
  
  // Prep the VN Conversation Engine.
  vnSceneInit(&pokerGame->scene, &pokerGame->assets.font, &pokerGame->assets.testTexture);
  pokerGameActionStartAdd(pokerGame);
  queueNext(&pokerGame->scene.conversation.actionQueue);

  return true;
} 

void pokerGameUpdate(game_t *game) {
  pokergame_t *pokerGame;
  pokerGame = &game->pokerGame;

  // Update the scene
  vnSceneUpdate(&pokerGame->scene, &game->engine);

  // Bind the shader.
  shaderUse(&pokerGame->assets.shader);


  // Render the visual novel scene
  // vnSceneRenderWorld(&pokerGame->scene, &game->engine, &pokerGame->assets.shader);
  vnSceneRenderGui(&pokerGame->scene, &game->engine, &pokerGame->assets.shader);
  pokerUiRender(pokerGame);
}

void pokerGameDispose(game_t *game) {
  pokerUiDispose(&game->pokerGame);
  vnSceneDispose(&game->pokerGame.scene);
  pokerGameAssetsDispose(&game->pokerGame.assets);
}