Sfoglia il codice sorgente

refactor: update code for retrocompatibility

lairaalmas 1 anno fa
parent
commit
35f4563750
2 ha cambiato i file con 11 aggiunte e 5 eliminazioni
  1. 5 4
      js/gameMechanics.js
  2. 6 1
      js/menus/menu_main.js

+ 5 - 4
js/gameMechanics.js

@@ -122,7 +122,7 @@ const game = {
       } else {
         self.create(); // Calls create()
         game.render.all(); // After create() ends, renders media on canvas
-        if (self?.restart) {
+        if (self && self.restart) {
           // If needed, restart state
           game.state.start(game.state.name);
         } else {
@@ -510,9 +510,10 @@ const game = {
       } else {
         const med = {
           typeOfMedia: 'text',
-          name: style?.increaseLetterSpacing
-            ? text.split('').join(String.fromCharCode(8202))
-            : text,
+          name:
+            style && style.increaseLetterSpacing
+              ? text.split('').join(String.fromCharCode(8202))
+              : text,
 
           x: x || game.add.default.x,
           y: y || game.add.default.y,

+ 6 - 1
js/menus/menu_main.js

@@ -131,7 +131,12 @@ const menuState = {
    * Displays game menu information boxes.
    */
   showInfoBox: function (icon) {
-    if (gameList?.[icon.id]?.assets?.menu?.infoBox) {
+    if (
+      gameList[icon.id] &&
+      gameList[icon.id].assets &&
+      gameList[icon.id].assets.menu &&
+      gameList[icon.id].assets.menu.infoBox
+    ) {
       self.infoBox.style.display = 'block';
 
       const data = gameList[icon.id].assets.menu.infoBox();