Run and Test the Examples v7 - nodeGame/nodegame GitHub Wiki

In the following sections, several JavaScript examples will be provided. To try out these examples, you will need a text editor to edit the files on your computer. We recommend the Atom editor and this guide shows you how to configure it properly.

For every example, open the file specified in the instructions with your text editor, and edit it according to the example. Once finishing editing, remember to save the file and restart the server with the command: node launcher.js. Then, access nodeGame and check the changes.

Modifying the treatments

Continuing with the last example of treatment settings, you can create a new treatment called "rich" simply adding a new object inside the treatments object. See the example below:

treatments: {
    standard: {
        description: "Longer time",
        bidTime: 30000
    },

    pressure: {
        description: "Short times to take decisions",
        bidTime: 10000
    },

    // New treatment added:
    rich:{
        description: "Many more coins!",
        COINS: 1000,
        // Defines a new variable named TEXT.
        TEXT: "You are rich now!"
  },

}

Testing your changes

To test your changes you need to restart the server.

If your server is already running, you must stop it by holding down the keys Ctrl and C in the same Git Bash console where you previously launched it.

Then simply launch the server with command (from the nodeGame root directory):

node launcher.js

Then open the browser and you should be able to see the changes as below:

Illustration of the Waiting Room

More on Settings and Treatments

All the game variables of the selected treatment are automatically sent to every connected client and stored as node.game.settings. For example, if you select a "rich" treatment, type node.game.settings in the browser console, and you will be able to see the settings object.

Illustration of the Waiting Room

Moreover, all treatment's settings are also available during the definition of client types (see Section Client Types).

Next Topics

⚠️ **GitHub.com Fallback** ⚠️