JSON Formatting - nt314p/Zork GitHub Wiki

Items

Descriptions for all items (including places) are optional.

Item

{
  "type": "item",
  "name": "[item name]",
  "weight": "[item weight]",
  "descriptions": [
    "hashmap key:hashmap value",
  ]
}

Health

The health value should be a value between 0.0 and 1.0 inclusive.

{
  "type": "health",
  "name": "[item name]",
  "weight": "[item weight]",
  "health": "[health value]",
  "descriptions": [
    "hashmap key:hashmap value",
  ]
}

Food

The food and water values should be between 0.0 and 1.0 inclusive.

{
  "type": "food",
  "name": "[item name]",
  "weight": "[item weight]",
  "food": "[food value]",
  "water": "[water value]",
  "descriptions": [
    "hashmap key:hashmap value",
  ]
}

Weapon

The weapon value should be between 0.0 and 1.0 inclusive.

{
  "type": "weapon",
  "name": "[item name]",
  "weight": "[item weight]",
  "damage": "[weapon damage]",
  "descriptions": [
    "hashmap key:hashmap value",
  ]
}

Key

{
  "type": "key",
  "name": "[item name]",
  "weight": "[item weight]",
  "code": "[key code to match with a door]",
  "descriptions": [
    "hashmap key:hashmap value",
  ]
}

Places

Room

The inventory is optional.

{
  "type": "room",
  "name": "[room name]",
  "inventory": "[inventory name]",
  "descriptions": [
    "hashmap key:hashmap value",
  ],
  "coords": "x,y,z"
}

Wall

{
  "type": "wall",
  "name": "[wall name]",
  "descriptions": [
    "hashmap key:hashmap value",
  ],
  "coords": "x,y,z"
}

Opening

{
  "type": "opening",
  "name": "[opening name]",
  "descriptions": [
    "hashmap key:hashmap value",
  ],
  "coords": "x,y,z"
}

Door

The locked value is optional, its default is false. The code value is optional, a door with no code has no lock.

{
  "type": "door",
  "name": "[door name]",
  "open": true/false,
  "locked": true/false,
  "code": "[the keycode to match with a key]",
  "descriptions": [
    "hashmap key:hashmap value",
  ],
  "coords": "x,y,z"
}

Map Related

Map

The map name on the file does not need to match the map name, however, the map name inside the JSON is the one to reference. The file name is irrelevant, but name it something useful. All defaults are optional.

File name: [map name].json

{
  "name": "[the map name]",
  "default-side-vertical": {
    "[place information]"
  },
  "default-side-horizontal": {
    "[place information]"
  },
  "default-room": {
    "[place information]"
  },
  "places": [
    {"[place]"},
    {"[place]"},
    {"[place]"}
  ]
}

Game

The phases should be loaded in their correct order.

File name: game.json

{
  "playerStart": {
    "map":"[map name]",
    "coords": "x,y,z"
  },
  "phases": [
    "[phase name one]",
    "[phase name two]",
    "[phase name three]"
  ]
}

Preset

{"item info"} can be any subclass of Item and includes Item itself. File name: presets.json

{
  "presets": [
    {"item info"},
    {"item info"},
    {"item info"}
  ]
}