mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-07-07 01:04:25 +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")
|
console.error("Trying to create an object with no name")
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@level = 0 # if > 0 it's hidden
|
|
||||||
@order = 0 # you can use this to sort the descriptions
|
@order = 0 # you can use this to sort the descriptions
|
||||||
|
@visible = true
|
||||||
@look = (system, f) =>
|
@look = (system, f) =>
|
||||||
if @dsc and @dsc != ""
|
if @dsc and @dsc != "" and @visible
|
||||||
text = markdown(@dsc.fcall(this, system, f).toString())
|
text = markdown(@dsc.fcall(this, system, f).toString())
|
||||||
text = system.view.wrapLevel(text, @level)
|
|
||||||
# replace braces {{}} with link to _act_
|
# replace braces {{}} with link to _act_
|
||||||
return parsedsc(text, @name)
|
return parsedsc(text, @name)
|
||||||
@takeable = false
|
@takeable = false
|
||||||
|
|
|
@ -124,7 +124,7 @@ class SaletRoom
|
||||||
|
|
||||||
objDescriptions = []
|
objDescriptions = []
|
||||||
for thing in @objects
|
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 ({
|
objDescriptions.push ({
|
||||||
order: thing.order,
|
order: thing.order,
|
||||||
content: thing.look(system, f)
|
content: thing.look(system, f)
|
||||||
|
@ -168,10 +168,9 @@ class SaletRoom
|
||||||
system.view.clearContent()
|
system.view.clearContent()
|
||||||
@entering.fcall(this, system, @name)
|
@entering.fcall(this, system, @name)
|
||||||
return system.view.write(thing.take.fcall(thing, system).toString())
|
return system.view.write(thing.take.fcall(thing, system).toString())
|
||||||
if thing.act
|
if thing.act?
|
||||||
return system.view.changeLevel(thing.level, () ->
|
return system.view.write thing.act.fcall(thing, system)
|
||||||
return thing.act.fcall(thing, system).toString()
|
|
||||||
)
|
|
||||||
# the loop is done but no return came - match not found
|
# the loop is done but no return came - match not found
|
||||||
console.error("Could not find #{link[2]} in current room.")
|
console.error("Could not find #{link[2]} in current room.")
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class SaletView
|
||||||
|
|
||||||
# Write content to current room
|
# Write content to current room
|
||||||
write: (content, elementSelector = "#current-room") =>
|
write: (content, elementSelector = "#current-room") =>
|
||||||
if content == ""
|
if not content? or content == ""
|
||||||
return
|
return
|
||||||
content = @prepareContent(content)
|
content = @prepareContent(content)
|
||||||
block = document.querySelector(elementSelector)
|
block = document.querySelector(elementSelector)
|
||||||
|
@ -202,24 +202,6 @@ class SaletView
|
||||||
else
|
else
|
||||||
contentToHide.remove()
|
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.
|
# At last, we scroll the view so that .new objects are in view.
|
||||||
endOutputTransaction: () =>
|
endOutputTransaction: () =>
|
||||||
if !@interactive
|
if !@interactive
|
||||||
|
|
Loading…
Reference in a new issue