Parserless javascript mini-adventure system

I’ve been playing some of the old Scott Adams games recently, and it occurred to me that the ultra-terse, puzzle-heavy style could be nice for “mini-adventure” games on mobile devices. But typing on mobile devices is not nice, so I’ve started working on a parserless system that otherwise mimics the feel of those games:

(This is a web page for now, but it will be possible to compile games made this way into mobile apps using cordova or something.)

The game data is defined in a JSON object, for easy stashing in variables or localStorage when I implement undo and save/restore. Currently you can see a version of this at work when the game ends (either bring the ruby to the trophy case and STASH it, or go down the tunnel with no light and get eaten by a grue) and you’re able to restart it.

An excerpt of game data showing an item:

		lantern: {
			description: "brass lantern",
			portable: true,
			active_verbs: [],
			location: 'house',
			after: {
				take: 'set_lantern_verbs' // name of a function that gets called after "take lantern"

Items have an active_verbs array that changes depending on context - for example, when you pick the lantern up, you’re able to DROP or LIGHT it, and when it’s lit you can UNLIGHT it. The available verbs show up as clickable words next to the item listing.

I’m not sure about the layout - there are three main bits of display: the room description, the hero’s inventory, and a pseudo-terminal bit that prints the commands as if you’d typed them ("> TAKE LANTERN") and the game’s responses.

One observation from trying the COD test on my mobile device – the output is quite a bit wider than is useful for mobile play, resulting in minuscule text.

General rule of thumb that’s good for anything mobile-based text-heavy - best to allow the player to customise at least the size of the text and have good word-wrap.

I put in a meta tag that is supposed to stop it resizing on mobiles and it’s working on my Android mini-tablet, is that better now?

I also made some things a bit neater, added save/restore/undo, and put in a new sample tiny game (the intro to one I might write in full.)

Display options like font size are on the to-do list.

Walkthrough for the sample game:

After the zeppelin goes through the swirly thing, take the harpoon, climb the rigging (AFT then UP from the bridge), and burst the balloon to land safely.