2021-06-14 22:03:55 -04:00
|
|
|
import { Game } from './Game.js';
|
2021-06-16 15:26:42 -04:00
|
|
|
import { render } from './ui/UI.js';
|
2021-06-18 02:02:50 -04:00
|
|
|
import { ensureDirSync } from 'fs-extra';
|
2021-06-19 18:23:44 -04:00
|
|
|
import { lstatSync } from 'fs';
|
|
|
|
|
import { parse, resolve } from 'path';
|
|
|
|
|
import walkSync from 'walk-sync';
|
|
|
|
|
import { fileURLToPath } from 'url';
|
2021-06-14 22:03:55 -04:00
|
|
|
|
2021-06-18 02:02:50 -04:00
|
|
|
const saveFile = process.argv[2] || 'data/world01.json';
|
2021-06-15 20:05:07 -04:00
|
|
|
|
2021-06-18 02:02:50 -04:00
|
|
|
ensureDirSync(parse(saveFile).dir);
|
|
|
|
|
|
2021-06-19 18:23:44 -04:00
|
|
|
const extensionsPath = resolve(parse(fileURLToPath(import.meta.url)).dir, '../content');
|
|
|
|
|
|
|
|
|
|
const extensions = walkSync(extensionsPath)
|
|
|
|
|
.map(path => resolve(extensionsPath, path))
|
|
|
|
|
.filter(path => lstatSync(path).isFile())
|
|
|
|
|
.filter(path => parse(path).ext === '.js')
|
|
|
|
|
.map(path => import(path));
|
|
|
|
|
|
|
|
|
|
Promise.all(extensions).then((extensions) => {
|
|
|
|
|
|
|
|
|
|
// TODO move render logic into game, so that the ui doesnt exist until the game does...
|
|
|
|
|
// maybe, i mean, an argument could be made for not that, because the game
|
|
|
|
|
// isnt necessarily the entire thing, its just one instance of a save file.
|
|
|
|
|
// But probably the initial menu screens will be their own thing entirely.
|
|
|
|
|
const game = Game.create(saveFile);
|
|
|
|
|
render(game);
|
|
|
|
|
|
|
|
|
|
});
|