mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-06-01 07:48:20 +03:00
33 lines
1.1 KiB
CoffeeScript
33 lines
1.1 KiB
CoffeeScript
markdown = require('./markdown.coffee')
|
|
undum = require('./undum.js')
|
|
objlink = (content, ref) ->
|
|
return "<a href='./_act_#{ref}'>#{content}</a>"
|
|
|
|
class RaconteurObj
|
|
constructor: (spec) ->
|
|
for key, value of spec
|
|
this[key] ?= value
|
|
level: 0
|
|
look: (character, system, f) ->
|
|
if @dsc
|
|
text = markdown(@dsc.fcall(this, character, system, f))
|
|
text = "<span class='look lvl#{@level}'>" + text + "</span>"
|
|
window.name = @name
|
|
text = text.replace /([\s^])\{\{(\w+)\}\}([\s$])/g, (str, p1, p2, p3) ->
|
|
name = window.name
|
|
window.name = undefined
|
|
return p1+objlink(p2, name)+p3
|
|
return text
|
|
take: () -> "You take the #{@name}." # taking to inventory
|
|
act: () -> "You don't find anything extraordinary about the #{@name}." # object action
|
|
dsc: () -> "You see a {{#{@name}}} here." # object description
|
|
put: (room) ->
|
|
@level = 0 # this is scenery
|
|
undum.game.situations[room].objects[@name] = this
|
|
|
|
obj = (name, spec) ->
|
|
spec ?= {}
|
|
spec.name = name
|
|
return new RaconteurObj(spec)
|
|
module.exports = obj
|