mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 00:47:28 +00:00
Dirty initial commit
This commit is contained in:
commit
eab87d32a9
13 changed files with 7039 additions and 0 deletions
82
tests/player.stdio.js
Normal file
82
tests/player.stdio.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
|
||||
Emglken runner
|
||||
==============
|
||||
|
||||
Copyright (c) 2020 Dannii Willis
|
||||
MIT licenced
|
||||
https://github.com/curiousdannii/emglken
|
||||
|
||||
*/
|
||||
|
||||
const fs = require('fs')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const CheapGlkOte = require('../src/')
|
||||
const { handlers } = require('../src/stdio')
|
||||
|
||||
const formats = [
|
||||
{
|
||||
id: 'bocfel',
|
||||
extensions: /z([3458]|blorb)$/,
|
||||
engine: 'bocfel.js',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'glulxe',
|
||||
extensions: /(gblorb|ulx)$/,
|
||||
engine: 'glulxe.js',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'git',
|
||||
extensions: /(gblorb|ulx)$/,
|
||||
engine: 'git.js',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'hugo',
|
||||
extensions: /hex$/,
|
||||
engine: 'hugo.js',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'tads',
|
||||
extensions: /(gam|t3)$/,
|
||||
engine: 'tads.js',
|
||||
},
|
||||
]
|
||||
|
||||
function run() {
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
|
||||
const storyfile = argv._[0]
|
||||
|
||||
let format
|
||||
for (const formatspec of formats) {
|
||||
if (
|
||||
formatspec.id === argv.vm ||
|
||||
(!argv.vm && formatspec.extensions.test(storyfile))
|
||||
) {
|
||||
format = formatspec
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
console.error('Unknown storyfile format')
|
||||
return
|
||||
}
|
||||
|
||||
const { glkInterface, sendFn } = CheapGlkOte(handlers)
|
||||
handlers.setSend(sendFn)
|
||||
|
||||
const engine = require('emglken/src/' + format.engine)
|
||||
const vm = new engine()
|
||||
vm.prepare(fs.readFileSync(storyfile), glkInterface)
|
||||
vm.start()
|
||||
}
|
||||
|
||||
run()
|
||||
Loading…
Add table
Add a link
Reference in a new issue