Преглед изворни кода

make all data in lower case

lairaalmas пре 1 година
родитељ
комит
454aff4e08

+ 35 - 35
src/js/games/circleOne.js

@@ -6,11 +6,11 @@
  *
  * .....circleOne.... = gameName
  * ....../....\......
- * .....A......B..... = gameMode
+ * .....a......a..... = gameMode
  * .......\./........
  * ........|.........
  * ....../.|.\.......
- * .Plus.Minus.Mixed. = gameOperation
+ * .plus.minus.mixed. = gameOperation
  * ......\.|./.......
  * ........|.........
  * ....1,2,3,4,5..... = gameDifficulty
@@ -22,18 +22,18 @@
  *
  * Game modes can be :
  *
- *   A : Player can place balloon position
+ *   a : Player can place balloon position
  *       Place balloon in position (so the kid can get to it)
- *   B : Player can select # of circles
+ *   b : Player can select # of circles
  *       Selects number of circles (that represent distance kid needs to walk to get to the balloon)
  *
  * Operations can be :
  *
- *   Plus : addition of fractions
+ *   plus : addition of fractions
  *     Represented by : kid going to the right (floor positions 0..5)
- *   Minus : subtraction of fractions
+ *   minus : subtraction of fractions
  *     Represented by: kid going to the left (floor positions 5..0)
- *   Mixed : Mix addition and subtraction of fractions in same
+ *   mixed : Mix addition and subtraction of fractions in same
  *     Represented by: kid going to the left (floor positions 0..5)
  *
  * @namespace
