systemjs wip

This commit is contained in:
Alexander Yakovlev 2017-12-04 20:27:15 +07:00
parent 9cc73f6c33
commit a1e070ad99
4 changed files with 31 additions and 28 deletions

View File

@ -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'])

View File

@ -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) ->

View File

@ -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")

View File

@ -31,6 +31,7 @@
</div>
</div> <!-- End of div.page -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="game/system.js"></script>
<script src="game/loader.js"></script>
<link rel='prefetch' href="https://togetherjs.com/togetherjs-min.js" />