diff --git a/game/begin.coffee b/game/begin.coffee
index f11fc17..3823d2f 100644
--- a/game/begin.coffee
+++ b/game/begin.coffee
@@ -23,14 +23,17 @@ actlink = (content, ref) ->
textcycle = (content, ref) ->
return "#{content}"
-###
-This function clears the screen.
-The full backlog makes sense in dialogues but it's clunky when you exploring.
-So this is manual cls
-###
-cls = () ->
- document.getElementById("intro").innerHTML = ""
- document.getElementById("content").innerHTML = ""
+# Cycling link. It's implied there can be only one per situation.
+# You are welcome to improve this code.
+cycle = (obj, character) ->
+ responses = obj.cycle_gallery()
+ character.sandbox.cycle_index ?= [] # initialize with empty array
+ character.sandbox.cycle_index[obj.name] ?= 0 # initialize with 0
+ response = responses[character.sandbox.cycle_index[obj.name]]
+ character.sandbox.cycle_index[obj.name]++
+ if character.sandbox.cycle_index[obj.name] == responses.length
+ character.sandbox.cycle_index[obj.name] = 0
+ return textcycle(response, 'cyclewriter')
# usage: writemd( system, "Text to write")
writemd = (system, text) ->
diff --git a/game/story.coffee b/game/story.coffee
index c991f59..6a4354f 100644
--- a/game/story.coffee
+++ b/game/story.coffee
@@ -58,7 +58,7 @@ dialogue "Dialogue functions", "question2", "world", """
room "world",
tags: ["world"],
optionText: "Enter the world",
- ways: ["university"]
+ ways: ["plaza"]
content: """
### Rhinestone Room
@@ -70,17 +70,60 @@ room "world",
writers:
well: "There is only one passage out. See the „Other rooms“ block popped up? Click it."
-room "university",
+room "plaza",
+ title: (from) ->
+ if from == "world"
+ return "Upwards"
+ else
+ return "Town plaza"
+ cycle_gallery: () ->
+ return [
+ "quirky", "distinct", "kooky", "crazy", "quaint"
+ ]
+ ways: ["shop"]
before: () ->
- undum.game.situations["supermarket"].destination()
"""
- You leave the University.
+ You climb up the well and come out to a central plaza of a #{textcycle("quaint", "cyclewriter")} little town.
+ A plaque nearby says it's the town of *Innsmouth,* wherever that is.
"""
content: """
- Okay, now to the supermarket.
+ You are
+ There are #{textlink("people shouting", "people")} nearby.
+
+ You could ask a policeman #{textlink("for directions.", "mark")}
+ """
+ writers:
+ cyclewriter: (character) -> cycle(this, character)
+ mark: (character) ->
+ if character.sandbox.has_mark?
+ return "You already talked to him, no need to bug the man twice."
+ character.sandbox.has_mark ?= true
+ undum.game.situations["lair"].destination()
+ """
+ “Here, let me mark it on your map.”
+ """
+ people: 'Just some weirdos shouting "Viva la Cthulhu!". Typical.'
+
+room "shop",
+ title: "The Shop"
+ ways: ["plaza", "lair"]
+ content: """
+ Being the only shop in town, this trendy establishment did not need a name.
+ It's an open question why it had one, especially because its name was "Hung Crossing".
+
+ You are standing in front of a picturesque sign. It's cold here.
"""
-room "supermarket",
+room "lair",
+ ways: ["shop"]
+ title: "The Lair"
content: """
- A trendy supermarket.
+ The Lair of Yog-Sothoth is a very *n'gai* cave, full of *buggs-shoggogs* and *n'ghaa ng'aa*.
"""
+
+bugg = obj "bugg-shoggog",
+ dsc: "You see a particularly beautiful slimy {{bugg.}}"
+ act: () ->
+ this.delete()
+ return "You eat the bugg mass. Delicious and raw."
+bugg.put("lair")
diff --git a/lib/obj.coffee b/lib/obj.coffee
index 748ffe0..410a6a5 100644
--- a/lib/obj.coffee
+++ b/lib/obj.coffee
@@ -3,6 +3,8 @@ undum = require('./undum.js')
objlink = (content, ref) ->
return "#{content}"
+Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
+
class RaconteurObj
constructor: (spec) ->
for key, value of spec
@@ -21,9 +23,13 @@ class RaconteurObj
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) ->
+ location: ""
+ put: (location) ->
@level = 0 # this is scenery
- undum.game.situations[room].objects[@name] = this
+ undum.game.situations[location].objects[@name] = this
+ @location = location
+ delete: () ->
+ undum.game.situations[@location].objects.remove(this)
obj = (name, spec) ->
spec ?= {}
diff --git a/lib/room.coffee b/lib/room.coffee
index 65d24b3..d2d011f 100644
--- a/lib/room.coffee
+++ b/lib/room.coffee
@@ -31,14 +31,14 @@ addClass = (element, className) ->
here = () ->
return undum.game.situations[document.getElementById("current-situation").getAttribute("data-situation")]
-update_ways = (ways) ->
+update_ways = (ways, name) ->
content = ""
distances = []
if ways
document.querySelector(".ways h2").style.display = "block"
for way in ways
if undum.game.situations[way]?
- title = undum.game.situations[way].name
+ title = undum.game.situations[way].title.fcall(this, name)
content += way_to(title, way)
distances.push({
key: way
@@ -74,7 +74,10 @@ class SaletRoom extends RaconteurSituation
@writers = spec.writers
if spec.extendSection?
@extendSection = spec.extendSection
+ if spec.title?
+ @title = spec.title
return this
+ title: "Room"
objects: []
extendSection: false
distance: Infinity # distance to the destination
@@ -133,13 +136,13 @@ class SaletRoom extends RaconteurSituation
current_situation = "
tags are usually bad for replacers system.replaceWith(output, '#'+ref) inserter: (ref) -> content = that.writers[ref].fcall(that, character, system, action) - output = markdown(content).fade() + output = markdown(content) system.writeInto(output, '#'+ref) }