From 295065fcff38b88ad7f9943f89b8d329d0e5a5b8 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Tue, 4 Feb 2025 17:06:07 +0800 Subject: [PATCH 01/17] Bump phaser v3.55.2 to 3.87.0 --- package.json | 8 +++++--- src/features/game/input/GameInputManager.ts | 6 +++--- yarn.lock | 18 +++++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 82fadd2c5e..0afa9fd1c2 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "mdast-util-from-markdown": "^2.0.0", "mdast-util-to-hast": "^13.0.0", "normalize.css": "^8.0.1", - "phaser": "^3.55.2", + "phaser": "^3.87.0", "query-string": "^9.0.0", "re-resizable": "^6.9.9", "react": "^18.3.1", @@ -100,6 +100,7 @@ "yareco": "^0.1.5" }, "devDependencies": { + "//": "See: https://github.com/facebook/react/issues/28313#issuecomment-2076798972, https://github.com/t3-oss/create-t3-turbo/issues/984#issuecomment-2076413457", "@babel/core": "^7.24.5", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-typescript": "^7.24.1", @@ -138,7 +139,6 @@ "cross-env": "^7.0.3", "eslint": "^9.9.0", "eslint-plugin-react": "^7.35.0", - "//": "See: https://github.com/facebook/react/issues/28313#issuecomment-2076798972, https://github.com/t3-oss/create-t3-turbo/issues/984#issuecomment-2076413457", "eslint-plugin-react-hooks": "5.1.0-canary-cb151849e1-20240424", "eslint-plugin-react-refresh": "^0.4.9", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -146,6 +146,7 @@ "husky": "^9.0.0", "npm-run-all2": "^7.0.0", "os-browserify": "^0.3.0", + "path": "^0.12.7", "path-browserify": "^1.0.1", "prettier": "^3.3.3", "process": "^0.11.10", @@ -177,5 +178,6 @@ "last 1 firefox version", "last 1 safari version" ] - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/src/features/game/input/GameInputManager.ts b/src/features/game/input/GameInputManager.ts index 2ab78d792a..fff21fcfa7 100644 --- a/src/features/game/input/GameInputManager.ts +++ b/src/features/game/input/GameInputManager.ts @@ -32,7 +32,7 @@ class GameInputManager { * @param active if true, mouse input is enabled. Else, mouse input is disabled. */ public enableMouseInput(active: boolean) { - this.scene.input.mouse.enabled = active; + this.scene.input.mouse!.enabled = active; // ! to convince typescript Mouse Manager exists } /** @@ -41,7 +41,7 @@ class GameInputManager { * @param active if true, keyboard input is enabled. Else, keyboard input is disabled. */ public enableKeyboardInput(active: boolean) { - this.scene.input.keyboard.enabled = active; + this.scene.input.keyboard!.enabled = active; // ! to convince typescript Keyboard Plugin exists } /** @@ -57,7 +57,7 @@ class GameInputManager { event: string | symbol, callback: Function ) { - const keyObj = this.scene.input.keyboard.addKey(key); + const keyObj = this.scene.input.keyboard!.addKey(key); // ! to convince typescript Keyboard Plugin exists const keyboardListener = keyObj.addListener(event, callback); this.keyboardListeners.push(keyboardListener); } diff --git a/yarn.lock b/yarn.lock index 7bb26c2ea8..e9c70dd630 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6619,11 +6619,16 @@ event-emitter-es6@^1.1.5: resolved "https://registry.yarnpkg.com/event-emitter-es6/-/event-emitter-es6-1.1.5.tgz#ef95311b2e17aa39be763b031ce4af7ee9cb7849" integrity sha512-/n7qzkJBySdbe1W9/FBDdO7gzDIaewgj+Rj6Ayc2BdvVcaGP+p40DyViOFudCgV47UU8+cUFmcD3tJgjwY65qQ== -eventemitter3@^4.0.0, eventemitter3@^4.0.1, eventemitter3@^4.0.7: +eventemitter3@^4.0.0, eventemitter3@^4.0.1: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + events@^3.2.0: version "3.3.0" resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" @@ -10406,13 +10411,12 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -phaser@^3.55.2: - version "3.55.2" - resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.55.2.tgz#c1e2e9e70de7085502885e06f46b7eb4bd95e29a" - integrity sha512-amKXsbb2Ht29dGPKvt1edq3yGGYKtq8373GpJYGKPNPnneYY6MtVTOgjHDuZwtmUyK4v86FugkT3hzW/N4tjxQ== +phaser@^3.87.0: + version "3.87.0" + resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.87.0.tgz#209f1673b311a3f76d59f14b785699709a8f9cf5" + integrity sha512-AyI1b3T5fp05gzf6WUmu2FNqaZL+Y7w88yBRLf7YZXF9bncUSHpnDrupnTGoPqy/RKHRLBcay7zWeqQ2wiMWcw== dependencies: - eventemitter3 "^4.0.7" - path "^0.12.7" + eventemitter3 "^5.0.1" picocolors@^0.2.1: version "0.2.1" From 96fa4267765d0fded2555887414e670712a82846 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Tue, 4 Feb 2025 17:55:19 +0800 Subject: [PATCH 02/17] Add phaser3spectorjs to satisfy phaser problems --- package.json | 1 + yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 0afa9fd1c2..85d72e8c56 100644 --- a/package.json +++ b/package.json @@ -148,6 +148,7 @@ "os-browserify": "^0.3.0", "path": "^0.12.7", "path-browserify": "^1.0.1", + "phaser3spectorjs": "^0.0.8", "prettier": "^3.3.3", "process": "^0.11.10", "react-error-overlay": "^6.0.11", diff --git a/yarn.lock b/yarn.lock index e9c70dd630..79cd9002b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10411,6 +10411,11 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== +phaser3spectorjs@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/phaser3spectorjs/-/phaser3spectorjs-0.0.8.tgz#a7996eebc9c498b6d9d19ecda35f16ad3918a8a8" + integrity sha512-0dSO7/aMjEUPrp5EcjRvRRsEf+jXDbmzalPeJ6VtTB2Pn1PeaKc+qlL/DmO3l1Dvc5lkzc+Sil1Ta+Hkyi5cbA== + phaser@^3.87.0: version "3.87.0" resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.87.0.tgz#209f1673b311a3f76d59f14b785699709a8f9cf5" From fae817c79409a8b894165bb134d26ed7d732ec3e Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Tue, 4 Feb 2025 20:30:08 +0800 Subject: [PATCH 03/17] Guard against MouseManager or Keyboard not existing --- src/features/game/input/GameInputManager.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/features/game/input/GameInputManager.ts b/src/features/game/input/GameInputManager.ts index fff21fcfa7..e2b420bfaf 100644 --- a/src/features/game/input/GameInputManager.ts +++ b/src/features/game/input/GameInputManager.ts @@ -32,7 +32,7 @@ class GameInputManager { * @param active if true, mouse input is enabled. Else, mouse input is disabled. */ public enableMouseInput(active: boolean) { - this.scene.input.mouse!.enabled = active; // ! to convince typescript Mouse Manager exists + if (this.scene.input.mouse) this.scene.input.mouse.enabled = active; } /** @@ -41,7 +41,7 @@ class GameInputManager { * @param active if true, keyboard input is enabled. Else, keyboard input is disabled. */ public enableKeyboardInput(active: boolean) { - this.scene.input.keyboard!.enabled = active; // ! to convince typescript Keyboard Plugin exists + if (this.scene.input.keyboard) this.scene.input.keyboard!.enabled = active; } /** @@ -57,9 +57,11 @@ class GameInputManager { event: string | symbol, callback: Function ) { - const keyObj = this.scene.input.keyboard!.addKey(key); // ! to convince typescript Keyboard Plugin exists - const keyboardListener = keyObj.addListener(event, callback); - this.keyboardListeners.push(keyboardListener); + if (this.scene.input.keyboard) { + const keyObj = this.scene.input.keyboard.addKey(key); + const keyboardListener = keyObj.addListener(event, callback); + this.keyboardListeners.push(keyboardListener); + } } /** From 10b11f4b6b3d8a8ae7d99765569073035193a21c Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Tue, 4 Feb 2025 21:04:05 +0800 Subject: [PATCH 04/17] Remove ! from keyboard guard and use if-return syntax for GameInputManager --- src/features/game/input/GameInputManager.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/features/game/input/GameInputManager.ts b/src/features/game/input/GameInputManager.ts index e2b420bfaf..d1909a447c 100644 --- a/src/features/game/input/GameInputManager.ts +++ b/src/features/game/input/GameInputManager.ts @@ -41,7 +41,7 @@ class GameInputManager { * @param active if true, keyboard input is enabled. Else, keyboard input is disabled. */ public enableKeyboardInput(active: boolean) { - if (this.scene.input.keyboard) this.scene.input.keyboard!.enabled = active; + if (this.scene.input.keyboard) this.scene.input.keyboard.enabled = active; } /** @@ -57,11 +57,11 @@ class GameInputManager { event: string | symbol, callback: Function ) { - if (this.scene.input.keyboard) { - const keyObj = this.scene.input.keyboard.addKey(key); - const keyboardListener = keyObj.addListener(event, callback); - this.keyboardListeners.push(keyboardListener); - } + if (!this.scene.input.keyboard) return; + + const keyObj = this.scene.input.keyboard.addKey(key); + const keyboardListener = keyObj.addListener(event, callback); + this.keyboardListeners.push(keyboardListener); } /** From 64b6f65a5e851fd720a218e3af7c5a5b10335da1 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Mon, 10 Feb 2025 13:17:44 +0800 Subject: [PATCH 05/17] Catch missing background music asset error --- src/features/game/sound/GameSoundManager.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/features/game/sound/GameSoundManager.ts b/src/features/game/sound/GameSoundManager.ts index 8ae17c78d8..f2aa98ff84 100644 --- a/src/features/game/sound/GameSoundManager.ts +++ b/src/features/game/sound/GameSoundManager.ts @@ -161,14 +161,18 @@ class GameSoundManager { const soundAsset = mandatory(this.getSoundAsset(soundKey)); const bgmVol = soundAsset.config.volume !== undefined ? soundAsset.config.volume : 1; - this.currBgMusic = this.getBaseSoundManager().add(soundAsset.key, { - ...soundAsset.config, - volume: bgmVol * this.bgmVol - }) as Phaser.Sound.WebAudioSound; - this.currBgMusicKey = soundAsset.key; - - // Finally, play it - this.currBgMusic.play(); + try { + this.currBgMusic = this.getBaseSoundManager().add(soundAsset.key, { + ...soundAsset.config, + volume: bgmVol * this.bgmVol + }) as Phaser.Sound.WebAudioSound; + this.currBgMusicKey = soundAsset.key; + + // Finally, play it + this.currBgMusic.play(); + } catch (err) { + console.error(err); + } } /** From 8577379286207f1f89a65e3ed6fe42fc6e95fa11 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Mon, 10 Feb 2025 13:30:54 +0800 Subject: [PATCH 06/17] prettier GameSoundManager --- src/features/game/sound/GameSoundManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/game/sound/GameSoundManager.ts b/src/features/game/sound/GameSoundManager.ts index f2aa98ff84..9997944518 100644 --- a/src/features/game/sound/GameSoundManager.ts +++ b/src/features/game/sound/GameSoundManager.ts @@ -167,7 +167,7 @@ class GameSoundManager { volume: bgmVol * this.bgmVol }) as Phaser.Sound.WebAudioSound; this.currBgMusicKey = soundAsset.key; - + // Finally, play it this.currBgMusic.play(); } catch (err) { From 862f83efc3903292aae0366ed9eaefe7654e58af Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Mon, 17 Feb 2025 14:07:00 +0800 Subject: [PATCH 07/17] Added REACT_APP_USE_BACKEND_ASSET_PREFIX to .env to allow for base url usage during development --- .env.example | 1 + public/assets/mockChapter0.txt | 2 +- src/features/game/commons/CommonConstants.ts | 1 + src/features/game/utils/GameUtils.ts | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index e9c6cbbcd9..4cb5cc4867 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,7 @@ REACT_APP_DEPLOYMENT_NAME=Source Academy REACT_APP_BACKEND_URL=http://localhost:4000 REACT_APP_USE_BACKEND=TRUE +REACT_APP_USE_BACKEND_ASSET_PREFIX=FALSE REACT_APP_PLAYGROUND_ONLY=FALSE REACT_APP_SHOW_RESEARCH_PROMPT=FALSE diff --git a/public/assets/mockChapter0.txt b/public/assets/mockChapter0.txt index 7a985d9fb0..b22cc9febf 100644 --- a/public/assets/mockChapter0.txt +++ b/public/assets/mockChapter0.txt @@ -113,7 +113,7 @@ dialogues Hmmm update_assessment_status*() Let me check - goto 2 if !userstate.assessments.173 else 3 + goto 1 if !userstate.assessments.173 else 3 what, What should I do now, Scottie? @you diff --git a/src/features/game/commons/CommonConstants.ts b/src/features/game/commons/CommonConstants.ts index 64ab1b6ee5..7f481a109c 100644 --- a/src/features/game/commons/CommonConstants.ts +++ b/src/features/game/commons/CommonConstants.ts @@ -4,6 +4,7 @@ import FontAssets from '../assets/FontAssets'; export const Constants = { assetsFolder: Links.sourceAcademyAssets, + useBackendAssetPrefix: process.env.REACT_APP_USE_BACKEND_ASSET_PREFIX?.toUpperCase() === "TRUE", fadeDuration: 600, nullFunction: () => {}, nullInteractionId: '', diff --git a/src/features/game/utils/GameUtils.ts b/src/features/game/utils/GameUtils.ts index 76852077ad..be50e37765 100644 --- a/src/features/game/utils/GameUtils.ts +++ b/src/features/game/utils/GameUtils.ts @@ -58,9 +58,9 @@ export function limitNumber(value: number, min: number, max: number) { */ export function toS3Path(fileName: string, courseCoded = false) { if (fileName.startsWith('/')) { - fileName = fileName.substr(1); + fileName = fileName.substring(1); } - return Constants.assetsFolder + (courseCoded ? assetsPrefix() + fileName : fileName); + return Constants.assetsFolder + (courseCoded && Constants.useBackendAssetPrefix ? assetsPrefix() + fileName : fileName); } /** From 806b13654488245bcdc9eacdb0e7e63f8f9b30c0 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Mon, 17 Feb 2025 14:09:28 +0800 Subject: [PATCH 08/17] Prettify using format:tsx --- src/features/game/commons/CommonConstants.ts | 2 +- src/features/game/utils/GameUtils.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/features/game/commons/CommonConstants.ts b/src/features/game/commons/CommonConstants.ts index 7f481a109c..a0f06ea345 100644 --- a/src/features/game/commons/CommonConstants.ts +++ b/src/features/game/commons/CommonConstants.ts @@ -4,7 +4,7 @@ import FontAssets from '../assets/FontAssets'; export const Constants = { assetsFolder: Links.sourceAcademyAssets, - useBackendAssetPrefix: process.env.REACT_APP_USE_BACKEND_ASSET_PREFIX?.toUpperCase() === "TRUE", + useBackendAssetPrefix: process.env.REACT_APP_USE_BACKEND_ASSET_PREFIX?.toUpperCase() === 'TRUE', fadeDuration: 600, nullFunction: () => {}, nullInteractionId: '', diff --git a/src/features/game/utils/GameUtils.ts b/src/features/game/utils/GameUtils.ts index be50e37765..bb5de7a789 100644 --- a/src/features/game/utils/GameUtils.ts +++ b/src/features/game/utils/GameUtils.ts @@ -60,7 +60,10 @@ export function toS3Path(fileName: string, courseCoded = false) { if (fileName.startsWith('/')) { fileName = fileName.substring(1); } - return Constants.assetsFolder + (courseCoded && Constants.useBackendAssetPrefix ? assetsPrefix() + fileName : fileName); + return ( + Constants.assetsFolder + + (courseCoded && Constants.useBackendAssetPrefix ? assetsPrefix() + fileName : fileName) + ); } /** From f025c930622d7f873be28e734985383821842051 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Tue, 18 Feb 2025 21:09:17 +0800 Subject: [PATCH 09/17] Invert useEmptyAssetPrefix for backwards compatibility --- .env.example | 2 +- src/features/game/commons/CommonConstants.ts | 2 +- src/features/game/utils/GameUtils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 4cb5cc4867..ecc741ea7b 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ REACT_APP_DEPLOYMENT_NAME=Source Academy REACT_APP_BACKEND_URL=http://localhost:4000 REACT_APP_USE_BACKEND=TRUE -REACT_APP_USE_BACKEND_ASSET_PREFIX=FALSE +REACT_APP_USE_EMPTY_ASSET_PREFIX=FALSE REACT_APP_PLAYGROUND_ONLY=FALSE REACT_APP_SHOW_RESEARCH_PROMPT=FALSE diff --git a/src/features/game/commons/CommonConstants.ts b/src/features/game/commons/CommonConstants.ts index a0f06ea345..34528d0c50 100644 --- a/src/features/game/commons/CommonConstants.ts +++ b/src/features/game/commons/CommonConstants.ts @@ -4,7 +4,7 @@ import FontAssets from '../assets/FontAssets'; export const Constants = { assetsFolder: Links.sourceAcademyAssets, - useBackendAssetPrefix: process.env.REACT_APP_USE_BACKEND_ASSET_PREFIX?.toUpperCase() === 'TRUE', + useEmptyAssetPrefix: process.env.REACT_APP_USE_EMPTY_ASSET_PREFIX?.toUpperCase() === 'TRUE', fadeDuration: 600, nullFunction: () => {}, nullInteractionId: '', diff --git a/src/features/game/utils/GameUtils.ts b/src/features/game/utils/GameUtils.ts index bb5de7a789..3d8833485a 100644 --- a/src/features/game/utils/GameUtils.ts +++ b/src/features/game/utils/GameUtils.ts @@ -62,7 +62,7 @@ export function toS3Path(fileName: string, courseCoded = false) { } return ( Constants.assetsFolder + - (courseCoded && Constants.useBackendAssetPrefix ? assetsPrefix() + fileName : fileName) + (courseCoded && !Constants.useEmptyAssetPrefix ? assetsPrefix() + fileName : fileName) ); } From fe0b85cf0bd113ecd38d9af14ddd33fe21d17ef1 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Wed, 19 Feb 2025 09:24:35 +0800 Subject: [PATCH 10/17] Stop fatal error on missing bgm key in ParserValidator --- src/features/game/parser/ParserValidator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/game/parser/ParserValidator.ts b/src/features/game/parser/ParserValidator.ts index 52bd8af204..4e3712b79f 100644 --- a/src/features/game/parser/ParserValidator.ts +++ b/src/features/game/parser/ParserValidator.ts @@ -209,9 +209,9 @@ export default class ParserValidator { sound => sound.soundType === GameSoundType.BGM && sound.key === itemId ).length; if (numberOfBgm === 0) { - throw new Error(`Cannot find bgm key "${itemId}"`); + console.error(`Cannot find bgm key "${itemId}"`); } else if (numberOfBgm > 1) { - throw new Error(`More than 1 bgm key "${itemId}"`); + console.error(`More than 1 bgm key "${itemId}"`); } break; From d6402a5865496c07310846a1cf97794a5058fd92 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:13:27 +0800 Subject: [PATCH 11/17] Fix versioning strategy and package.json post-merge --- package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 60c5652d58..34bc82506c 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "mdast-util-from-markdown": "^2.0.0", "mdast-util-to-hast": "^13.0.0", "normalize.css": "^8.0.1", - "phaser": "^3.87.0", + "phaser": "~3.87.0", "query-string": "^9.0.0", "re-resizable": "^6.9.9", "react": "^18.3.1", @@ -103,7 +103,6 @@ "yareco": "^0.1.5" }, "devDependencies": { - "//": "See: https://github.com/facebook/react/issues/28313#issuecomment-2076798972, https://github.com/t3-oss/create-t3-turbo/issues/984#issuecomment-2076413457", "@babel/core": "^7.24.5", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-typescript": "^7.24.1", @@ -182,6 +181,5 @@ "last 1 firefox version", "last 1 safari version" ] - }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + } } From 214f21584ea571d91b96a84a217fa78a41ed05c5 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:13:48 +0800 Subject: [PATCH 12/17] Update lockfile post-merge --- yarn.lock | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index c96a4f6baa..f8a4abd69d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9056,13 +9056,20 @@ __metadata: languageName: node linkType: hard -"eventemitter3@npm:^4.0.0, eventemitter3@npm:^4.0.1, eventemitter3@npm:^4.0.7": +"eventemitter3@npm:^4.0.0, eventemitter3@npm:^4.0.1": version: 4.0.7 resolution: "eventemitter3@npm:4.0.7" checksum: 10c0/5f6d97cbcbac47be798e6355e3a7639a84ee1f7d9b199a07017f1d2f1e2fe236004d14fa5dfaeba661f94ea57805385e326236a6debbc7145c8877fbc0297c6b languageName: node linkType: hard +"eventemitter3@npm:^5.0.1": + version: 5.0.1 + resolution: "eventemitter3@npm:5.0.1" + checksum: 10c0/4ba5c00c506e6c786b4d6262cfbce90ddc14c10d4667e5c83ae993c9de88aa856033994dd2b35b83e8dc1170e224e66a319fa80adc4c32adcd2379bbc75da814 + languageName: node + linkType: hard + "events@npm:^3.2.0": version: 3.3.0 resolution: "events@npm:3.3.0" @@ -9662,8 +9669,10 @@ __metadata: normalize.css: "npm:^8.0.1" npm-run-all2: "npm:^7.0.0" os-browserify: "npm:^0.3.0" + path: "npm:^0.12.7" path-browserify: "npm:^1.0.1" - phaser: "npm:^3.55.2" + phaser: "npm:~3.87.0" + phaser3spectorjs: "npm:^0.0.8" prettier: "npm:^3.3.3" process: "npm:^0.11.10" query-string: "npm:^9.0.0" @@ -14249,13 +14258,19 @@ __metadata: languageName: node linkType: hard -"phaser@npm:^3.55.2": - version: 3.55.2 - resolution: "phaser@npm:3.55.2" +"phaser3spectorjs@npm:^0.0.8": + version: 0.0.8 + resolution: "phaser3spectorjs@npm:0.0.8" + checksum: 10c0/84933cc3e314279d2bd2c4b3356f2c93e0fe6918dcf6d7ab88d0df4d3457df05703e895012a27ba50d8dd3d9bc61183b58a7b8dde9ec81fc3d887e0fd77184dd + languageName: node + linkType: hard + +"phaser@npm:~3.87.0": + version: 3.87.0 + resolution: "phaser@npm:3.87.0" dependencies: - eventemitter3: "npm:^4.0.7" - path: "npm:^0.12.7" - checksum: 10c0/aed4c37a22174e843344328c6b0cc0a6160a49fe12d37a6fa0aab82d37d6bfc00a3c76fa792621fa61b02148e340c39dae5be4f0f5b7cb95df7c774b826455b3 + eventemitter3: "npm:^5.0.1" + checksum: 10c0/39f5baef2cbd3c30ae65efb7f1b4a034f5fd87f51f74547574602a6bada014999a900561cb0efa17e086a6a06f886525d0832b1d465af382db8674c1ed42ef67 languageName: node linkType: hard From 81988b727d663a0c7fc138ff1d9801b57b0e0815 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Thu, 27 Feb 2025 10:55:49 +0800 Subject: [PATCH 13/17] ParserValidator now checks default sound assets for bgms and sfxs --- src/features/game/parser/ParserValidator.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/features/game/parser/ParserValidator.ts b/src/features/game/parser/ParserValidator.ts index 4e3712b79f..dc13775d22 100644 --- a/src/features/game/parser/ParserValidator.ts +++ b/src/features/game/parser/ParserValidator.ts @@ -2,6 +2,7 @@ import { ItemId } from '../commons/CommonTypes'; import { GameItemType } from '../location/GameMapTypes'; import { GameSoundType } from '../sound/GameSoundTypes'; import Parser from './Parser'; +import SoundAssets from '../assets/SoundAssets'; export enum GameEntityType { locations = 'locations', @@ -203,22 +204,24 @@ export default class ParserValidator { break; case GameEntityType.bgms: - const numberOfBgm = Parser.checkpoint.map - .getSoundAssets() - .filter( + const numberOfBgm = [ + ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets + ...Object.values(SoundAssets) // Default sound assets + ].filter( sound => sound.soundType === GameSoundType.BGM && sound.key === itemId ).length; if (numberOfBgm === 0) { - console.error(`Cannot find bgm key "${itemId}"`); + throw new Error(`Cannot find bgm key "${itemId}"`); } else if (numberOfBgm > 1) { - console.error(`More than 1 bgm key "${itemId}"`); + throw new Error(`More than 1 bgm key "${itemId}"`); } break; case GameEntityType.sfxs: - const numberOfSfx = Parser.checkpoint.map - .getSoundAssets() - .filter( + const numberOfSfx = [ + ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets + ...Object.values(SoundAssets) // Default sound assets + ].filter( sound => sound.soundType === GameSoundType.SFX && sound.key === itemId ).length; if (numberOfSfx === 0) { From 20dc2191a74c0b20e93df4a8f887f06ae8132c32 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Thu, 27 Feb 2025 11:04:20 +0800 Subject: [PATCH 14/17] ESLint sort imports --- src/features/game/parser/ParserValidator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/game/parser/ParserValidator.ts b/src/features/game/parser/ParserValidator.ts index dc13775d22..1a8701e8b1 100644 --- a/src/features/game/parser/ParserValidator.ts +++ b/src/features/game/parser/ParserValidator.ts @@ -1,8 +1,8 @@ +import SoundAssets from '../assets/SoundAssets'; import { ItemId } from '../commons/CommonTypes'; import { GameItemType } from '../location/GameMapTypes'; import { GameSoundType } from '../sound/GameSoundTypes'; import Parser from './Parser'; -import SoundAssets from '../assets/SoundAssets'; export enum GameEntityType { locations = 'locations', From ac875efe235234baf05b7a04a2f68137f36659e3 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Thu, 27 Feb 2025 15:04:27 +0800 Subject: [PATCH 15/17] yarn format again --- src/features/game/parser/ParserValidator.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/features/game/parser/ParserValidator.ts b/src/features/game/parser/ParserValidator.ts index 1a8701e8b1..ed4a7a280a 100644 --- a/src/features/game/parser/ParserValidator.ts +++ b/src/features/game/parser/ParserValidator.ts @@ -205,11 +205,11 @@ export default class ParserValidator { case GameEntityType.bgms: const numberOfBgm = [ - ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets - ...Object.values(SoundAssets) // Default sound assets - ].filter( - sound => sound.soundType === GameSoundType.BGM && sound.key === itemId - ).length; + ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets + ...Object.values(SoundAssets) // Default sound assets + ].filter( + sound => sound.soundType === GameSoundType.BGM && sound.key === itemId + ).length; if (numberOfBgm === 0) { throw new Error(`Cannot find bgm key "${itemId}"`); } else if (numberOfBgm > 1) { @@ -219,11 +219,11 @@ export default class ParserValidator { case GameEntityType.sfxs: const numberOfSfx = [ - ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets - ...Object.values(SoundAssets) // Default sound assets - ].filter( - sound => sound.soundType === GameSoundType.SFX && sound.key === itemId - ).length; + ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets + ...Object.values(SoundAssets) // Default sound assets + ].filter( + sound => sound.soundType === GameSoundType.SFX && sound.key === itemId + ).length; if (numberOfSfx === 0) { throw new Error(`Cannot find sfx key "${itemId}"`); } else if (numberOfSfx > 1) { From ad079e79173b80e4c96a1f932abbe6f633c530cf Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Thu, 27 Feb 2025 22:14:02 +0800 Subject: [PATCH 16/17] Shift USE_EMPTY_ASSET_PREFIX reading to commons/utils/Constants instead --- src/commons/utils/Constants.ts | 2 ++ src/features/game/commons/CommonConstants.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commons/utils/Constants.ts b/src/commons/utils/Constants.ts index 0c0137fa4e..28a5555c3a 100644 --- a/src/commons/utils/Constants.ts +++ b/src/commons/utils/Constants.ts @@ -21,6 +21,7 @@ const storiesBackendUrl = process.env.REACT_APP_STORIES_BACKEND_URL; const cadetLoggerUrl = isTest ? undefined : process.env.REACT_APP_CADET_LOGGER; const cadetLoggerInterval = parseInt(process.env.REACT_APP_CADET_LOGGER_INTERVAL || '10000', 10); const useBackend = !isTest && isTrue(process.env.REACT_APP_USE_BACKEND); +const useEmptyAssetPrefix = isTrue(process.env.REACT_APP_USE_EMPTY_ASSET_PREFIX); const defaultSourceChapter = Chapter.SOURCE_4; const defaultSourceVariant = Variant.DEFAULT; const defaultQuestionId = 0; @@ -154,6 +155,7 @@ const Constants = { storiesBackendUrl, cadetLoggerUrl, useBackend, + useEmptyAssetPrefix, defaultSourceChapter, defaultSourceVariant, defaultQuestionId, diff --git a/src/features/game/commons/CommonConstants.ts b/src/features/game/commons/CommonConstants.ts index 34528d0c50..613d33fbcf 100644 --- a/src/features/game/commons/CommonConstants.ts +++ b/src/features/game/commons/CommonConstants.ts @@ -1,10 +1,10 @@ -import { Links } from 'src/commons/utils/Constants'; +import UtilConstants, { Links } from 'src/commons/utils/Constants'; import FontAssets from '../assets/FontAssets'; export const Constants = { assetsFolder: Links.sourceAcademyAssets, - useEmptyAssetPrefix: process.env.REACT_APP_USE_EMPTY_ASSET_PREFIX?.toUpperCase() === 'TRUE', + useEmptyAssetPrefix: UtilConstants.useEmptyAssetPrefix, fadeDuration: 600, nullFunction: () => {}, nullInteractionId: '', From 5cd04dbef1a5bd6e29d189dbb46edb51194a8dc0 Mon Sep 17 00:00:00 2001 From: JustATin555 Date: Thu, 27 Feb 2025 23:12:32 +0800 Subject: [PATCH 17/17] Only check for default asset if BGM / SFX not found --- src/features/game/parser/ParserValidator.ts | 41 ++++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/features/game/parser/ParserValidator.ts b/src/features/game/parser/ParserValidator.ts index ed4a7a280a..b29ac8e78c 100644 --- a/src/features/game/parser/ParserValidator.ts +++ b/src/features/game/parser/ParserValidator.ts @@ -1,3 +1,4 @@ +import { SoundAsset } from '../assets/AssetsTypes'; import SoundAssets from '../assets/SoundAssets'; import { ItemId } from '../commons/CommonTypes'; import { GameItemType } from '../location/GameMapTypes'; @@ -204,28 +205,40 @@ export default class ParserValidator { break; case GameEntityType.bgms: - const numberOfBgm = [ - ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets - ...Object.values(SoundAssets) // Default sound assets - ].filter( - sound => sound.soundType === GameSoundType.BGM && sound.key === itemId - ).length; + // Count BGMs matching itemId + const numberOfBgm = Parser.checkpoint.map + .getSoundAssets() + .reduce((acc: number, sound: SoundAsset): number => { + return ( + acc + (sound.soundType === GameSoundType.BGM && sound.key === itemId ? 1 : 0) + ); + }, 0); if (numberOfBgm === 0) { - throw new Error(`Cannot find bgm key "${itemId}"`); + // Check if itemId is a default BGM + const isDefaultAsset = Object.values(SoundAssets).some( + sound => sound.soundType === GameSoundType.BGM && sound.key === itemId + ); + if (!isDefaultAsset) throw new Error(`Cannot find bgm key "${itemId}"`); } else if (numberOfBgm > 1) { throw new Error(`More than 1 bgm key "${itemId}"`); } break; case GameEntityType.sfxs: - const numberOfSfx = [ - ...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets - ...Object.values(SoundAssets) // Default sound assets - ].filter( - sound => sound.soundType === GameSoundType.SFX && sound.key === itemId - ).length; + // Count SFXs matching itemId + const numberOfSfx = Parser.checkpoint.map + .getSoundAssets() + .reduce((acc: number, sound: SoundAsset): number => { + return ( + acc + (sound.soundType === GameSoundType.SFX && sound.key === itemId ? 1 : 0) + ); + }, 0); if (numberOfSfx === 0) { - throw new Error(`Cannot find sfx key "${itemId}"`); + // Check if itemId is a default SFX + const isDefaultAsset = Object.values(SoundAssets).some( + sound => sound.soundType === GameSoundType.SFX && sound.key === itemId + ); + if (!isDefaultAsset) throw new Error(`Cannot find sfx key "${itemId}"`); } else if (numberOfSfx > 1) { throw new Error(`More than 1 sfx key "${itemId}"`); }