-
Notifications
You must be signed in to change notification settings - Fork 18
Run and Test the Examples v7
- status: complete
- version: 7.x
- follows from: Settings and Treatments
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.
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!"
},
}
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:
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.
Moreover, all treatment's settings are also available during the definition of client types (see Section Client Types).
Go back to the wiki Home.
Copyright (C) 2021 Stefano Balietti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.