mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-07-07 01:04:25 +03:00
Localization supports functions, init fixes
This commit is contained in:
parent
84d6538e61
commit
ba9b59b53a
|
@ -49,8 +49,9 @@ String.prototype.l = (args) ->
|
||||||
|
|
||||||
# Find the localized form.
|
# Find the localized form.
|
||||||
localized = localize(lang, this)
|
localized = localize(lang, this)
|
||||||
|
if typeof(localized) == "function"
|
||||||
# Merge in any replacement content.
|
localized = localized(args)
|
||||||
|
else # Merge in any replacement content.
|
||||||
if args
|
if args
|
||||||
for name in args
|
for name in args
|
||||||
localized = localized.replace(
|
localized = localized.replace(
|
||||||
|
|
|
@ -166,5 +166,7 @@ oneOf = (ary...) ->
|
||||||
|
|
||||||
Array.prototype.oneOf = () ->
|
Array.prototype.oneOf = () ->
|
||||||
oneOf.apply(null, this)
|
oneOf.apply(null, this)
|
||||||
|
String.prototype.oneOf = () ->
|
||||||
|
return this
|
||||||
|
|
||||||
module.exports = oneOf;
|
module.exports = oneOf;
|
||||||
|
|
|
@ -2,7 +2,7 @@ markdown = require('./markdown.coffee')
|
||||||
SaletView = require('./view.coffee')
|
SaletView = require('./view.coffee')
|
||||||
Random = require('./random.js')
|
Random = require('./random.js')
|
||||||
character = require('./character.coffee')
|
character = require('./character.coffee')
|
||||||
languages = require('./localize.coffee')
|
require('./localize.coffee')
|
||||||
|
|
||||||
###
|
###
|
||||||
fcall() (by analogy with fmap) is added to the prototypes of both String and
|
fcall() (by analogy with fmap) is added to the prototypes of both String and
|
||||||
|
@ -296,6 +296,7 @@ class Salet
|
||||||
oldRoomId = @current
|
oldRoomId = @current
|
||||||
oldRoom = @getCurrentRoom()
|
oldRoom = @getCurrentRoom()
|
||||||
newRoom = @rooms[newRoomId]
|
newRoom = @rooms[newRoomId]
|
||||||
|
console.log @rooms, newRoomId
|
||||||
|
|
||||||
assert(newRoom, "unknown_situation".l({id:newRoomId}))
|
assert(newRoom, "unknown_situation".l({id:newRoomId}))
|
||||||
|
|
||||||
|
@ -361,7 +362,9 @@ class Salet
|
||||||
# Loads the game from the given data
|
# Loads the game from the given data
|
||||||
@loadGame = (saveFile) =>
|
@loadGame = (saveFile) =>
|
||||||
@progress = saveFile.progress
|
@progress = saveFile.progress
|
||||||
@character = saveFile.character
|
@character = new Character
|
||||||
|
for index, value of saveFile.character
|
||||||
|
@character[index] = value
|
||||||
|
|
||||||
@rnd = new Random(@progress.seed)
|
@rnd = new Random(@progress.seed)
|
||||||
|
|
||||||
|
@ -370,8 +373,7 @@ class Salet
|
||||||
if saveFile.progress? and saveFile.progress.sequence.length > 1
|
if saveFile.progress? and saveFile.progress.sequence.length > 1
|
||||||
@view.clearContent()
|
@view.clearContent()
|
||||||
|
|
||||||
# Now play through the actions so far:
|
# Start the game
|
||||||
if (@init)
|
|
||||||
@init()
|
@init()
|
||||||
|
|
||||||
# Run through all the player's history.
|
# Run through all the player's history.
|
||||||
|
@ -413,8 +415,7 @@ class Salet
|
||||||
|
|
||||||
# Start the game
|
# Start the game
|
||||||
@startTime = new Date().getTime() * 0.001
|
@startTime = new Date().getTime() * 0.001
|
||||||
if (@init)
|
@init()
|
||||||
@init(character)
|
|
||||||
|
|
||||||
# Do the first state.
|
# Do the first state.
|
||||||
@doTransitionTo(@start)
|
@doTransitionTo(@start)
|
||||||
|
@ -432,6 +433,7 @@ class Salet
|
||||||
|
|
||||||
for index, value of spec
|
for index, value of spec
|
||||||
this[index] = value
|
this[index] = value
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
|
||||||
salet = (spec) ->
|
salet = (spec) ->
|
||||||
|
|
Loading…
Reference in a new issue