Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ const TILES = {
o: { id: 'rock', name: 'una piedra', solid: true },
t: { id: 'tree', name: 'un arbol', solid: true },
'~': { id: 'water', name: 'el agua', solid: true },
// Art leftovers that used to fall through to NOWHERE and become invisible
// walls (#6): carved-out ground reads as open floor, lattice windows and
// tiny ornament glyphs stay part of the facade they decorate.
' ': { id: 'open', name: 'el hueco del arte', solid: false },
'=': { id: 'lattice', name: 'una reja', solid: true },
'`': { id: 'ornament', name: 'un adorno', solid: true },
"'": { id: 'ornament', name: 'un adorno', solid: true },

C: { id: 'door.home', name: 'tu casa', solid: false, enter: { kind: 'home' } },
I: { id: 'door.church', name: 'la iglesia', solid: false, enter: { kind: 'church' } },
Expand Down Expand Up @@ -599,7 +606,14 @@ function makeHighResolutionCityRows() {
}
}
const write = (x, y, text) => {
for (let i = 0; i < String(text).length; i++) set(x + i, y, String(text)[i])
for (let i = 0; i < String(text).length; i++) {
// Spaces between sign words or around stamped art are gaps, not terrain:
// writing them would punch NOWHERE holes into whatever lies beneath and
// leave invisible walls behind (#6). Deliberate carving goes through
// set()/fill() directly, which keeps its explicit-space behaviour.
if (String(text)[i] === ' ') continue
set(x + i, y, String(text)[i])
}
}
const centred = (x, y, w, text) => write(x + Math.floor((w - String(text).length) / 2), y, text)
const border = (x, y, w, h, horizontal = '-', vertical = '|') => {
Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
const render = require('../lib/render.js')

require('./sage.test.js')
require('./no-invisible-walls.test.js')

function press(game, name) {
return game.onKey({ type: 'key', is: (...keys) => keys.includes(name) })
Expand Down
40 changes: 40 additions & 0 deletions test/no-invisible-walls.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { test } = require('brittle')
const M = require('../lib/map.js')

test('art leftover glyphs live in the tile table, not in NOWHERE (#6)', (t) => {
t.is(M.TILES[' '].id, 'open')
t.is(M.TILES[' '].solid, false, 'a carved-out gap is open ground')
t.is(M.TILES['='].solid, true, 'the lattice stays part of the facade')
t.is(M.TILES['`'].solid, true)
t.is(M.TILES["'"].solid, true)
})

test('no in-bounds cell of the city resolves to NOWHERE anymore (#6)', (t) => {
// The issue counted 15938 of 64000 cells (24.9%) falling into NOWHERE via
// four undeclared glyphs. Every glyph the art uses must now be declared.
const city = M.MAPS.city
let nowhere = 0
for (let y = 0; y < city.height; y++) {
for (let x = 0; x < city.width; x++) {
if (M.tileAt(city, x, y).id === 'nowhere') nowhere++
}
}
t.is(nowhere, 0, 'every glyph in the active art is declared in TILES')
})

test('walking into an art gap meets open ground, not an invisible wall (#6)', (t) => {
const city = M.MAPS.city
let checked = 0
for (let y = 0; y < city.height; y++) {
const row = city.rows[y]
for (let x = 0; x < row.length; x++) {
if (row[x] !== ' ') continue
checked++
if (M.isSolid(city, x, y)) {
t.fail(`space at ${x},${y} is still solid`)
return
}
}
}
t.ok(checked > 10000, `the scan actually saw the art gaps (saw ${checked})`)
})