Salet 1.4 upgrade
This commit is contained in:
parent
5618f05a8f
commit
a6b9ba0be4
|
@ -1,7 +1,7 @@
|
|||
dialogue = require('../../lib/dialogue.coffee')
|
||||
phrase = require('../../lib/phrase.coffee')
|
||||
oneOf = require('../../lib/oneOf.coffee')
|
||||
salet = require('salet')
|
||||
require('salet')
|
||||
|
||||
salet.game_id = "your-game-id-here"
|
||||
salet.game_version = "1.3"
|
||||
|
@ -27,8 +27,8 @@ actlink = (content, ref) ->
|
|||
|
||||
# The first room of the game.
|
||||
# For accessibility reasons the text is provided in HTML, not here.
|
||||
room "start", salet,
|
||||
enter: (salet) ->
|
||||
room "start",
|
||||
enter: () ->
|
||||
salet.character.bought_lamp = false
|
||||
dsc: """
|
||||
""",
|
||||
|
@ -37,13 +37,13 @@ room "start", salet,
|
|||
# This is a special inventory room.
|
||||
# The inventory button is a regular link to this room.
|
||||
# You may alter these as much as you like or scrap it along with the button.
|
||||
room "inventory", salet,
|
||||
room "inventory",
|
||||
canSave: false # saving the game here is forbidden. Aautosaving too.
|
||||
enter: () ->
|
||||
$("#inventory").hide()
|
||||
exit: () ->
|
||||
$("#inventory").show()
|
||||
dsc: (salet) ->
|
||||
dsc: () ->
|
||||
if salet.character.inventory.length == 0
|
||||
text = "You are carrying nothing."
|
||||
else
|
||||
|
@ -54,5 +54,5 @@ room "inventory", salet,
|
|||
<div class="center"><a href="./exit"><button class="btn btn-lg btn-outline-primary">Go back</button></a></div>
|
||||
"""
|
||||
actions:
|
||||
exit: (salet) ->
|
||||
exit: () ->
|
||||
return salet.goBack()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
room "world", salet,
|
||||
room "world",
|
||||
tags: ["start"],
|
||||
optionText: "Enter the world",
|
||||
ways: ["plaza"]
|
||||
|
@ -14,7 +14,7 @@ room "world", salet,
|
|||
act: "There is only one passage out. See the „Other rooms“ block popped up? Click it."
|
||||
]
|
||||
|
||||
room "plaza", salet,
|
||||
room "plaza",
|
||||
title: (from) ->
|
||||
if from == "world"
|
||||
return "Upwards"
|
||||
|
@ -22,10 +22,10 @@ room "plaza", salet,
|
|||
return "Town plaza"
|
||||
cycle: ["quirky", "distinct", "kooky", "crazy", "quaint"]
|
||||
ways: ["shop"]
|
||||
before: (system, from) ->
|
||||
before: (from) ->
|
||||
if from == 'world'
|
||||
"""
|
||||
You climb up the well and come out to a central plaza of a #{system.view.cycleLink("quaint")} little town.
|
||||
You climb up the well and come out to a central plaza of a #{salet.view.cycleLink("quaint")} little town.
|
||||
A plaque nearby says it's the town of *Innsmouth,* wherever that is.
|
||||
"""
|
||||
else
|
||||
|
@ -33,7 +33,7 @@ room "plaza", salet,
|
|||
units: [
|
||||
unit "policeman",
|
||||
dsc: "There is a policeman nearby. You could ask him {{for directions.}}"
|
||||
act: (salet) ->
|
||||
act: () ->
|
||||
if salet.character.has_mark?
|
||||
return "You already talked to him, no need to bug the man twice."
|
||||
salet.character.has_mark ?= true
|
||||
|
@ -46,7 +46,7 @@ room "plaza", salet,
|
|||
act: 'Just some weirdos shouting "Viva la Cthulhu!". Typical.'
|
||||
]
|
||||
|
||||
room "shop", salet,
|
||||
room "shop",
|
||||
title: "The Shop"
|
||||
#pic: "http://loremflickr.com/640/300/room,shop"
|
||||
ways: ["plaza", "shop-inside", "lair"]
|
||||
|
@ -57,7 +57,7 @@ room "shop", salet,
|
|||
You are standing in front of a picturesque sign. It's cold here.
|
||||
"""
|
||||
|
||||
room "lair", salet,
|
||||
room "lair",
|
||||
title: "The Lair"
|
||||
before: "Finding The Lair is easy. Leaving it is impossible. Your game ends here."
|
||||
dsc: """
|
||||
|
@ -68,26 +68,26 @@ room "lair", salet,
|
|||
unit "bugg",
|
||||
dsc: "You see a particularly beautiful slimy {{bugg.}}"
|
||||
takeable: false
|
||||
act: (salet) =>
|
||||
act: () =>
|
||||
salet.rooms[salet.current].drop("bugg")
|
||||
return "You eat the bugg mass. Delicious and raw. Perhaps it's a good lair to live in."
|
||||
]
|
||||
|
||||
phrase "Yes", salet, "merchant", """
|
||||
phrase "Yes", "merchant", """
|
||||
Yes.
|
||||
"""
|
||||
dialogue "No", salet, "merchant", "merchant", """
|
||||
dialogue "No", "merchant", "merchant", """
|
||||
No.
|
||||
"""
|
||||
room "sell-lamp", salet,
|
||||
room "sell-lamp",
|
||||
ways: ["shop"]
|
||||
tags: ["merchant"]
|
||||
choices: ["#merchant"]
|
||||
optionText: "May I buy this lamp?"
|
||||
title: "Talking with merchant"
|
||||
canView: (salet) ->
|
||||
canView: () ->
|
||||
return salet.character.has("lamp") and salet.character.bought_lamp == false
|
||||
enter: (salet) ->
|
||||
enter: () ->
|
||||
salet.character.bought_lamp = true
|
||||
dsc: """
|
||||
"That'll be 30 pieces of your time."
|
||||
|
@ -95,7 +95,7 @@ room "sell-lamp", salet,
|
|||
You quickly pay the price and take the lamp as a rightful owner.
|
||||
"""
|
||||
|
||||
room "shop-inside", salet,
|
||||
room "shop-inside",
|
||||
ways: ["shop"]
|
||||
tags: ["merchant"]
|
||||
optionText: "End the conversation"
|
||||
|
@ -107,17 +107,17 @@ room "shop-inside", salet,
|
|||
unit "merchant",
|
||||
dsc: "A {{merchant}} eyes you warily."
|
||||
takeable: false
|
||||
act: (salet) =>
|
||||
act: () =>
|
||||
salet.processClick("merchdialogue")
|
||||
return ""
|
||||
]
|
||||
|
||||
lamp = unit "lamp",
|
||||
takeable: true
|
||||
lamp.put(salet, "shop-inside")
|
||||
lamp.put("shop-inside")
|
||||
|
||||
# The dialogue entry point has to be a room, in order to have an ID to go to.
|
||||
room "merchdialogue", salet,
|
||||
room "merchdialogue",
|
||||
choices: "#merchant",
|
||||
dsc: """
|
||||
Nice day, isn't it?
|
||||
|
|
|
@ -6,8 +6,8 @@ Usage:
|
|||
Point out a thing in her purse (mildly)
|
||||
""", "character.mild = true"
|
||||
###
|
||||
dialogue = (title, salet, startTag, endTag, text, effect) ->
|
||||
retval = room("dialogue_"+Object.keys(salet.rooms).length, salet, {
|
||||
dialogue = (title, startTag, endTag, text, effect) ->
|
||||
retval = room("dialogue_"+Object.keys(salet.rooms).length, {
|
||||
optionText: title
|
||||
dsc: text
|
||||
clear: false # backlog is useful in dialogues
|
||||
|
|
|
@ -36,14 +36,13 @@ all copies or substantial portions of the Software.
|
|||
Returns the shuffled array.
|
||||
###
|
||||
|
||||
Array.prototype.shuffle = (system) ->
|
||||
rng = if system then system.rnd.random else Math.random
|
||||
Array.prototype.shuffle = () ->
|
||||
# slice() clones the array. Object members are copied by reference, beware.
|
||||
newArr = this.slice()
|
||||
m = newArr.length
|
||||
|
||||
while (m)
|
||||
i = Math.floor(rng() * m--)
|
||||
i = Math.floor(salet.rnd.randf() * m--)
|
||||
t = newArr[m]
|
||||
newArr[m] = newArr[i]
|
||||
newArr[i] = t
|
||||
|
@ -123,7 +122,6 @@ oneOf = (ary...) ->
|
|||
)
|
||||
|
||||
randomly: (system) ->
|
||||
rng = if system then system.rnd.random else Math.random
|
||||
last = null
|
||||
|
||||
if (ary.length<2)
|
||||
|
@ -132,7 +130,7 @@ oneOf = (ary...) ->
|
|||
i = null
|
||||
offset = null
|
||||
if not last?
|
||||
i = Math.floor(rng() * ary.length)
|
||||
i = Math.floor(salet.rnd.randf() * ary.length)
|
||||
else
|
||||
###
|
||||
Let offset be a random number between 1 and the length of the
|
||||
|
@ -141,17 +139,16 @@ oneOf = (ary...) ->
|
|||
other than the one we just chose.
|
||||
###
|
||||
|
||||
offset = Math.floor(rng() * (ary.length -1) + 1);
|
||||
i = (last + offset) % ary.length;
|
||||
offset = Math.floor(salet.rnd.randf() * (ary.length -1) + 1)
|
||||
i = (last + offset) % ary.length
|
||||
|
||||
last = i
|
||||
return ary[i]
|
||||
)
|
||||
|
||||
trulyAtRandom: (system) ->
|
||||
rng = if system then system.rnd.random else Math.random
|
||||
return stringish(() ->
|
||||
return ary[Math.floor(rng() * ary.length)];
|
||||
return ary[Math.floor(salet.rnd.randf() * ary.length)];
|
||||
)
|
||||
|
||||
inRandomOrder: (system) ->
|
||||
|
|
|
@ -12,8 +12,8 @@ Usage:
|
|||
@param string text Response
|
||||
@param string effect an optional parameter, eval'd code
|
||||
###
|
||||
phrase = (title, salet, tag, text, effect) ->
|
||||
retval = room("phrase_"+salet.rooms.length, salet, {
|
||||
phrase = (title, tag, text, effect) ->
|
||||
retval = room("phrase_"+salet.rooms.length, {
|
||||
optionText: title
|
||||
dsc: text
|
||||
clear: false # backlog is useful in dialogues
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"salet": "^1.3.3"
|
||||
"salet": "^1.4.1"
|
||||
},
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue