mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-07-02 06:45:06 +03:00
Got rid of levels
This commit is contained in:
parent
51abba90dd
commit
2197fbad65
|
@ -21,12 +21,11 @@ class SaletObj
|
|||
console.error("Trying to create an object with no name")
|
||||
return null
|
||||
|
||||
@level = 0 # if > 0 it's hidden
|
||||
@order = 0 # you can use this to sort the descriptions
|
||||
@visible = true
|
||||
@look = (system, f) =>
|
||||
if @dsc and @dsc != ""
|
||||
if @dsc and @dsc != "" and @visible
|
||||
text = markdown(@dsc.fcall(this, system, f).toString())
|
||||
text = system.view.wrapLevel(text, @level)
|
||||
# replace braces {{}} with link to _act_
|
||||
return parsedsc(text, @name)
|
||||
@takeable = false
|
||||
|
|
|
@ -124,7 +124,7 @@ class SaletRoom
|
|||
|
||||
objDescriptions = []
|
||||
for thing in @objects
|
||||
if thing.name and typeof(thing.look) == "function" and thing.level == 0 and thing.look(system, f)
|
||||
if thing.name and typeof(thing.look) == "function" and thing.look(system, f)
|
||||
objDescriptions.push ({
|
||||
order: thing.order,
|
||||
content: thing.look(system, f)
|
||||
|
@ -168,10 +168,9 @@ class SaletRoom
|
|||
system.view.clearContent()
|
||||
@entering.fcall(this, system, @name)
|
||||
return system.view.write(thing.take.fcall(thing, system).toString())
|
||||
if thing.act
|
||||
return system.view.changeLevel(thing.level, () ->
|
||||
return thing.act.fcall(thing, system).toString()
|
||||
)
|
||||
if thing.act?
|
||||
return system.view.write thing.act.fcall(thing, system)
|
||||
|
||||
# the loop is done but no return came - match not found
|
||||
console.error("Could not find #{link[2]} in current room.")
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class SaletView
|
|||
|
||||
# Write content to current room
|
||||
write: (content, elementSelector = "#current-room") =>
|
||||
if content == ""
|
||||
if not content? or content == ""
|
||||
return
|
||||
content = @prepareContent(content)
|
||||
block = document.querySelector(elementSelector)
|
||||
|
@ -202,24 +202,6 @@ class SaletView
|
|||
else
|
||||
contentToHide.remove()
|
||||
|
||||
# Remove every section marked as a different level.
|
||||
# For a link level 0, we hide every link of level 1 and above.
|
||||
# It's for the player to focus.
|
||||
changeLevel: (level, callback) =>
|
||||
maxLevel = 6
|
||||
if level < maxLevel
|
||||
i = level + 1
|
||||
hideArray = []
|
||||
while i <= maxLevel
|
||||
hideArray.push("#content .lvl"+i)
|
||||
i++
|
||||
directive = hideArray.join(", ")
|
||||
$(directive).hide()
|
||||
@write system.view.wrapLevel(callback(), level)
|
||||
|
||||
wrapLevel: (text, level) =>
|
||||
return "<div class='lvl#{level}'>"+markdown(text)+'</div>'
|
||||
|
||||
# At last, we scroll the view so that .new objects are in view.
|
||||
endOutputTransaction: () =>
|
||||
if !@interactive
|
||||
|
|
Loading…
Reference in a new issue