-
Notifications
You must be signed in to change notification settings - Fork 18
Settings and Treatments v7
- status: complete
- version: 7.x
- follows from: Game Basics
All game variables and treatments are contained in the file
game/game.settings
. It is appropriate to store in this files variables such as: the number of coins available in the game, the duration of timers, or the exchange rate between experimental coins and some real world currency.
{
BASE_PAY: 1,
COINS: 100,
EXCHANGE_RATE: 0.0001,
TIMER: {
instructions: 60000,
bidder: 30000,
},
WAIT_TIME: 30,
WAIT_TIME_TEXT: 'Somebody disconnected!',
}
Game variables can be grouped together under a common label to create
a treatment. Simply add a variable named treatments
inside this file to start defining treatments.
Each treatment is an object nested inside the treatments
object.
{
// Other game variables omitted.
// The treatments object is a special default variable
// which contains treatments objects.
treatments: {
// Name of the treatment.
rich_treatment: {
// One-sentence description (mandatory).
description: 'Many more coins!',
// Overwrites the default variable COINS,
// but still inherits EXCHANGE_RATE.
COINS: 1000,
// Defines a new variable named TEXT.
TEXT: "You are rich now!"
// Other treatment variables here.
}
// Other treatments here.
}
}
Each treatment inherits all the variable defined outside of the treatments
object, while variables defined inside the treatments
object are available only to a specific treatment. In our example, the final settings object for the "rich_treatment" treatment will be:
{
EXCHANGE_RATE: 0.0001,
TIMER: {
instructions: 60000,
bidder: 30000,
},
WAIT_TIME: 30,
WAIT_TIME_TEXT: 'Somebody disconnected!',
// One-sentence description (mandatory).
description: 'Many more coins!',
// Overwrites the default variable COINS,
// but still inherits EXCHANGE_RATE.
COINS: 1000,
// Defines a new variable named TEXT.
TEXT: "You are rich now!",
treatmentName: "rich_treatment"
}
Note! In the final settings object:
- the treatment name is stored under a variable named
treatmentName
, - the value of game variables defined both inside and outside the treatment object (here:
COINS
) is always equal to the value inside the treatments object.
If no treatment is defined, all game variables are grouped together under a treatment named standard
.
Game developers can define as many game variables as needed, however some names are reserved for special purposes:
-
BASE_PAY: a number indicating the base pay for participating; this number is
used by
gameRoom.computeBonus()
, which adds it to any amount already added viagameRoom.updateWin()
(see Server API). - CONSENT: an object containing settings for the Consent widget.
-
TIMER: an object containing the values (in milliseconds) for the
timers of steps named after the properties of the TIMER object. For instance,
when a step named
"myStep"
begins, then a new timer is instantiated with the duration (and options) contained inTIMER["myStep"]
(if defined). - WAIT_TIME: the waiting time (in seconds) for a disconnected player to reconnect.
- WAIT_TIME_TEXT: the text displayed to other players while waiting for a player to reconnect.
When a new game starts, the waiting room selects and assigns a treatment among those available. This can be either done automatically, or users can choose a treatment themselves as shown below.
After a treatment has been decided, the final settings object is stored under node.game.settings
. More on this later.
In the later sections, you will learn how to modify and test the settings with examples.
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.