@@ -58,7 +58,7 @@ const circleOne = {
     let hasBaseDifficulty = false; // Will validate that level isnt too easy (has at least one '1/difficulty' fraction)
 
     const startY = context.canvas.height - 75 * 1.6;
-    const startX = gameOperation == 'Minus' ? 66 + 5 * 156 : 66; // Initial 'x' coordinate for the kid and the baloon
+    const startX = gameOperation == 'minus' ? 66 + 5 * 156 : 66; // Initial 'x' coordinate for the kid and the baloon
     this.correctX = startX; // Ending position, accumulative
 
     // BACKGROUND
@@ -130,17 +130,17 @@ const circleOne = {
 
     // Number of circles
     const max =
-      gameOperation == 'Mixed' || gameMode == 'B' ? 6 : curMapPosition + 1;
+      gameOperation == 'mixed' || gameMode == 'b' ? 6 : curMapPosition + 1;
     const min =
-      gameOperation == 'Mixed' && curMapPosition < 2 ? 2 : curMapPosition; // Mixed level has at least 2 fractions
+      gameOperation == 'mixed' && curMapPosition < 2 ? 2 : curMapPosition; // Mixed level has at least 2 fractions
     const total = game.math.randomInRange(min, max); // Total number of circles
 
-    // gameMode 'B' exclusive variables
-    this.fractionIndex = -1; // Index of clicked circle (game B)
+    // gameMode 'b' exclusive variables
+    this.fractionIndex = -1; // Index of clicked circle (game (b))
     this.numberOfPlusFractions = game.math.randomInRange(1, total - 1);
 
     // CIRCLES
-    const levelDirection = gameOperation == 'Minus' ? -1 : 1;
+    const levelDirection = gameOperation == 'minus' ? -1 : 1;
     const x = startX + 65 * levelDirection;
 
     for (let i = 0; i < total; i++) {
@@ -154,13 +154,13 @@ const circleOne = {
       let direction;
 
       switch (gameOperation) {
-        case 'Plus':
+        case 'plus':
           direction = 'Right';
           break;
-        case 'Minus':
+        case 'minus':
           direction = 'Left';
           break;
-        case 'Mixed':
+        case 'mixed':
           if (i < this.numberOfPlusFractions) direction = 'Right';
           else direction = 'Left';
           break;
@@ -254,8 +254,8 @@ const circleOne = {
 
       circle.rotate = 90;
 
-      // If game is type B (select fractions)
-      if (gameMode == 'B') {
+      // If game is type (b) (select fractions)
+      if (gameMode == 'b') {
         circle.alpha = 0.5;
         circle.index = i;
       }
@@ -281,8 +281,8 @@ const circleOne = {
       this.restart = true;
     }
 
-    // If game is type B, selectiong a random balloon place
-    if (gameMode == 'B') {
+    // If game is type (b), selectiong a random balloon place
+    if (gameMode == 'b') {
       this.balloonPlace = startX;
       this.endIndex = game.math.randomInRange(
         this.numberOfPlusFractions,
@@ -322,7 +322,7 @@ const circleOne = {
       1.2
     );
     this.kid.anchor(0.5, 0.8);
-    if (gameOperation == 'Minus') {
+    if (gameOperation == 'minus') {
       this.kid.animation = this.availableAnimations['Left'];
       this.kid.curFrame = 23;
     } else {
@@ -496,7 +496,7 @@ const circleOne = {
   },
 
   /**
-   * (in gameMode 'B') Function called when cursor is over a valid circle
+   * (in gameMode 'b') Function called when cursor is over a valid circle
    *
    * @param {object} cur circle the cursor is over
    */
@@ -510,7 +510,7 @@ const circleOne = {
   },
 
   /**
-   * (in gameMode 'B') Function called when cursor is out of a valid circle
+   * (in gameMode 'b') Function called when cursor is out of a valid circle
    */
   outCircle: function () {
     if (!self.hasClicked) {
@@ -522,18 +522,18 @@ const circleOne = {
   },
 
   /**
-   * (in gameMode 'B') Function called when player clicked over a valid circle
+   * (in gameMode 'b') Function called when player clicked over a valid circle
    *
    * @param {number|object} cur clicked circle
    */
   clicked: function (cur) {
     if (!self.hasClicked) {
-      // On gameMode A
-      if (gameMode == 'A') {
+      // On gameMode (a)
+      if (gameMode == 'a') {
         self.balloon.x = cur;
         self.basket.x = cur;
-        // On gameMode B
-      } else if (gameMode == 'B') {
+        // On gameMode (b)
+      } else if (gameMode == 'b') {
         document.body.style.cursor = 'auto';
 
         for (let i in self.circles.all) {
@@ -593,11 +593,11 @@ const circleOne = {
    */
   viewHelp: function () {
     if (!self.hasClicked) {
-      // On gameMode A
-      if (gameMode == 'A') {
+      // On gameMode (a)
+      if (gameMode == 'a') {
         self.help.x = self.correctX;
         self.help.y = 490;
-        // On gameMode B
+        // On gameMode (b)
       } else {
         self.help.x = self.circles.all[self.endIndex - 1].x;
         self.help.y =
@@ -617,7 +617,7 @@ const circleOne = {
     const y = game.math.getMouse(mouseEvent).y;
 
     // GAME MODE A : click road
-    if (gameMode == 'A') {
+    if (gameMode == 'a') {
       const cur = self.road;
 
       const valid =
@@ -628,7 +628,7 @@ const circleOne = {
     }
 
     // GAME MODE B : click circle
-    if (gameMode == 'B') {
+    if (gameMode == 'b') {
       self.circles.all.forEach((cur) => {
         const valid =
           game.math.distanceToPointer(x, cur.xWithAnchor, y, cur.yWithAnchor) <=
@@ -653,7 +653,7 @@ const circleOne = {
     let flag = false;
 
     // GAME MODE A : balloon follow mouse
-    if (gameMode == 'A' && !self.hasClicked) {
+    if (gameMode == 'a' && !self.hasClicked) {
       if (
         game.math.distanceToPointer(x, self.balloon.x, y, self.balloon.y) > 8
       ) {
@@ -665,7 +665,7 @@ const circleOne = {
     }
 
     // GAME MODE B : hover circle
-    if (gameMode == 'B' && !self.hasClicked) {
+    if (gameMode == 'b' && !self.hasClicked) {
       self.circles.all.forEach((cur) => {
         const valid =
           game.math.distanceToPointer(x, cur.xWithAnchor, y, cur.yWithAnchor) <=

+ 66 - 66
src/js/games/squareOne.js

@@ -6,11 +6,11 @@
  *
  * ..squareOne...	= gameName
  * ..../...\.....
- * ...A.....B.... = gameMode
+ * ...a.....b.... = gameMode
  * .....\./......
  * ......|.......
  * ...../.\......
- * .Plus...Minus. = gameOperation
+ * .plus...minus. = gameOperation
  * .....\./......
  * ......|.......
  * ....1,2,3..... = gameDifficulty
@@ -22,16 +22,16 @@
  *
  * Game modes can be :
  *
- *   A : Player can select # of 'floor blocks' (hole in the ground)
+ *   a : Player can select # of 'floor blocks' (hole in the ground)
  *       Selects size of hole to be made in the ground (to fill with the blocks in front of the truck)
- *   B : Player can select # of 'stacked blocks' (in front of the truck)
+ *   b : Player can select # of 'stacked blocks' (in front of the truck)
  *       Selects number of blocks in front of the truck (to fill the hole on the ground)
  *
  * Operations can be :
  *
- *   Plus : addition of fractions
+ *   plus : addition of fractions
  *     Represented by : tractor going to the right (floor positions 0..8)
- *   Minus : subtraction of fractions
+ *   minus : subtraction of fractions
  *     Represented by: tractor going to the left (floor positions 8..0)
  *
  * @namespace
@@ -51,7 +51,7 @@ const squareOne = {
 
     this.divisorsList = ''; // Hold the divisors for each fraction on stacked blocks (created for postScore())
 
-    this.direc_level = gameOperation == 'Minus' ? -1 : 1; // Will be multiplied to values to easily change tractor direction when needed
+    this.direc_level = gameOperation == 'minus' ? -1 : 1; // Will be multiplied to values to easily change tractor direction when needed
     this.animationSpeed = 2 * this.direc_level; // X distance in which the tractor moves in each iteration of the animation
 
     // GAME VARIABLES
@@ -59,7 +59,7 @@ const squareOne = {
     this.defaultBlockHeight = 40 * 1.5; // Base block height
 
     this.startX =
-      gameOperation == 'Minus' ? context.canvas.width - 170 * 1.5 : 170 * 1.5; // Initial 'x' coordinate for the tractor and stacked blocks
+      gameOperation == 'minus' ? context.canvas.width - 170 * 1.5 : 170 * 1.5; // Initial 'x' coordinate for the tractor and stacked blocks
     this.startY = context.canvas.height - 157 * 1.5 + 10;
 
     renderBackground();
@@ -92,7 +92,7 @@ const squareOne = {
     // TRACTOR
     this.tractor = game.add.sprite(this.startX, this.startY, 'tractor', 0, 1.2);
 
-    if (gameOperation == 'Plus') {
+    if (gameOperation == 'plus') {
       this.tractor.anchor(1, 0.5);
       this.tractor.animation = ['move', [0, 1, 2, 3, 4], 4];
     } else {
@@ -106,26 +106,26 @@ const squareOne = {
       blocks: [], // Group of 'stacked' block objects
       labels: [], // Group of fraction labels on the side of 'stacked' blocks
 
-      index: undefined, // (gameMode 'B') index of 'stacked' block selected by player
+      index: undefined, // (gameMode 'b') index of 'stacked' block selected by player
 
       // Control variables for animation
       curIndex: 0, // (needs to be 0)
       curBlockEnd: undefined,
 
       // Correct values
-      correctIndex: undefined, // (gameMode 'B') index of the CORRECT 'stacked' block
+      correctIndex: undefined, // (gameMode 'b') index of the CORRECT 'stacked' block
     };
 
     // FLOOR BLOCKS variables
     this.floor = {
       blocks: [], // Group of 'floor' block objects
-      index: undefined, // (gameMode 'A') index of 'floor' block selected by player
+      index: undefined, // (gameMode 'a') index of 'floor' block selected by player
 
       // Control variables for animation
       curIndex: -1, // (needs to be -1)
 
       // Correct values
-      correctIndex: undefined, // (gameMode 'A') index of the CORRECT 'floor' block
+      correctIndex: undefined, // (gameMode 'a') index of the CORRECT 'floor' block
       correctX: undefined, // 'x' coordinate of CORRECT 'floor' block
       correctXA: undefined, // Temporary variable
       correctXB: undefined, // Temporary variable
@@ -139,7 +139,7 @@ const squareOne = {
 
     // SELECTION ARROW
 
-    if (gameMode == 'A') {
+    if (gameMode == 'a') {
       this.arrow = game.add.image(
         this.startX + this.defaultBlockWidth * this.direc_level,
         this.startY + 35,
@@ -191,9 +191,9 @@ const squareOne = {
 
       // Check if block falls
       if (
-        (gameOperation == 'Plus' &&
+        (gameOperation == 'plus' &&
           stck.blocks[0].x >= stck.curBlockEnd + restOfCurBlock) ||
-        (gameOperation == 'Minus' &&
+        (gameOperation == 'minus' &&
           stck.blocks[0].x <= stck.curBlockEnd + restOfCurBlock)
       ) {
         let lowerBlock = true;
@@ -202,20 +202,20 @@ const squareOne = {
           stck.blocks[0].x +
           stck.blocks[stck.curIndex].width * self.direc_level;
 
-        // If current index is (A) last stacked index (correct index - fixed)
-        // If current index is (B) selected stacked index
+        // If current index is (a) last stacked index (correct index - fixed)
+        // If current index is (b) selected stacked index
         if (stck.curIndex == stck.index) {
-          // floor.index : (A) selected floor index
-          // floor.index : (B) last floor index (correct index - fixed)
+          // floor.index : (a) selected floor index
+          // floor.index : (b) last floor index (correct index - fixed)
           const selectedEnd =
             floor.blocks[floor.index].x +
             floor.blocks[0].width * self.direc_level;
 
-          // (A) last stacked block (fixed) doesnt fit selected gap AKA NOT ENOUGH FLOOR BLOCKS (DOESNT CHECK TOO MANY)
-          // (B) selected stacked index doesnt fit last floor gap (fixed) AKA TOO MANY STACKED BLOCKS (DOESNT CHECK NOT ENOUGH)
+          // (a) last stacked block (fixed) doesnt fit selected gap AKA NOT ENOUGH FLOOR BLOCKS (DOESNT CHECK TOO MANY)
+          // (b) selected stacked index doesnt fit last floor gap (fixed) AKA TOO MANY STACKED BLOCKS (DOESNT CHECK NOT ENOUGH)
           if (
-            (gameOperation == 'Plus' && curEnd > selectedEnd) ||
-            (gameOperation == 'Minus' && curEnd < selectedEnd)
+            (gameOperation == 'plus' && curEnd > selectedEnd) ||
+            (gameOperation == 'minus' && curEnd < selectedEnd)
           ) {
             lowerBlock = false;
           }
@@ -227,13 +227,13 @@ const squareOne = {
 
         // Fill floor gap
         if (lowerBlock) {
-          // Until (A) selected floor index
-          // Until (B) last floor index (correct index - fixed)
+          // Until (a) selected floor index
+          // Until (b) last floor index (correct index - fixed)
           // Updates floor index to be equivalent to stacked index (and change alpha so floor appears to be filled)
           for (let i = 0; i <= floor.index; i++) {
             if (
-              (gameOperation == 'Plus' && floor.blocks[i].x < curEnd) ||
-              (gameOperation == 'Minus' && floor.blocks[i].x > curEnd)
+              (gameOperation == 'plus' && floor.blocks[i].x < curEnd) ||
+              (gameOperation == 'minus' && floor.blocks[i].x > curEnd)
             ) {
               floor.blocks[i].alpha = 0.2;
               floor.curIndex = i;
@@ -263,7 +263,7 @@ const squareOne = {
 
       game.animation.stop(self.tractor.animation[0]);
 
-      if (gameMode == 'A') {
+      if (gameMode == 'a') {
         self.result = self.floor.index == self.floor.correctIndex;
       } else {
         self.result = self.stck.index == self.stck.correctIndex;
@@ -328,8 +328,8 @@ const squareOne = {
     if (!self.hasClicked) {
       document.body.style.cursor = 'pointer';
 
-      // On gameMode A
-      if (gameMode == 'A') {
+      // On gameMode (a)
+      if (gameMode == 'a') {
         for (let i in self.floor.blocks) {
           self.floor.blocks[i].alpha = i <= cur.index ? 1 : 0.5;
         }
@@ -337,7 +337,7 @@ const squareOne = {
         // Saves the index of the selected 'floor' block
         self.floor.index = cur.index;
 
-        // On gameMode B
+        // On gameMode (b)
       } else {
         for (let i in self.stck.blocks) {
           self.stck.blocks[i].alpha = i <= cur.index ? 0.5 : 0.2;
@@ -356,14 +356,14 @@ const squareOne = {
     if (!self.hasClicked) {
       document.body.style.cursor = 'auto';
 
-      // On game mode A
-      if (gameMode == 'A') {
+      // On game mode (a)
+      if (gameMode == 'a') {
         for (let i in self.floor.blocks) {
           self.floor.blocks[i].alpha = 0.5; // Back to normal
         }
 
         self.floor.index = -1;
-        // On game mode B
+        // On game mode (b)
       } else {
         for (let i in self.stck.blocks) {
           self.stck.blocks[i].alpha = 0.5; // Back to normal
@@ -381,8 +381,8 @@ const squareOne = {
     if (!self.hasClicked && !self.animateEnding) {
       document.body.style.cursor = 'auto';
 
-      // On gameMode A
-      if (gameMode == 'A') {
+      // On gameMode (a)
+      if (gameMode == 'a') {
         // Turns selection arrow completely visible
         self.arrow.alpha = 1;
 
@@ -394,7 +394,7 @@ const squareOne = {
 
         // (FIXED : self.STCK.index) save the 'stacked' blocks index
         self.stck.index = self.stck.blocks.length - 1;
-        // On gameMode B
+        // On gameMode (b)
       } else {
         for (let i in self.stck.blocks) {
           // (FIXED : self.STCK.index)
@@ -437,7 +437,7 @@ const squareOne = {
    */
   createStckBlocks: function () {
     let hasBaseDifficulty = false; // Will be true after next for loop if level has at least one '1/difficulty' fraction (if false, restart)
-    const max = gameMode == 'B' ? 10 : curMapPosition + 4; // Maximum number of stacked blocks for the level
+    const max = gameMode == 'b' ? 10 : curMapPosition + 4; // Maximum number of stacked blocks for the level
 
     const total = game.math.randomInRange(curMapPosition + 2, max); // Current number of stacked blocks for the level
 
@@ -456,7 +456,7 @@ const squareOne = {
       self.floor.correctXA += curBlockWidth * self.direc_level;
 
       // Create stacked block (close to tractor)
-      const lineColor = gameOperation == 'Minus' ? colors.red : colors.blueDark;
+      const lineColor = gameOperation == 'minus' ? colors.red : colors.blueDark;
       const lineSize = 2;
       const block = game.add.geom.rect(
         self.startX,
@@ -468,11 +468,11 @@ const squareOne = {
         colors.white,
         1
       );
-      const anchor = gameOperation == 'Minus' ? 1 : 0;
+      const anchor = gameOperation == 'minus' ? 1 : 0;
       block.anchor(anchor, 0);
 
-      // If game is type B, adding events to stacked blocks
-      if (gameMode == 'B') {
+      // If game mode is (b), adding events to stacked blocks
+      if (gameMode == 'b') {
         block.alpha = 0.5;
         block.index = i;
       }
@@ -527,10 +527,10 @@ const squareOne = {
     // Check for errors (level too easy for its difficulty or end position out of bounds)
     if (
       !hasBaseDifficulty ||
-      (gameOperation == 'Plus' &&
+      (gameOperation == 'plus' &&
         (self.floor.correctXA < self.startX + self.defaultBlockWidth ||
           self.floor.correctXA > self.startX + 8 * self.defaultBlockWidth)) ||
-      (gameOperation == 'Minus' &&
+      (gameOperation == 'minus' &&
         (self.floor.correctXA < self.startX - 8 * self.defaultBlockWidth ||
           self.floor.correctXA > self.startX - self.defaultBlockWidth))
     ) {
@@ -562,8 +562,8 @@ const squareOne = {
 
     const blockWidth = self.defaultBlockWidth / divisor; // Width of each floor block
 
-    // If game is type B, selectiong a random floor x position
-    if (gameMode == 'B') {
+    // If game is type (b), selectiong a random floor x position
+    if (gameMode == 'b') {
       self.stck.correctIndex = game.math.randomInRange(
         0,
         self.stck.blocks.length - 1
@@ -586,20 +586,20 @@ const squareOne = {
         self.startX +
         (self.defaultBlockWidth + i * blockWidth) * self.direc_level;
 
-      if (flag && gameMode == 'A') {
+      if (flag && gameMode == 'a') {
         if (
-          (gameOperation == 'Plus' && x >= self.floor.correctXA) ||
-          (gameOperation == 'Minus' && x <= self.floor.correctXA)
+          (gameOperation == 'plus' && x >= self.floor.correctXA) ||
+          (gameOperation == 'minus' && x <= self.floor.correctXA)
         ) {
           self.floor.correctIndex = i - 1; // Set index of correct floor block
           flag = false;
         }
       }
 
-      if (gameMode == 'B') {
+      if (gameMode == 'b') {
         if (
-          (gameOperation == 'Plus' && x >= self.floor.correctXB) ||
-          (gameOperation == 'Minus' && x <= self.floor.correctXB)
+          (gameOperation == 'plus' && x >= self.floor.correctXB) ||
+          (gameOperation == 'minus' && x <= self.floor.correctXB)
         ) {
           total = i;
           break;
@@ -618,11 +618,11 @@ const squareOne = {
         colors.blueBgInsideLevel,
         1
       );
-      const anchor = gameOperation == 'Minus' ? 1 : 0;
+      const anchor = gameOperation == 'minus' ? 1 : 0;
       block.anchor(anchor, 0);
 
-      // If game is type A, adding events to floor blocks
-      if (gameMode == 'A') {
+      // If game is type (a), adding events to floor blocks
+      if (gameMode == 'a') {
         block.alpha = 0.5;
         block.index = i;
       }
@@ -631,8 +631,8 @@ const squareOne = {
       self.floor.blocks.push(block);
     }
 
-    if (gameMode == 'A') self.floor.correctX = self.floor.correctXA;
-    else if (gameMode == 'B') self.floor.correctX = self.floor.correctXB;
+    if (gameMode == 'a') self.floor.correctX = self.floor.correctXA;
+    else if (gameMode == 'b') self.floor.correctX = self.floor.correctXB;
 
     // Creates labels on the floor to display the numbers
     for (let i = 1; i < 10; i++) {
@@ -651,12 +651,12 @@ const squareOne = {
    */
   viewHelp: function () {
     if (!self.hasClicked) {
-      // On gameMode A
-      if (gameMode == 'A') {
+      // On gameMode (a)
+      if (gameMode == 'a') {
         const aux = self.floor.blocks[0];
         self.help.x = self.floor.correctX - (aux.width / 2) * self.direc_level;
         self.help.y = 501;
-        // On gameMode B
+        // On gameMode (b)
       } else {
         const aux = self.stck.blocks[self.stck.correctIndex];
         self.help.x = aux.x + (aux.width / 2) * self.direc_level;
@@ -676,7 +676,7 @@ const squareOne = {
     const x = game.math.getMouse(mouseEvent).x;
     const y = game.math.getMouse(mouseEvent).y;
 
-    if (gameMode == 'A') {
+    if (gameMode == 'a') {
       self.floor.blocks.forEach((cur) => {
         if (game.math.isOverIcon(x, y, cur)) self.clickSquare(cur);
       });
@@ -702,7 +702,7 @@ const squareOne = {
     let flagA = false;
     let flagB = false;
 
-    if (gameMode == 'A') {
+    if (gameMode == 'a') {
       // Make arrow follow mouse
       if (!self.hasClicked && !self.animateEnding) {
         if (game.math.distanceToPointer(self.arrow.x, x, self.arrow.y, y) > 8) {
@@ -717,10 +717,10 @@ const squareOne = {
         }
       });
 
-      if (!flagA) self.outSquare('A');
+      if (!flagA) self.outSquare('a');
     }
 
-    if (gameMode == 'B') {
+    if (gameMode == 'b') {
       self.stck.blocks.forEach((cur) => {
         if (game.math.isOverIcon(x, y, cur)) {
           flagB = true;
@@ -728,7 +728,7 @@ const squareOne = {
         }
       });
 
-      if (!flagB) self.outSquare('B');
+      if (!flagB) self.outSquare('b');
     }
 
     navigationIcons.onInputOver(x, y);

+ 81 - 81
src/js/games/squareTwo.js

@@ -6,10 +6,10 @@
  *
  * .squareTwo. = gameName
  * .../...\...
- * ..A.....B.. = gameMode
+ * ..a.....b.. = gameMode
  * ....\./....
  * .....|.....
- * ...Equals.. = gameOperation
+ * ...minus.. = gameOperation
  * .....|.....
  * .1,2,3,4,5. = gameDifficulty
  *
@@ -20,14 +20,14 @@
  *
  * Game modes can be :
  *
- *   A : equivalence of fractions
+ *   a : equivalence of fractions
  *       top has more subdivisions
- *   B : equivalence of fractions
+ *   b : equivalence of fractions
  *       bottom has more subdivisions
  *
  * Operations :
  *
- *   Equals : Player selects equivalent fractions of both blocks
+ *   minus : Player selects equivalent fractions of both blocks
  *
  * @namespace
  */
@@ -42,18 +42,18 @@ const squareTwo = {
     this.delay = 0; // Counter for game dalays
     this.endLevel = false;
 
-    this.A = {
+    this.a = {
       blocks: [], // List of selection blocks
       auxBlocks: [], // List of shadow under selection blocks
       fractions: [], // Fraction numbers
-      selected: 0, // Number of selected blocks for A
-      hasClicked: false, // Check if player clicked blocks from A
-      animate: false, // Animate blocks from A
+      selected: 0, // Number of selected blocks for (a)
+      hasClicked: false, // Check if player clicked blocks from (a)
+      animate: false, // Animate blocks from (a)
       warningText: undefined,
       label: undefined,
     };
 
-    this.B = {
+    this.b = {
       blocks: [],
       auxBlocks: [],
       fractions: [],
@@ -102,27 +102,27 @@ const squareTwo = {
     );
     this.kidAnimation.anchor(0.5, 0.7);
 
-    // Width and Height of A and B
+    // Width and Height of (a) and (b)
     this.figureWidth = 400 * 1.5;
     const figureHeight = 50 * 1.5;
 
-    // Coordinates for A and B
+    // Coordinates for (a) and (b)
     let xA, xB, yA, yB;
-    if (gameMode != 'B') {
-      // More subdivisions on B
+    if (gameMode != 'b') {
+      // More subdivisions on (b)
       xA = context.canvas.width / 2 - this.figureWidth / 2;
       yA = gameFrame().y;
       xB = xA;
       yB = yA + 3 * figureHeight + 30;
     } else {
-      // More subdivisions on A
+      // More subdivisions on (a)
       xB = context.canvas.width / 2 - this.figureWidth / 2;
       yB = gameFrame().y;
       xA = xB;
       yA = yB + 3 * figureHeight + 30;
     }
 
-    // Possible points for A
+    // Possible points for (a)
     const points = [2, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20];
 
     // Random index for 'points'
@@ -131,7 +131,7 @@ const squareTwo = {
       (gameDifficulty - 1) * 2 + 3
     );
 
-    // Number of subdivisions of A and B (blocks)
+    // Number of subdivisions of (a) and (b) (blocks)
     const totalBlocksA = points[randomIndex];
     const totalBlocksB = game.math.randomDivisor(totalBlocksA);
 
@@ -146,15 +146,15 @@ const squareTwo = {
           ', max index: ' +
           ((gameDifficulty - 1) * 2 + 3) +
           ')' +
-          '\ntotal blocks A: ' +
+          '\ntotal blocks a: ' +
           totalBlocksA +
-          ', total blocks B: ' +
+          ', total blocks b: ' +
           totalBlocksB
       );
     }
 
-    // CREATING TOP FIGURE (A)
-    let blockWidth = this.figureWidth / totalBlocksA; // Width of each block in A
+    // CREATING TOP FIGURE (a)
+    let blockWidth = this.figureWidth / totalBlocksA; // Width of each block in (a)
     let lineColor = colors.redDark;
     let fillColor = colors.redLight;
 
@@ -173,15 +173,15 @@ const squareTwo = {
         fillColor,
         0.5
       );
-      block.figure = 'A';
+      block.figure = 'a';
       block.index = i;
       block.finalX = xA;
-      this.A.blocks.push(block);
+      this.a.blocks.push(block);
 
       // Auxiliar blocks
       const alpha = fractionLabel ? 0.1 : 0;
 
-      const yAux = yA + figureHeight + 10; // On the bottom of A
+      const yAux = yA + figureHeight + 10; // On the bottom of (a)
       const auxBlock = game.add.geom.rect(
         x,
         yAux,
@@ -192,47 +192,47 @@ const squareTwo = {
         fillColor,
         alpha
       );
-      this.A.auxBlocks.push(auxBlock);
+      this.a.auxBlocks.push(auxBlock);
     }
 
-    // 'total blocks' label for A : on the side of A
+    // 'total blocks' label for (a) : on the side of (a)
     let xLabel = xA + this.figureWidth + 30;
     let yLabel = yA + figureHeight / 2;
 
-    this.A.label = game.add.text(
+    this.a.label = game.add.text(
       xLabel,
       yLabel,
-      this.A.blocks.length,
+      this.a.blocks.length,
       textStyles.h4_blueDark
     );
 
-    // 'selected blocks/fraction' label for A : at the bottom of A
+    // 'selected blocks/fraction' label for (a) : at the bottom of (a)
     yLabel = yA + figureHeight + 34;
 
-    this.A.fractions[0] = game.add.text(
+    this.a.fractions[0] = game.add.text(
       xLabel,
       yLabel,
       '',
       textStyles.h4_blueDark
     );
-    this.A.fractions[1] = game.add.text(
+    this.a.fractions[1] = game.add.text(
       xLabel,
       yLabel + 21,
       '',
       textStyles.h4_blueDark
     );
-    this.A.fractions[2] = game.add.text(
+    this.a.fractions[2] = game.add.text(
       xLabel,
       yLabel,
       '___',
       textStyles.h4_blueDark
     );
-    this.A.fractions[0].alpha = 0;
-    this.A.fractions[1].alpha = 0;
-    this.A.fractions[2].alpha = 0;
+    this.a.fractions[0].alpha = 0;
+    this.a.fractions[1].alpha = 0;
+    this.a.fractions[2].alpha = 0;
 
-    // CREATING BOTTOM FIGURE (B)
-    blockWidth = this.figureWidth / totalBlocksB; // Width of each block in B
+    // CREATING BOTTOM FIGURE (b)
+    blockWidth = this.figureWidth / totalBlocksB; // Width of each block in (b)
     lineColor = colors.greenDark;
     fillColor = colors.greenLight;
 
@@ -251,14 +251,14 @@ const squareTwo = {
         fillColor,
         0.5
       );
-      block.figure = 'B';
+      block.figure = 'b';
       block.index = i;
       block.finalX = xB;
-      this.B.blocks.push(block);
+      this.b.blocks.push(block);
 
       // Auxiliar blocks
       const alpha = fractionLabel ? 0.1 : 0;
-      const yAux = yB + figureHeight + 10; // On the bottom of B
+      const yAux = yB + figureHeight + 10; // On the bottom of (b)
       const auxBlock = game.add.geom.rect(
         x,
         yAux,
@@ -269,53 +269,53 @@ const squareTwo = {
         fillColor,
         alpha
       );
-      this.B.auxBlocks.push(auxBlock);
+      this.b.auxBlocks.push(auxBlock);
     }
 
-    // Label block B
+    // Label block (b)
     xLabel = xB + this.figureWidth + 30;
     yLabel = yB + figureHeight / 2;
 
-    this.B.label = game.add.text(
+    this.b.label = game.add.text(
       xLabel,
       yLabel,
-      this.B.blocks.length,
+      this.b.blocks.length,
       textStyles.h4_blueDark
     );
 
     // Label fraction
     yLabel = yB + figureHeight + 34;
 
-    this.B.fractions[0] = game.add.text(
+    this.b.fractions[0] = game.add.text(
       xLabel,
       yLabel,
       '',
       textStyles.h4_blueDark
     );
-    this.B.fractions[1] = game.add.text(
+    this.b.fractions[1] = game.add.text(
       xLabel,
       yLabel + 21,
       '',
       textStyles.h4_blueDark
     );
-    this.B.fractions[2] = game.add.text(
+    this.b.fractions[2] = game.add.text(
       xLabel,
       yLabel,
       '___',
       textStyles.h4_blueDark
     );
-    this.B.fractions[0].alpha = 0;
-    this.B.fractions[1].alpha = 0;
-    this.B.fractions[2].alpha = 0;
+    this.b.fractions[0].alpha = 0;
+    this.b.fractions[1].alpha = 0;
+    this.b.fractions[2].alpha = 0;
 
     // Invalid selection text
-    this.A.warningText = game.add.text(
+    this.a.warningText = game.add.text(
       context.canvas.width / 2,
       context.canvas.height / 2 - 225,
       '',
       textStyles.h4_brown
     );
-    this.B.warningText = game.add.text(
+    this.b.warningText = game.add.text(
       context.canvas.width / 2,
       context.canvas.height / 2 - 45,
       '',
@@ -333,8 +333,8 @@ const squareTwo = {
    */
   update: function () {
     // Animate blocks
-    if (self.A.animate || self.B.animate) {
-      ['A', 'B'].forEach((cur) => {
+    if (self.a.animate || self.b.animate) {
+      ['a', 'b'].forEach((cur) => {
         if (self[cur].animate) {
           // Lower selected blocks
           for (let i = 0; i < self[cur].selected; i++) {
@@ -350,16 +350,16 @@ const squareTwo = {
       });
     }
 
-    // If A and B are already clicked
-    if (self.A.hasClicked && self.B.hasClicked && !self.endLevel) {
+    // If (a) and (b) are already clicked
+    if (self.a.hasClicked && self.b.hasClicked && !self.endLevel) {
       game.timer.stop();
       self.delay++;
 
       // After delay is over, check result
       if (self.delay > 50) {
         self.result =
-          self.A.selected / self.A.blocks.length ==
-          self.B.selected / self.B.blocks.length;
+          self.a.selected / self.a.blocks.length ==
+          self.b.selected / self.b.blocks.length;
 
         // Fractions are equivalent : CORRECT
         if (self.result) {
@@ -405,16 +405,16 @@ const squareTwo = {
   /**
    * Function called by self.onInputOver() when cursor is over a valid rectangle.
    *
-   * @param {object} curBlock rectangle the cursor is over : can be self.A.blocks[i] or self.B.blocks[i]
+   * @param {object} curBlock rectangle the cursor is over : can be self.a.blocks[i] or self.b.blocks[i]
    */
   overSquare: function (curBlock) {
-    const curSet = curBlock.figure; // 'A' || 'B'
+    const curSet = curBlock.figure; // 'a' || 'b'
 
     if (!self[curSet].hasClicked) {
-      // self.A.hasClicked || self.B.hasClicked
+      // self.a.hasClicked || self.b.hasClicked
       // If over fraction 'n/n' shows warning message not allowing it
       if (curBlock.index == self[curSet].blocks.length - 1) {
-        const otherSet = curSet == 'A' ? 'B' : 'A';
+        const otherSet = curSet == 'a' ? 'b' : 'a';
 
         self[curSet].warningText.name = game.lang.s2_error_msg;
         self[otherSet].warningText.name = '';
@@ -423,8 +423,8 @@ const squareTwo = {
       } else {
         document.body.style.cursor = 'pointer';
 
-        self.A.warningText.name = '';
-        self.B.warningText.name = '';
+        self.a.warningText.name = '';
+        self.b.warningText.name = '';
 
         // Selected blocks become fully visible
         for (let i in self[curSet].blocks) {
@@ -451,7 +451,7 @@ const squareTwo = {
   /**
    * Function called (by self.onInputOver() and self.overSquare()) when cursor is out of a valid rectangle.
    *
-   * @param {object} curSet set of rectangles : can be top (self.A) or bottom (self.B)
+   * @param {object} curSet set of rectangles : can be top (self.a) or bottom (self.b)
    */
   outSquare: function (curSet) {
     if (!self[curSet].hasClicked) {
@@ -468,10 +468,10 @@ const squareTwo = {
   /**
    * Function called by self.onInputDown() when player clicked a valid rectangle.
    *
-   * @param {object} curBlock clicked rectangle : can be self.A.blocks[i] or self.B.blocks[i]
+   * @param {object} curBlock clicked rectangle : can be self.a.blocks[i] or self.b.blocks[i]
    */
   clickSquare: function (curBlock) {
-    const curSet = curBlock.figure; // 'A' || 'B'
+    const curSet = curBlock.figure; // 'a' || 'b'
 
     if (
       !self[curSet].hasClicked &&
@@ -521,13 +521,13 @@ const squareTwo = {
     const x = game.math.getMouse(mouseEvent).x;
     const y = game.math.getMouse(mouseEvent).y;
 
-    // Click block in A
-    self.A.blocks.forEach((cur) => {
+    // Click block in (a)
+    self.a.blocks.forEach((cur) => {
       if (game.math.isOverIcon(x, y, cur)) self.clickSquare(cur);
     });
 
-    // Click block in B
-    self.B.blocks.forEach((cur) => {
+    // Click block in (b)
+    self.b.blocks.forEach((cur) => {
       if (game.math.isOverIcon(x, y, cur)) self.clickSquare(cur);
     });
 
@@ -548,23 +548,23 @@ const squareTwo = {
     let flagA = false;
     let flagB = false;
 
-    // Mouse over A : show fraction
-    self.A.blocks.forEach((cur) => {
+    // Mouse over (a) : show fraction
+    self.a.blocks.forEach((cur) => {
       if (game.math.isOverIcon(x, y, cur)) {
         flagA = true;
         self.overSquare(cur);
       }
     });
-    if (!flagA) self.outSquare('A');
+    if (!flagA) self.outSquare('a');
 
-    // Mouse over B : show fraction
-    self.B.blocks.forEach((cur) => {
+    // Mouse over (b) : show fraction
+    self.b.blocks.forEach((cur) => {
       if (game.math.isOverIcon(x, y, cur)) {
         flagB = true;
         self.overSquare(cur);
       }
     });
-    if (!flagB) self.outSquare('B');
+    if (!flagB) self.outSquare('b');
 
     if (!flagA && !flagB) document.body.style.cursor = 'auto';
 
@@ -599,13 +599,13 @@ const squareTwo = {
       game.timer.elapsed +
       '&line_deta=' +
       'numBlocksA: ' +
-      self.A.blocks.length +
+      self.a.blocks.length +
       ', valueA: ' +
-      self.A.selected +
+      self.a.selected +
       ', numBlocksB: ' +
-      self.B.blocks.length +
+      self.b.blocks.length +
       ', valueB: ' +
-      self.B.selected;
+      self.b.selected;
 
     // FOR MOODLE
     sendToDatabase(data);

+ 7 - 7
src/js/globals/globals_control.js

@@ -9,12 +9,12 @@
  * .........../...........\....................|........ } = gameName (game)
  * ........One.............Two................One....... }
  * ......./...\.........../...\............./....\......
- * ......A.....B.........A.....B...........A......B..... = gameMode (game mode)
+ * ......a.....b.........a.....b...........a......b..... = gameMode (game mode)
  * .(floor)..(stack)..(top)..(bottom)..(floor)..(stack).
  * .......\./.............\./................\./........
  * ........|...............|..................|.........
  * ......./.\..............|................/.|.\.......
- * ...Plus...Minus.......Equals........Plus.Minus.Mixed. = gameOperation (game math operation)
+ * ...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)
@@ -65,8 +65,8 @@ let gameShape;
 
 /**
  * Holds selected game mode.<br>
- * In squareOne/circleOne   can be: 'A' (click on the floor) or 'B' (click on the amount to go/stacked figures).<br>
- * In squareTwo             can be: 'A' (more subdivisions on top) or 'B' (more subdivisions on bottom).
+ * In squareOne/circleOne   can be: 'a' (click on the floor) or 'b' (click on the amount to go/stacked figures).<br>
+ * In squareTwo             can be: 'a' (more subdivisions on top) or 'b' (more subdivisions on bottom).
  *
  * @type {string}
  */
@@ -74,9 +74,9 @@ let gameMode;
 
 /**
  * Holds game math operation.<br>
- * In squareOne   can be: 'Plus' (green tractor goes right) or 'Minus' (red tractor goes left).<br>
- * In circleOne   can be: 'Plus' (green tractor goes right), 'Minus' (red tractor goes left) or 'Mixed' (green tractor goes both sides).<br>
- * In squareTwo   can be: 'Equals' (compares two rectangle subdivisions).
+ * In squareOne   can be: 'plus' (green tractor goes right) or 'minus' (red tractor goes left).<br>
+ * In circleOne   can be: 'plus' (green tractor goes right), 'minus' (red tractor goes left) or 'mixed' (green tractor goes both sides).<br>
+ * In squareTwo   can be: 'minus' (compares two rectangle subdivisions).
  *
  * @type {string}
  */

+ 1 - 1
src/js/globals/globals_debug.js

@@ -7,7 +7,7 @@ const debugState = {
   customMenu: {
     status: false,
     getData: () => {
-      return { mode: 'A', operation: 'Plus', difficulty: 1, label: true };
+      return { mode: 'a', operation: 'plus', difficulty: 1, label: true };
     },
   },
   map: { status: false, stop: false },

+ 16 - 25
src/js/globals/globals_tokens.js

@@ -7,13 +7,11 @@ const baseUrl = 'src/assets/img/'; // Base directory for media
 const gameList = [
   {
     gameName: 'squareOne',
-    gameMode: ['A', 'B'],
-    gameOperation: ['Plus', 'Minus'],
+    gameMode: ['a', 'b'],
+    gameOperation: ['plus', 'minus'],
     gameDifficulty: 3,
-
     // info
     gameShape: 'square',
-
     assets: {
       gameNameBtn: 'game0',
       gameModeBtn: ['mode0', 'mode1'],
@@ -25,7 +23,7 @@ const gameList = [
       },
       mapCharacter: (operation) => {
         let char;
-        if (operation == 'Plus') {
+        if (operation == 'plus') {
           char = game.add.sprite(
             self.points.x[curMapPosition],
             self.points.y[curMapPosition],
@@ -34,7 +32,7 @@ const gameList = [
             0.75
           );
         }
-        if (operation === 'Minus') {
+        if (operation === 'minus') {
           char = game.add.sprite(
             self.points.x[curMapPosition],
             self.points.y[curMapPosition],
@@ -56,14 +54,14 @@ const gameList = [
           .image(self.points.x[5], self.points.y[5], 'farm', 0.9)
           .anchor(0.4, 0.7);
       },
-      endCharacterAnimation: () =>
-        animation === 'Plus'
+      endCharacterAnimation: (animation) =>
+        animation === 'plus'
           ? ['move', [0, 1, 2, 3, 4], 4]
           : ['move', [10, 11, 12, 13, 14], 4],
       endCharacter: (operation) => {
         const char = game.add.sprite(0, 490, 'tractor', 0, 0.7);
         char.anchor(0.5, 0.5);
-        if (operation === 'Plus') char.curFrame = 10;
+        if (operation === 'plus') char.curFrame = 10;
         return char;
       },
       endBuilding: () => game.add.image(650, 260, 'farm', 1.1),
@@ -71,13 +69,11 @@ const gameList = [
   },
   {
     gameName: 'circleOne',
-    gameMode: ['A', 'B'],
-    gameOperation: ['Plus', 'Minus', 'Mixed'],
+    gameMode: ['a', 'b'],
+    gameOperation: ['plus', 'minus', 'mixed'],
     gameDifficulty: 5,
-
     // info
     gameShape: 'circle',
-
     assets: {
       gameNameBtn: 'game1',
       gameModeBtn: ['mode2', 'mode3'],
@@ -86,7 +82,7 @@ const gameList = [
         'operation_minus',
         'operation_mixed',
       ],
-      mapCharacterAnimation: () => {
+      mapCharacterAnimation: (operation) => {
         return ['kid', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3];
       },
       mapCharacter: () => {
@@ -122,12 +118,10 @@ const gameList = [
     },
   },
   {
-    // game data
     gameName: 'squareTwo',
-    gameMode: ['A', 'B'],
-    gameOperation: ['Equals'],
+    gameMode: ['a', 'b'],
+    gameOperation: ['minus'],
     gameDifficulty: 5,
-
     // info
     gameShape: 'square',
     assets: {
@@ -170,15 +164,12 @@ const gameList = [
     },
   },
   {
-    // game data
     gameName: 'scaleOne',
-    gameMode: ['A'],
-    gameOperation: ['Plus'],
+    gameMode: ['a'],
+    gameOperation: ['plus'],
     gameDifficulty: 1,
-
     // info
     gameShape: 'noShape',
-
     assets: {
       gameNameBtn: 'game3',
       gameModeBtn: ['mode6'],
@@ -190,7 +181,7 @@ const gameList = [
       },
       mapCharacter: (operation) => {
         let char;
-        if (operation == 'Plus') {
+        if (operation == 'plus') {
           char = game.add.sprite(
             self.points.x[curMapPosition],
             self.points.y[curMapPosition],
@@ -199,7 +190,7 @@ const gameList = [
             0.75
           );
         }
-        if (operation === 'Minus') {
+        if (operation === 'minus') {
           char = game.add.sprite(
             self.points.x[curMapPosition],
             self.points.y[curMapPosition],

+ 6 - 6
src/js/menus/menu_custom.js

@@ -458,9 +458,9 @@ const customMenuState = {
           title: '<b>' + game.lang.game_modes + '</b>',
           body: game.lang.infoBox_mode,
           img:
-            '<table> <tr> <td> <b>A)</b> ' +
+            '<table> <tr> <td> <b>a)</b> ' +
             game.lang.infoBox_mode_s1_A +
-            ' </td> <td> <b>B)</b> ' +
+            ' </td> <td> <b>b)</b> ' +
             game.lang.infoBox_mode_s1_B +
             ' </td> </tr> <tr> <td> <img width=100% src="' +
             game.image['s1-A-h'].src +
@@ -476,12 +476,12 @@ const customMenuState = {
             '<table> <tr style="border-bottom: 5px solid white"> <td width=70%> <img width=100% src="' +
             game.image['c1-A-h'].src +
             '">' +
-            ' </td> <td> &nbsp; <b>A)</b> ' +
+            ' </td> <td> &nbsp; <b>a)</b> ' +
             game.lang.infoBox_mode_c1_A +
             ' </td> </tr> </tr> <td> <img width=100% src="' +
             game.image['c1-B-h'].src +
             '"> ' +
-            ' </td> <td> &nbsp; <b>B)</b> ' +
+            ' </td> <td> &nbsp; <b>b)</b> ' +
             game.lang.infoBox_mode_c1_B +
             '</td> </tr> <table>',
         },
@@ -489,9 +489,9 @@ const customMenuState = {
           title: '<b>' + game.lang.game_modes + '</b>',
           body: game.lang.infoBox_mode,
           img:
-            '<table> <tr> <td> <b>A)</b> ' +
+            '<table> <tr> <td> <b>a)</b> ' +
             game.lang.infoBox_mode_s2_A +
-            ' </td> <td> <b>B)</b> ' +
+            ' </td> <td> <b>b)</b> ' +
             game.lang.infoBox_mode_s2_B +
             ' </td> </tr> <tr> <td> <img width=98% src="' +
             game.image['s2-A-h'].src +

+ 1 - 1
src/php/save.php

@@ -50,7 +50,7 @@ if ($conn->connect_error) {
 $ip = clientIP();
 
 // /js/globals.js: data = line_ip=120.0.0.1&line_name=name&line_lang=pt_BR
-// /js/squareOne.js: data += &line_game=Square&line_mode=A&line_oper=Plus&line_leve=1&line_posi=1&line_resu=true&line_time=3&line_deta=numBlocks:3, valBlocks: 1,1,1, blockIndex: 2, floorIndex: 2;url=php/save.php
+// /js/squareOne.js: data += &line_game=Square&line_mode=a&line_oper=Plus&line_leve=1&line_posi=1&line_resu=true&line_time=3&line_deta=numBlocks:3, valBlocks: 1,1,1, blockIndex: 2, floorIndex: 2;url=php/save.php
 $name = $_REQUEST["line_name"];
 $date = date("Y-m-d H:i:s");
 $lang = $_REQUEST["line_lang"];