Pārlūkot izejas kodu

rename and refactor 'info' token to 'metadata'

lairaalmas 1 gadu atpakaļ
vecāks
revīzija
6dce079c21

+ 42 - 23
src/js/globals/globals_tokens.js

@@ -4,29 +4,35 @@ const baseUrl = 'src/assets/img/'; // Base directory for media
  * Metadata for all games
  * @type {object}
  */
-const info = {
+const metadata = {
   all: {
     squareOne: {
+      // game data
       gameName: 'squareOne',
       gameMode: ['A', 'B'],
       gameOperation: ['Plus', 'Minus'],
       gameDifficulty: 3,
 
+      // info
       gameShape: 'square',
 
+      // menu icons data
       gameNameIconName: 'game0',
       gameModeIconName: ['mode0', 'mode1'],
       gameOperationIconName: ['operation_plus', 'operation_minus'],
     },
 
     circleOne: {
+      // game data
       gameName: 'circleOne',
       gameMode: ['A', 'B'],
       gameOperation: ['Plus', 'Minus', 'Mixed'],
       gameDifficulty: 5,
 
+      // info
       gameShape: 'circle',
 
+      // menu icons data
       gameNameIconName: 'game1',
       gameModeIconName: ['mode2', 'mode3'],
       gameOperationIconName: [
@@ -37,51 +43,64 @@ const info = {
     },
 
     squareTwo: {
-      gameShape: 'square',
+      // game data
       gameName: 'squareTwo',
-      gameNameIconName: 'game2',
       gameMode: ['A', 'B'],
-      gameModeIconName: ['mode4', 'mode5'],
       gameOperation: ['Equals'],
-      gameOperationIconName: ['operation_equals'],
       gameDifficulty: 5,
+
+      // info
+      gameShape: 'square',
+
+      // menu icon data
+      gameOperationIconName: ['operation_equals'],
+      gameNameIconName: 'game2',
+      gameModeIconName: ['mode4', 'mode5'],
     },
 
     scaleOne: {
+      // game data
       gameName: 'scaleOne',
       gameMode: ['A'],
       gameOperation: ['Plus'],
       gameDifficulty: 5,
 
-      gameShape: 'scale',
+      // info
+      gameShape: 'noShape',
 
+      // menu icon data
       gameNameIconName: 'game0',
       gameModeIconName: ['mode0'],
       gameOperationIconName: ['operation_plus'],
     },
   },
-  gameShape: [],
-  gameName: [],
-  gameMode: [],
-  gameOperation: [],
-  gameDifficulty: [],
+  gameNames: [],
+  // gameModes: [],
+  // gameOperations: [],
+  // gameDifficulties: [],
 
-  gameNameIconName: [],
-  gameModeIconName: [],
-  gameOperationIconName: [],
+  gameShapes: [],
+
+  gameNameIconNames: [],
+  // gameModeIconNames: [],
+  // gameOperationIconNames: [],
 };
 
 // Called once when the game starts
 (function () {
-  for (key in info.all) {
-    info.gameShape.push(info.all[key].gameShape);
-    info.gameName.push(info.all[key].gameName);
-    info.gameNameIconName.push(info.all[key].gameNameIconName);
-    info.gameMode.push(info.all[key].gameMode);
-    info.gameModeIconName.push(info.all[key].gameMode);
-    info.gameOperation.push(info.all[key].gameOperation);
-    info.gameOperationIconName.push(info.all[key].gameOperationIconName);
-    info.gameDifficulty.push(info.all[key].gameDifficulty);
+  for (key in metadata.all) {
+    metadata.gameNames.push(metadata.all[key].gameName);
+    // metadata.gameModes.push(metadata.all[key].gameMode);
+    // metadata.gameOperations.push(metadata.all[key].gameOperation);
+    // metadata.gameDifficulties.push(metadata.all[key].gameDifficulty);
+
+    metadata.gameShapes.push(metadata.all[key].gameShape);
+
+    metadata.gameNameIconNames.push(metadata.all[key].gameNameIconName);
+    // metadata.gameModeIconNames.push(metadata.all[key].gameMode);
+    // metadata.gameOperationIconNames.push(
+    //   metadata.all[key].gameOperationIconName
+    // );
   }
 })();
 

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

@@ -45,7 +45,7 @@ const customMenuState = {
       // Loads navigation icons
       navigationIcons.add(true, false, false, true, true, 'menu', false);
 
-      const curGame = info.all[gameName];
+      const curGame = metadata.all[gameName];
 
       this.menuIcons = [];
 

+ 10 - 6
src/js/menus/menu_main.js

@@ -58,20 +58,24 @@ const menuState = {
 
       const offset = game.math.getOffset(
         context.canvas.width,
-        info.gameName.length
+        metadata.gameNames.length
       );
 
-      for (let i = 0, x = offset; i < info.gameName.length; i++, x += offset) {
+      for (
+        let i = 0, x = offset;
+        i < metadata.gameNames.length;
+        i++, x += offset
+      ) {
         const icon = game.add.image(
           x,
           context.canvas.height / 2 - 70,
-          info.gameNameIconName[i],
+          metadata.gameNameIconNames[i],
           1.5
         );
         icon.anchor(0.5, 0.5);
 
-        icon.gameShape = info.gameShape[i];
-        icon.gameName = info.gameName[i];
+        icon.gameShape = metadata.gameShapes[i];
+        icon.gameName = metadata.gameNames[i];
         icon.iconType = 'game';
 
         this.menuIcons.push(icon);
@@ -195,7 +199,7 @@ const menuState = {
       case 'game':
         gameShape = icon.gameShape;
         gameName = icon.gameName;
-        if (!info.gameName.includes(gameName))
+        if (!metadata.gameNames.includes(gameName))
           console.error('Game error: the name of the game is not valid.');
         self.menuIcons = self.lbl_game.name;
         game.state.start('customMenu');

+ 6 - 1
src/js/moodle/studentReport.js

@@ -30,7 +30,12 @@ const studentReport = {
       game.lang.results,
       textStyles.h1_green
     );
-    game.add.image(x - 40, y - 70, info.all[gameName].gameNameIconName, 0.8);
+    game.add.image(
+      x - 40,
+      y - 70,
+      metadata.all[gameName].gameNameIconName,
+      0.8
+    );
 
     // Game info
     text =