1
1
Fork 0
mirror of https://gitlab.com/Oreolek/cloak-salet.git synced 2024-06-29 05:15:07 +03:00
cloak-salet/game/story.coffee

129 lines
3.3 KiB
CoffeeScript
Raw Normal View History

2017-07-11 19:12:35 +03:00
cloak = unit "cloak",
examine: () -> "cloak".l()
display: () -> "cloak_disp".l()
inv: () -> "cloak".l()
dsc: ""
takeable: true
take: () ->
cloak = null
for thing in salet.here().units
if thing.name == "cloak"
cloak = thing
salet.here().drop('cloak')
salet.character.take(cloak)
return "take_cloak".l()
drop: () ->
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()
2017-07-22 08:42:14 +03:00
invl: () -> "cloak_invl".l()
2017-07-11 19:12:35 +03:00
wear: () ->
if (salet.here().has('cloak'))
2017-07-10 16:32:24 +03:00
cloak = null
2017-07-11 19:12:35 +03:00
for thing in salet.here().units
2017-07-10 16:32:24 +03:00
if thing.name == "cloak"
cloak = thing
2017-07-11 19:12:35 +03:00
salet.here().drop('cloak')
salet.character.take(cloak)
return "wear_cloak".l()
else # no cloak in the room, maybe in the inventory?
if salet.character.has('cloak')
2017-05-15 13:28:53 +03:00
return "wear_cloak".l()
2017-07-11 19:12:35 +03:00
else
return "no_cloak".l()
2017-05-15 13:28:53 +03:00
foyer_options =
2017-05-15 13:28:53 +03:00
before: () -> "start".l()
title: () -> "foyer_title".l()
2017-05-15 13:28:53 +03:00
dsc: () -> "foyer".l()
ways: ["entrance", "cloakroom", "bar"]
canExit: (to) -> # can't exit to north
2017-07-10 16:32:24 +03:00
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>")
, 0)
return false
2017-05-15 13:28:53 +03:00
croom "start", foyer_options
foyer_options.before = null # no title splash after game begins
croom "foyer", foyer_options
2017-05-15 13:28:53 +03:00
croom "cloakroom",
dsc: () -> "cloakroom".l()
title: () -> "cloakroom_title".l()
ways: ["foyer"]
2017-07-10 04:58:19 +03:00
units: []
hook = unit "hook",
dsc: "",
display: () -> "hook_disp".l()
2017-07-10 16:32:24 +03:00
examine: () ->
if salet.here().has('cloak')
2017-07-11 19:12:35 +03:00
list = ""
for thing in salet.here().units
if thing.name == "cloak"
2017-07-22 08:42:14 +03:00
list += thing.invl()
return "hook".l() + "hook_full".l({
2017-07-11 19:12:35 +03:00
"list": list
})
2017-07-10 16:32:24 +03:00
else
2017-07-22 08:42:14 +03:00
return "hook".l() + "hook_empty".l()
2017-07-10 04:58:19 +03:00
hook.put("cloakroom")
2017-05-15 13:28:53 +03:00
croom "entrance",
title: () -> "entrance_title".l()
2017-07-22 08:42:14 +03:00
ways: ["foyer"]
dsc: () -> "entrance".l()
2017-05-15 13:28:53 +03:00
croom "bar",
2017-07-11 19:12:35 +03:00
before: () ->
if salet.character.has('cloak')
this.dsc = "bar_dark".l()
this.units = [
unit "darkness",
display: () -> "darkness".l()
dsc: ""
examine: () ->
this.chaos++
"dark".l()
takeable: true
take: () ->
this.chaos++
"dark".l()
wear: () ->
"wear_darkness".l()
]
2017-07-22 08:42:14 +03:00
this.actions = {}
2017-07-11 19:12:35 +03:00
else
2017-07-22 08:42:14 +03:00
this.actions = {
message: () ->
salet.view.write salet.here().units[0].act()
}
2017-07-11 19:12:35 +03:00
this.dsc = "bar".l()
this.units = [
unit "message",
display: () -> "message_disp".l()
dsc: () -> "message".l()
act: () ->
$(".sidebar").hide()
$("#content").toggleClass("narrow")
$(".ways").hide()
if salet.here().chaos == 0
return "message_x".l()
else
return "message_ruined".l()
examine: () ->
2017-07-22 08:42:14 +03:00
salet.here().units[0].act()
2017-07-11 19:12:35 +03:00
]
return ""
2017-05-15 13:28:53 +03:00
title: () -> "bar_title".l()
ways: ["foyer"]
2017-07-11 19:12:35 +03:00
chaos: 0