1-- Script that creates a game ready to be played.
2
3-- Usage:
4-- local game_manager = require("scripts/game_manager")
5-- local game = game_manager:create("savegame_file_name")
6-- game:start()
7
8local initial_game = require("scripts/initial_game")
9
10local game_manager = {}
11
12-- Name of the main save file
13local save_file = "save1.dat"
14
15
16-- Start a new game.
17-- The old game will be overwritten when it saves.
18function game_manager:new_game()
19  -- FIXME: Deleting the file is an immediate and irreversible action.
20  --        Instead it should be more graceful, starting a new game
21  --        and only overwriting the old file upon saving.
22  sol.game.delete(save_file)
23  local game = sol.game.load(save_file)
24  initial_game:initialize_new_savegame(game)
25  sol.main:start_savegame(game)
26end
27
28
29-- Continue the existing game.
30-- Check that it exists before calling this.
31function game_manager:continue_game()
32  local game = sol.game.load(save_file)
33  sol.main:start_savegame(game)
34end
35
36
37return game_manager
38