Added #map

This commit is contained in:
raeleus 2024-09-30 08:08:19 -07:00
parent 99b9206276
commit a27a107c83
4 changed files with 48 additions and 3 deletions

View file

@ -187,6 +187,15 @@ const modifier = (text) => {
}
text += "******************\n\n"
break
case "map":
text += `A 11x11 map of the area surrounding (${state.x},${state.y}):\n`
var map = mapGenerate()
map = mapReplace(map, state.x, state.y, "@")
state.locations.forEach(location => {
map = mapReplace(map, location.x, location.y, location.name.substring(0, 1).toUpperCase())
})
text += map
break
case "none":
text += " "
break
@ -348,4 +357,27 @@ const modifier = (text) => {
return { text }
}
const mapLineBreak = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
const mapLine = "| * * * * * * * * * * * |\n"
function mapGenerate() {
var map = mapLineBreak
for (var i = 0; i < 11; i++) map += mapLine
map += mapLineBreak
return map
}
function mapReplace(map, x, y, character) {
x += 5 - state.x
y += 5 - state.y
if (x < 0 || x > 10 || y < 0 || y > 10) return map
index = mapLineBreak.length + 6 + x * 6 + y * mapLine.length
map = map.replaceAt(index, character)
return map
}
modifier(text)