From a1e070ad99a34fd9d4f1adb2474c7651be034f4e Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Mon, 4 Dec 2017 20:27:15 +0700 Subject: [PATCH] systemjs wip --- Gulpfile.coffee | 3 ++- game/begin.coffee | 52 ++++++++++++++++++++++------------------------ game/loader.coffee | 3 +++ html/index.html | 1 + 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Gulpfile.coffee b/Gulpfile.coffee index d3adeb8..d2a3b5c 100644 --- a/Gulpfile.coffee +++ b/Gulpfile.coffee @@ -25,7 +25,8 @@ html = (target, debug) -> sources.push('html/test.html') gulp.src(sources) .pipe(gulp.dest(target)) - gulp.src(['node_modules/salet/lib/index.min.js']) + #gulp.src(['node_modules/salet/lib/index.min.js']) + gulp.src(['/www/games/salet-module/lib/index.js']) .pipe(rename('salet.min.js')) .pipe(gulp.dest(target+"/game")) gulp.src(['node_modules/systemjs/dist/system-production.js']) diff --git a/game/begin.coffee b/game/begin.coffee index ea5e8ae..c659173 100644 --- a/game/begin.coffee +++ b/game/begin.coffee @@ -1,32 +1,30 @@ +salet = SystemJS.import("./game/salet.min.js") + +salet.game_id = "8b0c371c-57f4-49b3-ae3c-cba07d1a9733" +salet.game_version = "1.0" +salet.verbRe = /^verb\_(\w+)\_(\w+)$/ +salet.start = "menu" +salet.beforeAction = (room, actionId) -> + match = salet.verbRe.exec(actionId) + if match? and match[1] and match[2] + verb = match[1] + unit = match[2] + if room.has(unit) + salet.view.write(room.unitdo(unit, verb)) + else if salet.character.has(unit) + for i in salet.character.inventory + if i.name == unit + salet.view.write(i[verb].fcall(salet.rooms[room.name])) + return true # consume the action + return false +salet.afterAction = () -> + salet.character.update_sidebar() + $.holdReady( true ) -SystemJS.register("./game/salet.min.js") -SystemJS.import("./game/salet.min.js").then(() -> - salet.game_id = "8b0c371c-57f4-49b3-ae3c-cba07d1a9733" - salet.game_version = "1.0" - salet.verbRe = /^verb\_(\w+)\_(\w+)$/ - salet.start = "menu" - salet.beforeAction = (room, actionId) -> - match = salet.verbRe.exec(actionId) - if match? and match[1] and match[2] - verb = match[1] - unit = match[2] - if room.has(unit) - salet.view.write(room.unitdo(unit, verb)) - else if salet.character.has(unit) - for i in salet.character.inventory - if i.name == unit - salet.view.write(i[verb].fcall(salet.rooms[room.name])) - return true # consume the action - return false - salet.afterAction = () -> - salet.character.update_sidebar() +$.getJSON('game/translations/'+i18n.lang+'.json', (data) -> + i18n.push(i18n.lang, data) - $.holdReady( true ) - $.getJSON('game/translations/'+i18n.lang+'.json', (data) -> - i18n.push(i18n.lang, data) - - $.holdReady( false ) - ) + $.holdReady( false ) ) switchTab = (tabid) -> diff --git a/game/loader.coffee b/game/loader.coffee index c06c32d..7138cb7 100644 --- a/game/loader.coffee +++ b/game/loader.coffee @@ -1 +1,4 @@ +SystemJS.register("./game/salet.min.js") +#`import {salet} from './game/salet.min.js'` +SystemJS.register("./game/main.js") SystemJS.import("./game/main.js") diff --git a/html/index.html b/html/index.html index 52e0de2..65036d5 100644 --- a/html/index.html +++ b/html/index.html @@ -31,6 +31,7 @@ +