/**************************************************************
* LInE - Free Education, Private Data - http://www.usp.br/line
*
* This file holds all global elements to the game.
*
* Generating game levels in menu:
* .....................................................
* ...............square....................circle...... } = gameShape
* .........../...........\....................|........ } = gameName (game)
* ........One.............Two................One....... }
* ......./...\.........../...\............./....\......
* ......a.....b.........a.....b...........a......b..... = gameMode (game mode)
* .(floor)..(stack)..(top)..(bottom)..(floor)..(stack).
* .......\./.............\./................\./........
* ........|...............|..................|.........
* ......./.\..............|................/.|.\.......
* ...plus...minus.......minus........plus.minus.mixed. = gameOperation (game math operation)
* .......\./..............|................\.|./.......
* ........|...............|..................|.........
* ......1,2,3.........1,2,3,4,5..........1,2,3,4,5..... = gameDifficulty (difficulty level)
* .....................................................
*
* About levels in map:
*
* ..................(game.levels)......................
* ......................__|__..........................
* .....................|.|.|.|.........................
* ...................0,1,2,3,4,5....................... = curMapPosition (map positions)
* ...................|.........|.......................
* ................(start)....(end).....................
**************************************************************/
/** FOR MOODLE
*
* iFractions can run on a server or inside moodle through iAssign.
* This variable should be set according to where it is suposed to run:
* - if true, on moodle
* - if false, on a server
*/
const moodle = false;
/**
* Index of the current game in gameList array
*
* @type {number}
*/
let gameId;
/**
* Selected game name.
* Can be: 'squareOne', 'squareTwo' or 'circleOne'.
*
* @type {string}
*/
let gameName;
/**
* Used for text and game information.
* Shape that makes the name of the game - e.g in 'squareOne' it is 'square'.
* Can be: 'circle' or 'square'.
*
* @type {string}
*/
let gameShape;
/**
* Holds selected game mode.
* In squareOne/circleOne can be: 'a' (click on the floor) or 'b' (click on the amount to go/stacked figures).
* In squareTwo can be: 'a' (more subdivisions on top) or 'b' (more subdivisions on bottom).
*
* @type {string}
*/
let gameMode;
/**
* Holds game math operation.
* In squareOne can be: 'plus' (green tractor goes right) or 'minus' (red tractor goes left).
* In circleOne can be: 'plus' (green tractor goes right), 'minus' (red tractor goes left) or 'mixed' (green tractor goes both sides).
* In squareTwo can be: 'minus' (compares two rectangle subdivisions).
*
* @type {string}
*/
let gameOperation;
/**
* Holds game overall difficulty. 1 (easier) -> n (harder).
* In squareOne can be: 1..3.
* In circleOne/squareTwo can be: 1..5.
*
* @type {number}
*/
let gameDifficulty;
/**
* Turns displaying the fraction labels on levels ON/OFF
* @type {boolean}
*/
let fractionLabel = true;
/**
* When true, the character can move to next position in the map
* @type {boolean}
*/
let canGoToNextMapPosition;
/**
* Character position on the map, aka game levels (1..4: valid; 5: end)
* @type {number}
*/
let curMapPosition;
/**
* Number of finished levels in the map
* @type {number}
*/
let completedLevels;
/**
* Turns game audio ON/OFF
* @type {boolean}
*/
let audioStatus = false;
/**
* Player's name
* @type {string}
*/
let playerName;
/**
* String that contains the selected language.
* It is the name of the language file.
* @type {string}
*/
let langString;
/**
* Holds the current state.
* Is used as if it was a 'this' inside state functions.
* @type {object}
*/
let self;
/**
* Information for all the games
* @type {Array}
*/
const gameList = [
{
gameName: 'squareOne',
gameMode: ['a', 'b'],
gameOperation: ['plus', 'minus'],
gameDifficulty: 3,
// info
gameShape: 'square',
assets: {
gameNameBtn: 'game_0',
gameModeBtn: ['mode_0', 'mode_1'],
gameOperationBtn: ['operation_plus', 'operation_minus'],
menuInfoBox: () => ({
title: `${game.lang.game}: ${game.lang.square} I`,
body: `
${game.lang.infoBox_mode}
`, img: `${game.lang.mode}: A - ${game.lang.infoBox_mode_s1_A} | ${game.lang.mode}: B - ${game.lang.infoBox_mode_s1_B} |
${game.lang.difficulty}: 1 | ${game.lang.difficulty}: 3 |
${game.lang.infoBox_mode}
`, img: `
|
${game.lang.mode}: A - ${game.lang.infoBox_mode_c1_A} |
${game.lang.mode}: B - ${game.lang.infoBox_mode_c1_B} |
${game.lang.infoBox_diff}
${game.lang.infoBox_diff_obs}
`, img: `${game.lang.difficulty}: 1 | ${game.lang.difficulty}: 5 |
|
|
${game.lang.infoBox_mode}
`, img: `${game.lang.mode}: A - ${game.lang.infoBox_mode_s2_A} | ${game.lang.mode}: B - ${game.lang.infoBox_mode_s2_B} |
${game.lang.difficulty}: 1 | ${game.lang.difficulty}: 5 |