Detailed structure

Let us consider an existing location called “marketStreet”. This place is directly accessible from the city map.
This location has several information :

  • a name market streets
  • a description This street is so vivid and full of life you are petrified for a moment
  • a set of actions and other locations accessible from it
  • an image which is displayed in the background

Everything you find there is defined in a specific folder of the referenceData directory
referenceData/locations/marketStreet which contains following files :

  • marketStreet.json
  • marketStreet.properties
  • marketStreet_en.properties

As you can notice, the image is not in this folder but in naorImages/images/locations folder.

To sum up, you basically have two kind of files :

  • .json, which must be unique inside any given directory.
  • .properties. one file must exist for each language, so in this example there is two languages for this location.

Json file

It is a specific text structure mainly used on the internet between website. It is used on this project because one can easily understand the content & format by reading it like a text file. For more details you can check wikipedia.

For the example of the location, it is like a summary and gives all details the game need to know to correctly use it.

If you open the file marketStreet.json, you will find something like that :

{
 "type": "location",
 "id": "marketStreet",
 "name": "marketStreetName",
 "descriptions": [
  "marketStreetDesc1",
  "marketStreetDesc2"
 ],
 "images": [
  "image:locations/market.jpg"
 ],
 "actions": [
  {
   "id": "Action01",
   "name": "marketStreetAction1",
   "arcs": [
    "marketStreetGenerics", "animalPheromonesArc"
   ]
  }
 ],
 "locations": [
  "generalStore", "redLightDistrict", "churchArea", "market"
 ]
}

You can see a set of attributes such as “type”, “id”, “name”, “locations” and a set of values such as “location”,”marketStreet”, [“generalStore”, “redLightDistrict”, “churchArea”, “market”] and so on.

There are four kind of attributes :

  • an attribute called “id” which defines a unique identifier for this object (it must be unique across all items, basically you just need to put the name of the file). It can be used each time you want to reference this concept from elsewhere.
  • a value such as the attribute “type” which defines the kind of object, here it is a location.
  • reference to a localized key, found in the corresponding properties file, for example the attribute “name” is referencing the key called “marketStreetName”.
  • reference to an other item. For exemple the “locations” attribute is full of them and basically tells that from “marketStreet” you can go to “generalStore”, “redLightDistrict” and so on. The value used here matches the one defined as “id” in the corresponding file.

Properties file

They are specific files that defines the text which will be displayed to the player, such as “This street is so vivid and full of life you are petrified for a moment”. You will find one .properties file for each supported language (so you get the _en for english one and the one without _ for the default language, which is French). it defines pair of key-value. Keys are used on json file and will be looked up at runtime when a text need to be displayed.

If you open a properties file, you will find something like that :

marketStreetName=The market
marketStreetDesc1=This street is so vivid and full of life you are petrified for a moment.
marketStreetDesc2=Welcome to the center of this town where everything can be bought and sold.
marketStreetAction1=Wandering

There is one thing to notice in the file : there is an = sign which will define pairs of key-value. On the left you get the key, which will be used in the json file, on the right its value which will be used during the runtime. You can see it as a dictionary; you look up a word and get its definition, here you lookup a specific word and get the text to display!

All text displayed to the player (such as the name of a place, the description of an item, an event) are written in .properties file.
As a side note, if you want to add a language, you will have to add one properties file for each existing json. Yes, that’s really long.

Advertisements