mirror of
https://gitlab.com/Oreolek/cloak-salet.git
synced 2024-06-16 23:20:56 +03:00
Dropping and wearing
This commit is contained in:
parent
8f915342ac
commit
962b21c4ac
|
@ -51,8 +51,6 @@ gulp.task('concatCoffee', () ->
|
|||
|
||||
gulp.src([
|
||||
## additional functions
|
||||
'./game/dialogue.coffee',
|
||||
'./game/phrase.coffee',
|
||||
## the actual game
|
||||
'./game/begin.coffee',
|
||||
'./game/story.coffee',
|
||||
|
|
|
@ -6,14 +6,16 @@ salet.beforeAction = (room, actionId) ->
|
|||
if match? and match[1] and match[2]
|
||||
verb = match[1]
|
||||
unit = match[2]
|
||||
if room.units[unit]
|
||||
salet.view.write(room.units[unit][verb].fcall(salet.rooms[roomId]))
|
||||
if room.has(unit)
|
||||
salet.view.write(room.unitdo(unit, verb))
|
||||
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 )
|
||||
$.getJSON('game/translations/'+i18n.lang+'.json', (data) ->
|
||||
|
@ -60,6 +62,8 @@ updateverb = (unit, verb) ->
|
|||
if unit[verb]? or salet.character.displayAll
|
||||
if verb == "take" and unit.takeable == false
|
||||
return ""
|
||||
if verb == "drop" and not salet.character.has(unit.name)
|
||||
return ""
|
||||
if verb == "wear" and salet.character.has(unit.name)
|
||||
return ""
|
||||
$("##{verb}list").append("<li><a href='./verb_#{verb}_#{unit.name}'>#{unit.display()}</a></li>")
|
||||
|
@ -109,6 +113,15 @@ sysroom = (name, options) ->
|
|||
croom = (name, spec) ->
|
||||
spec.clear ?= true
|
||||
spec.optionColor ?= ""
|
||||
spec.has = (thing) ->
|
||||
for item in this.units
|
||||
if item.name == thing
|
||||
return true
|
||||
return false
|
||||
spec.unitdo = (thing, verb) ->
|
||||
for item in this.units
|
||||
if item.name == thing and item[verb] != undefined
|
||||
return item[verb].fcall(this)
|
||||
spec.optionText ?= () ->
|
||||
retval = """
|
||||
<div class="#{spec.optionColor}">
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
###
|
||||
A dialogue shortcut.
|
||||
Usage:
|
||||
|
||||
dialogue "Point out a thing in her purse (mildly)", "start", "mild", """
|
||||
Point out a thing in her purse (mildly)
|
||||
""", "character.mild = true"
|
||||
###
|
||||
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
|
||||
choices: "#"+endTag
|
||||
})
|
||||
if typeof(startTag) == "string"
|
||||
retval.tags = [startTag]
|
||||
else if typeof(startTag) == "object"
|
||||
retval.tags = startTag
|
||||
if effect?
|
||||
retval.before = (character, system) ->
|
||||
eval(effect)
|
||||
return retval
|
|
@ -1,26 +0,0 @@
|
|||
###
|
||||
A phrase shortcut.
|
||||
Usage:
|
||||
|
||||
phrase "Point out a thing in her purse (mildly)", "start", """
|
||||
Point out a thing in her purse (mildly)
|
||||
""", "character.sandbox.mild = true"
|
||||
|
||||
@param title phrase Phrase (question)
|
||||
@param salet Salet core
|
||||
@param string tag tag marking viewing condition
|
||||
@param string text Response
|
||||
@param string effect an optional parameter, eval'd code
|
||||
###
|
||||
phrase = (title, tag, text, effect) ->
|
||||
retval = room("phrase_"+salet.rooms.length, {
|
||||
optionText: title
|
||||
dsc: text
|
||||
clear: false # backlog is useful in dialogues
|
||||
choices: "#"+tag
|
||||
tags: [tag]
|
||||
})
|
||||
if effect?
|
||||
retval.before = (character, system) ->
|
||||
eval(effect)
|
||||
return retval
|
|
@ -11,15 +11,26 @@ salet.init = () ->
|
|||
cloak = unit "cloak",
|
||||
examine: () -> "cloak".l()
|
||||
display: () -> "cloak_disp".l()
|
||||
inv: () -> "cloak".l()
|
||||
dsc: ""
|
||||
drop: () ->
|
||||
if (salet.currentRoom != 'cloakroom')
|
||||
if (salet.current != 'cloakroom')
|
||||
return "drop_cloak".l()
|
||||
cloak = null
|
||||
for thing in salet.character.inventory
|
||||
if thing.name == "cloak"
|
||||
cloak = thing
|
||||
salet.character.drop('cloak')
|
||||
salet.here().take(cloak)
|
||||
return "hang_cloak".l()
|
||||
wear: () ->
|
||||
if (salet.here().has('cloak'))
|
||||
cloak = null
|
||||
for thing in salet.here().units
|
||||
if thing.name == "cloak"
|
||||
cloak = thing
|
||||
salet.here().drop('cloak')
|
||||
salet.character.take('cloak')
|
||||
salet.character.take(cloak)
|
||||
return "wear_cloak".l()
|
||||
else # no cloak in the room, maybe in the inventory?
|
||||
if salet.character.has('cloak')
|
||||
|
@ -34,7 +45,7 @@ foyer_options =
|
|||
dsc: () -> "foyer".l()
|
||||
ways: ["entrance", "cloakroom", "bar"]
|
||||
canExit: (to) -> # can't exit to north
|
||||
if (to == 'entrance')
|
||||
if (to == 'entrance' and salet.interactive)
|
||||
# print the effect after the room description, after the player enters the room
|
||||
setTimeout(() ->
|
||||
salet.view.write("<span class='effect'>"+"entrance".l()+"</span>")
|
||||
|
@ -54,7 +65,11 @@ croom "cloakroom",
|
|||
hook = unit "hook",
|
||||
dsc: "",
|
||||
display: () -> "hook_disp".l()
|
||||
examine: () -> "hook".l()
|
||||
examine: () ->
|
||||
if salet.here().has('cloak')
|
||||
return "hook".l() + " " + "hook_full".l()
|
||||
else
|
||||
return "hook".l() + " " + "hook_empty".l()
|
||||
hook.put("cloakroom")
|
||||
|
||||
croom "entrance",
|
||||
|
|
|
@ -36,7 +36,7 @@ entrance: """
|
|||
"""
|
||||
cloakroom: """
|
||||
The walls of this small room were clearly once lined with hooks,
|
||||
though now [only one](./hook) remains. The exit is a door to the [east.](cloakroom)
|
||||
though now [only one](./verb_examine_hook) remains. The exit is a door to the [east.](foyer)
|
||||
"""
|
||||
cloakroom_title: "Cloakroom"
|
||||
entrance_title: "Street entrance"
|
||||
|
@ -63,13 +63,15 @@ cloak: """
|
|||
A handsome cloak, of velvet trimmed with satin, and slightly spattered with raindrops.
|
||||
Its blackness is so deep that it almost seems to suck light from the room.
|
||||
"""
|
||||
cloak_disp: "cloak"
|
||||
cloak_disp: "Cloak"
|
||||
hook: "It's just a small brass hook,"
|
||||
hook_disp: "Small hook"
|
||||
hook_empty: "screwed to the wall."
|
||||
hook_full: "with {list} hanging on it."
|
||||
dark: "Blundering around in the dark isn't a good idea!"
|
||||
drop_cloak: "This isn't the best place to leave a smart cloak lying around."
|
||||
hang_cloak: "There's a hook here, so you hang the cloak on it."
|
||||
wear_cloak: "You take the cloak from the hook and wear it."
|
||||
night: "Night mode"
|
||||
multiplayer: "Multiplayer mode"
|
||||
showall: "Filter list of objects"
|
||||
|
|
Loading…
Reference in a new issue