How to create game data

This page explains how to create game data by yourself.

Introduction

GameRandomizer's game data consist of XML (extensible markup language) files. XML data are human readable text so that you can edit the files using a text editor.

For each game, you need to create some XML files; a file '__game.xml' (starting with two '_') and one or more expansion files.

All the XML files MUST be written in UTF-8.

'__game.xml' file

'__game.xml' defines basic information of the game. The following is an exmaple of a '__game.xml' file.

<?xml version="1.0" encoding="UTF-8"?>
<game id="dominion"
      revision="1" format_version="1" language="en" country="">
  <game_title>Dominion</game_title>
  <selection_size>10</selection_size>
</game>

Whitespaces at the beginning of lines are not mandatory. The second line can also be described like this:

<game id="dominion"
revision="1" format_version="1" language="en" country="">

You can also insert new line characters where whitespace is allowed.

<game id="dominion"
      revision="1"
      format_version="1"
      language="en"
      country="">

The first line of '__game.xml' file MUST be an XML declaration. Please insert the line as it is.

<?xml version="1.0" encoding="UTF-8"?>

The rest of the file is a <game>...</game> block. The start tag <game> has some attribtues:

<game id="dominion"
      revision="1" format_version="1" language="en" country="">

Here is a short brief of the attributes.

attributedescription
idID of the game.
revisionRevision number of the XML file.
format_versionVersion of the XML format.
languageLanguage code.
countryCountry code.

The value of the 'id' attribute MUST be unique in all games.

The 'revision' attribute is optional. GameRandomizer ignores this attribute but you SHOULD use the attribute to manage the game data. It starts from '1' and adds one each time you update the data.

Please set 'format_version' to '1'. Only the format version '1' is currently defined.

'language' and 'country' attributes represent that the game data are written in the specified language and for the specified country. GameRandomizer reads game data only matching with the current language/country setting of the Anroid device. (Go to "Settings" -> "Language & Input" to change the language/country setting.)

The value of 'language' MUST be a two-letter ISO 639-1 language code in lower case. The language code 'en' in this example means English. You can see a list of the language codes at:

The value of 'country' MUST be an ISO 3166-1 country/region code in upper case. You can see a list of the country/region codes at:

Unlike 'language', 'country' MAY be blank (""). In most cases, blank is suitable value for 'country'. When you create game data for Chinese (zh), set 'country' to 'CN' (China = Simplified Chinese) or 'TW' (Taiwan = Traditional Chinese).

Basic information about the game is described within the <game>...</game> block.

<game_title>Dominion</game_title>
<selection_size>10</selection_size>

<game_title>...</game_title> describes a title of the game.

<selection_size>...</selection_size> describes how many kinds of cards GameRandomizer selects randomly. It MUST be an integer greater than zero.

Expansion files

An expansion file defines data about an expansion (like Intrigue, Seaside ... of Dominion) of the game. Since GameRandomizer doesn't distinguishes a base game (like Dominion of Dominion) from expansions, also an expansion file for a base game is needed.

Here is an example of an expansion file:

<?xml version="1.0" encoding="UTF-8"?>
<expansion id="intrigue" game_id="dominion"
           revision="1" format_version="1" language="en" country="">

  <preference>1020</preference>
  <expansion_title>Intrigue</expansion_title>

  <card id="courtyard">
    <title>Courtyard</title>
    <price>2</price>
  </card>

  <card id="pawn">
    <title>Pawn</title>
    <price>2</price>
  </card>
</expansion>

The first line is an XML declaration which is the same as '__game.xml'.

<?xml version="1.0" encoding="UTF-8"?>

The rest of the file is an <expansion>...</expansion> block. The start tag <expansion> has some attribtues:

<game id="intrigue" game_id="dominion"
      revision="1" format_version="1" language="en" country="">

Those attributes mean:

attributedescription
idID of the expansion.
game_idID of the game.
revisionRevision number of the XML file.
format_versionVersion of the XML format.
languageLanguage code.
countryCountry code.

'revision', 'format_version', 'language' and 'country' are the same as those of the <game> tag in '__game.xml'.

The value of 'game_id' tag MUST be the same as that of the 'id' attribute of the <game> tag in '__game.xml'.

The value of 'id' MUST be unique in all expansions of the game. The file name of the expansion file MUST be id.xml. (The file name of this example must be 'intrigue.xml'.)

Basic information about the expansion is described at the beginning within the <expansion>...</expansion> block:

  <preference>1020</preference>
  <expansion_title>Intrigue</expansion_title>

The value within <preference>...</preference> tags MUST be an integer. When GameRandomizer displays a list of expansions, sorts them according with the preference values. Its value SHOULD be unique in all expansions of the game.

<expansion_title>...</expansion_title> describes a title of the expansion.

At the rest of the <expansion>...</expansion> block, all cards prvoided by the expansion are defined:

  <card id="courtyard">
    <title>Courtyard</title>
    <price>2</price>
  </card>

  <card id="pawn">
    <title>Pawn</title>
    <price>2</price>
  </card>

This expansion provides only two cards, because this is just an example. Each <card>...</card> block defines a card. The <card> tag has an attribute 'id' which defines an identifier of the card. It MUST be unique in all cards of the game, but if multiple expansions provide the identical cards, they MUST have the same identifier. Otherwise, GameRandomizer selects the card multiple times during a random selection.

<title>...</title> tags describes a title of the card.

<price>...</price> tags describes price (cost) of the card. Note that the value of <price>...</price> is not restricted to an integer. You can set "?", "X", "3+" and so on.

Layout of folders and XML files

Suppose that <game> tag of '__game.xml' is:

<game id="dominion"
      revision="1" format_version="1" language="en" country="">

The '__game.xml' file MUST be placed as 'dominion/en/__game.xml', in this case.

+- dominion/
   +- en/
      +- __game.xml

The top folder name ('dominion') is determined by the 'id' attribute and its sub-folder name ('en') is determined by the 'language' attribute of the <game> tag, respectively. If the 'country' attribute is not blank, adds '_' + country to the sub-folder name. For example, the country attribute is set to "US" (United States of America), the proper sub-folder name is "en_US":

+- dominion/
   +- en_US/
      +- __game.xml

Place all exapnsion files at the folder where '__game.xml' exists.

+- dominion/
   +- en/
      +- __game.xml
      +- dominion.xml
      +- intrigue.xml
      +- seaside.xml
      +- alchemy.xml

Now the game data files are ready to use.