From a41e9c482dad1515545855a7805ba91b90b190fd Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 1 Sep 2024 11:34:21 +0800 Subject: [PATCH 1/3] fix: use key when setting var --- packages/webgal/src/Core/gameScripts/setVar.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/webgal/src/Core/gameScripts/setVar.ts b/packages/webgal/src/Core/gameScripts/setVar.ts index a1f8d18f..d9a1a08b 100644 --- a/packages/webgal/src/Core/gameScripts/setVar.ts +++ b/packages/webgal/src/Core/gameScripts/setVar.ts @@ -68,7 +68,8 @@ export const setVar = (sentence: ISentence): IPerform => { if (!isNaN(Number(valExp))) { webgalStore.dispatch(targetReducerFunction({ key, value: Number(valExp) })); } else { - webgalStore.dispatch(targetReducerFunction({ key, value: getValueFromStateElseKey(valExp) })); + // 字符串 + webgalStore.dispatch(targetReducerFunction({ key, value: getValueFromStateElseKey(valExp, true) })); } } if (setGlobal) { @@ -113,10 +114,13 @@ export function getValueFromState(key: string) { /** * 取不到时返回 {key} */ -export function getValueFromStateElseKey(key: string) { +export function getValueFromStateElseKey(key: string, setting = false) { const valueFromState = getValueFromState(key); if (valueFromState === null || valueFromState === undefined) { logger.warn('valueFromState result null, key = ' + key); + if (setting) { + return key; + } return `{${key}}`; } return valueFromState; From 37bfddd7862ffddf72cea4c3e49e76b8574f857f Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 1 Sep 2024 11:42:51 +0800 Subject: [PATCH 2/3] fix: get var problem --- .../webgal/src/Core/controller/gamePlay/scriptExecutor.ts | 2 +- packages/webgal/src/Core/gameScripts/setVar.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts b/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts index db7d6d0c..3370b99a 100644 --- a/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts +++ b/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts @@ -25,7 +25,7 @@ export const whenChecker = (whenValue: string | undefined): boolean => { if (e.match(/true/) || e.match(/false/)) { return e; } - return getValueFromStateElseKey(e); + return getValueFromStateElseKey(e, true); } else return e; }) .reduce((pre, curr) => pre + curr, ''); diff --git a/packages/webgal/src/Core/gameScripts/setVar.ts b/packages/webgal/src/Core/gameScripts/setVar.ts index d9a1a08b..ff6ac550 100644 --- a/packages/webgal/src/Core/gameScripts/setVar.ts +++ b/packages/webgal/src/Core/gameScripts/setVar.ts @@ -43,7 +43,7 @@ export const setVar = (sentence: ISentence): IPerform => { // 检查是否是变量名,不是就返回本身 return e; } - const _r = getValueFromStateElseKey(e.trim()); + const _r = getValueFromStateElseKey(e.trim(), true); return typeof _r === 'string' ? `'${_r}'` : _r; }) .reduce((pre, curr) => pre + curr, ''); @@ -114,11 +114,11 @@ export function getValueFromState(key: string) { /** * 取不到时返回 {key} */ -export function getValueFromStateElseKey(key: string, setting = false) { +export function getValueFromStateElseKey(key: string, useKeyNameAsReturn = false) { const valueFromState = getValueFromState(key); if (valueFromState === null || valueFromState === undefined) { logger.warn('valueFromState result null, key = ' + key); - if (setting) { + if (useKeyNameAsReturn) { return key; } return `{${key}}`; From 0039ce1a527980cbf59e25a989826460b60c1914 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 1 Sep 2024 11:45:15 +0800 Subject: [PATCH 3/3] update version --- packages/webgal/package.json | 2 +- packages/webgal/public/game/template/template.json | 2 +- packages/webgal/src/config/info.ts | 2 +- releasenote.md | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/webgal/package.json b/packages/webgal/package.json index ed59ae5a..cf884027 100644 --- a/packages/webgal/package.json +++ b/packages/webgal/package.json @@ -1,7 +1,7 @@ { "name": "webgal", "private": true, - "version": "4.5.6", + "version": "4.5.7", "scripts": { "dev": "vite --host --port 3000", "build": "cross-env NODE_ENV=production tsc && vite build --base=./", diff --git a/packages/webgal/public/game/template/template.json b/packages/webgal/public/game/template/template.json index 8a398b19..ea42e412 100644 --- a/packages/webgal/public/game/template/template.json +++ b/packages/webgal/public/game/template/template.json @@ -1,4 +1,4 @@ { "name":"Default Template", - "webgal-version":"4.5.6" + "webgal-version":"4.5.7" } diff --git a/packages/webgal/src/config/info.ts b/packages/webgal/src/config/info.ts index ec3046f1..dc89641a 100644 --- a/packages/webgal/src/config/info.ts +++ b/packages/webgal/src/config/info.ts @@ -1,5 +1,5 @@ export const __INFO = { - version: 'WebGAL 4.5.6', + version: 'WebGAL 4.5.7', contributors: [ // 现在改为跳转到 GitHub 了 ], diff --git a/releasenote.md b/releasenote.md index 9bcccc0a..6a9a3ac6 100644 --- a/releasenote.md +++ b/releasenote.md @@ -12,7 +12,7 @@ #### 修复 -4.5.6 修复:无法从状态中获取到对应 key 的变量时,返回 {key} 以避免变换不生效 +4.5.7 修复:无法从状态中获取到对应 key 的变量时,返回 {key} 以避免变换不生效 修复了 `-concat` 选项动画在新行中的错误。 @@ -54,7 +54,7 @@ Added a new parameter to control "execute the next statement after the performan #### Bug Fixes -4.5.6 Fix: When the corresponding key variable cannot be obtained from the state, return {key} to avoid ineffective transformation. +4.5.7 Fix: When the corresponding key variable cannot be obtained from the state, return {key} to avoid ineffective transformation. Fixed an animation error with the `-concat` option in a new line. @@ -96,7 +96,7 @@ Fixed the logo image issue. #### 修正 -4.5.6 修正:状態から対応する key の変数が取得できない場合、{key} を返すようにし、変換が無効になるのを回避しました +4.5.7 修正:状態から対応する key の変数が取得できない場合、{key} を返すようにし、変換が無効になるのを回避しました `-concat` オプションのアニメーションが新しい行でエラーになる問題を修正しました。