mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-06 05:30:28 -04:00
Added #map
This commit is contained in:
parent
99b9206276
commit
a27a107c83
4 changed files with 48 additions and 3 deletions
13
Input.js
13
Input.js
|
@ -52,12 +52,13 @@ const showAutoXpSynonyms = ["showautoxp"]
|
|||
const setDefaultDifficultySynonyms = ["setdefaultdifficulty", "defaultdifficulty", "setdefaultdc", "defaultdc", "setdefaultac", "defaultac", "setdifficulty", "difficulty", "dc"]
|
||||
const showDefaultDifficultySynonyms = ["showdefaultdifficulty", "showdefaultdc", "showdefaultac"]
|
||||
const generateNameSynonyms = ["generatename", "name", "randomname", "makename", "createname"]
|
||||
const createLocationSynonyms = ["createlocation", "makelocation", "generatelocation", "addlocation", "createplace", "makeplace", "generateplace", "addplace", "createtown", "maketown", "generatetown", "addtown", "createvillage", "makevillage", "generatevillage", "addvillage", "createcity", "makecity", "generatecity", "addcity", "updatelocation", "updateplace", "updatetown", "updatevillage", "updatecity"]
|
||||
const createLocationSynonyms = ["createlocation", "makelocation", "generatelocation", "addlocation", "setlocation", "createplace", "makeplace", "generateplace", "addplace", "setplace", "createtown", "maketown", "generatetown", "addtown", "settown", "createvillage", "makevillage", "generatevillage", "addvillage", "setvillage", "createcity", "makecity", "generatecity", "addcity", "setcity", "updatelocation", "updateplace", "updatetown", "updatevillage", "updatecity"]
|
||||
const goToLocationSynonyms = ["gotolocation", "golocation", "movetolocation", "traveltolocation", "travellocation", "gotoplace", "goplace", "movetoplace", "traveltoplace", "travelplace", "gototown", "gotown", "movetotown", "traveltotown", "traveltown", "gotovillage", "govillage", "movetovillage", "traveltovillage", "travelvillage", "gotocity", "gocity", "movetocity", "traveltocity", "travelcity", "goto", "go", "moveto", "move", "travelto", "travel"]
|
||||
const removeLocationSynonyms = ["removelocation", "deletelocation", "eraselocation", "removeplace", "deleteplace", "eraseplace", "removetown", "deletetown", "erasetown", "removevillage", "deletevillage", "erasevillage", "removecity", "deletecity", "erasecity"]
|
||||
const showLocationsSynonyms = ["showlocations", "showplaces", "showtowns", "showvillages", "showcities", "locations", "places", "towns", "villages", "cities"]
|
||||
const getLocationSynonyms = ["getlocation", "location", "getcoordinates", "coordinates", "getcoords", "coords", "showlocation"]
|
||||
const clearLocationsSynonyms = ["clearlocations", "eraselocations", "deletelocations", "resetlocations"]
|
||||
const mapSynonyms = ["map", "showmap"]
|
||||
const helpSynonyms = ["help"]
|
||||
|
||||
const modifier = (text) => {
|
||||
|
@ -162,6 +163,7 @@ const modifier = (text) => {
|
|||
if (text == null) text = processCommandSynonyms(command, commandName, removeLocationSynonyms, doRemoveLocation)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, showLocationsSynonyms, doShowLocations)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, getLocationSynonyms, doGetLocation)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, mapSynonyms, doMap)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, renameCharacterSynonyms, doRenameCharacter)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, cloneCharacterSynonyms, doCloneCharacter)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp)
|
||||
|
@ -1246,8 +1248,8 @@ function doGoToLocation(command) {
|
|||
|
||||
if (location == null) {
|
||||
distance = pointDistance(state.x, state.y, arg0, arg1)
|
||||
state.x = arg0
|
||||
state.y = arg1
|
||||
state.x = parseInt(arg0)
|
||||
state.y = parseInt(arg1)
|
||||
} else {
|
||||
distance = pointDistance(state.x, state.y, location.x, location.y)
|
||||
state.x = location.x
|
||||
|
@ -1373,6 +1375,11 @@ function doTake(command) {
|
|||
return text
|
||||
}
|
||||
|
||||
function doMap(command) {
|
||||
state.show = "map"
|
||||
return " "
|
||||
}
|
||||
|
||||
function doDrop(command) {
|
||||
var character = getCharacter()
|
||||
var commandName = getCommandName(command)
|
||||
|
|
|
@ -31,6 +31,7 @@ function rotate(cx, cy, x, y, angle) {
|
|||
}
|
||||
|
||||
function createLocation(x, y, name) {
|
||||
log(`createlocation ${name}:${x},${y}`)
|
||||
if (x == null || y == null) {
|
||||
var cx = x == null ? state.x : x
|
||||
var cy = y == null ? state.y : y
|
||||
|
@ -340,6 +341,10 @@ function findSpellCardIndex(name) {
|
|||
return storyCards.findIndex((element) => element.type == "spell" && element.keys == name)
|
||||
}
|
||||
|
||||
String.prototype.replaceAt = function(index, replacement) {
|
||||
return this.substring(0, index) + replacement + this.substring(index + replacement.length);
|
||||
}
|
||||
|
||||
String.prototype.plural = function(revert) {
|
||||
|
||||
var plural = {
|
||||
|
|
32
Output.js
32
Output.js
|
@ -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)
|
|
@ -16,6 +16,7 @@ See the [user guide here](https://github.com/raeleus/Hashtag-DnD/wiki).
|
|||
|
||||
v. 0.1.0
|
||||
* Added `#createlocation`, `#goto`, `#removelocation`, `#clearlocations`, `#getlocation` and `#showlocations` to enable travelling.
|
||||
* Added `#map` to generate an ASCII map based on the locations and player location.
|
||||
* Added `#renameitem` to rename an existing item
|
||||
* Added `#renamecharacter` to rename an existing character
|
||||
* Added `#clonecharacter` to copy an existing character
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue