From d64a4ae81d6103878fd5821271e5296bcc208b7b Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:06:14 +0800 Subject: [PATCH 1/7] improve quests --- quests/exceptions.yml | 67 +++++++++++++++++++++++++++++++++++-- quests/explore/game.yml | 7 ---- quests/get-started/game.yml | 2 ++ quests/helloworld/game.yml | 16 ++++----- 4 files changed, 74 insertions(+), 18 deletions(-) diff --git a/quests/exceptions.yml b/quests/exceptions.yml index 6ffe5f5..f972be3 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -1,6 +1,67 @@ exceptions: - condition: command: - - '`' - hints: - - '!! 不需要輸入上下引號 !!' + - '[\uff21-\uff3a\uff41-\uff5a]' + responses: + - type: narrative + content: + - '!! 請使用半形英文字母 !!' + + - condition: + command: + - ' ' + responses: + - type: narrative + content: + - '!! 請使用半形空格 !!' + + - condition: + or: + - command: + - '`' + - command: + - \' + responses: + - type: narrative + content: + - '!! 不需要輸入上下引號 !!' + + - condition: + command: + - ^echo\S*$ + responses: + - type: narrative + content: + - '!! `echo` 後面要加空格 !!' + + - condition: + command: + - ^cd\S*$ + responses: + - type: narrative + content: + - '!! `cd` 後面要加空格 !!' + + - condition: + command: + - ^ls\S*$ + responses: + - type: narrative + content: + - '!! `ls` 後面要加空格 !!' + + - condition: + command: + - ^[Ii]s$ + responses: + - type: narrative + content: + - '!! `ls` 的首字母是小寫的 `L`,不是 `I` !!' + + - condition: + command: + - 嗨 + responses: + - type: narrative + content: + - '嗨~' diff --git a/quests/explore/game.yml b/quests/explore/game.yml index 5aa292e..cc65698 100644 --- a/quests/explore/game.yml +++ b/quests/explore/game.yml @@ -42,13 +42,6 @@ stages: content: - 請先回到 `/home/commander/` 資料夾 - 輸入 `cd ~` 來返回 `/home/commander/` 資料夾 - - condition: - command: - - ^[Ii]s$ - responses: - - type: narrative - content: - - '!! `ls` 的首字母是小寫的 `L`,不是 `I` !!' responses: - content: - 你應該能看到資料夾中的內容了。 diff --git a/quests/get-started/game.yml b/quests/get-started/game.yml index 9fd00fb..ba3e277 100644 --- a/quests/get-started/game.yml +++ b/quests/get-started/game.yml @@ -7,6 +7,7 @@ instruction: | 在畫面的中間可以看到終端機和提示兩個區塊。 請你在終端機中的 `commander:~ $` 後面輸入 `echo start` 並按下 Enter 來開始教程。 + !! 注意:不需要輸入上下引號 !! stages: - id: start @@ -65,6 +66,7 @@ stages: hints: - ➤ 按下 `Ctrl + C` 能夠中斷指令 - ➤ 劇情進行時可以按下 `Enter` 來快速跳過 + - ➤ 輸入 `echo finish` 來結束這一關 - id: END task: 結束關卡 diff --git a/quests/helloworld/game.yml b/quests/helloworld/game.yml index 05e382a..259dac5 100644 --- a/quests/helloworld/game.yml +++ b/quests/helloworld/game.yml @@ -12,9 +12,9 @@ stages: task: 輸入 `echo help` 來朗誦咒語 condition: pwd: - - '^/home/commander$' + - ^/home/commander$ command: - - echo [Hh]elp + - ^echo [Hh]elp$ responses: - type: narrative content: @@ -39,9 +39,9 @@ stages: - help condition: pwd: - - '^/home/commander$' + - ^/home/commander$ command: - - ls + - ^ls$ responses: - type: narrative content: @@ -65,9 +65,9 @@ stages: - find-scroll condition: pwd: - - '^/home/commander$' + - ^/home/commander$ command: - - cat forgotten_scroll.txt + - ^cat forgotten_scroll.txt$ responses: - type: dialogue speaker: Unix 精靈 @@ -83,9 +83,9 @@ stages: - read-forgotten-scroll condition: pwd: - - '^/home/commander$' + - ^/home/commander$ command: - - echo [Hh]ello\s*[Ww]orld + - ^echo [Hh]ello\s*[Ww]orld$ responses: - type: narrative content: From a22b898c0cd6bbb23d5b92fc5e9c8226ce78a5c5 Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:12:36 +0800 Subject: [PATCH 2/7] improve quest exceptions --- quests/exceptions.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/quests/exceptions.yml b/quests/exceptions.yml index f972be3..3b7ee9c 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -52,11 +52,11 @@ exceptions: - condition: command: - - ^[Ii]s$ + - ^[Ii1]s$ responses: - type: narrative content: - - '!! `ls` 的首字母是小寫的 `L`,不是 `I` !!' + - '!! `ls` 的首字母是小寫的 `L` !!' - condition: command: @@ -65,3 +65,20 @@ exceptions: - type: narrative content: - '嗨~' + + # 需改進 + - condition: + command: + - folderl + responses: + - type: narrative + content: + - '`folder1` 的 `1` 是數字 `1`,不是小寫的 `L` !!' + + - condition: + command: + - filel + responses: + - type: narrative + content: + - '`file1` 的 `1` 是數字 `1`,不是小寫的 `L` !!' From 3c1afb92e1c4c45aa167a267aecf50e00f292150 Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:17:02 +0800 Subject: [PATCH 3/7] improve exceptions --- quests/exceptions.yml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/quests/exceptions.yml b/quests/exceptions.yml index 3b7ee9c..7ab256f 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -50,6 +50,41 @@ exceptions: content: - '!! `ls` 後面要加空格 !!' + - condition: + not: + command: + - ^rmdir$ + command: + - ^rm\S*$ + responses: + - type: narrative + content: + - '!! `rm` 後面要加空格 !!' + + - condition: + command: + - ^mv\S*$ + responses: + - type: narrative + content: + - '!! `mv` 後面要加空格 !!' + + - condition: + command: + - ^rmdir\S*$ + responses: + - type: narrative + content: + - '!! `rmdir` 後面要加空格 !!' + + - condition: + command: + - ^cp\S*$ + responses: + - type: narrative + content: + - '!! `cp` 後面要加空格 !!' + - condition: command: - ^[Ii1]s$ @@ -66,7 +101,6 @@ exceptions: content: - '嗨~' - # 需改進 - condition: command: - folderl From 68492cd93271dff9b2cb72f8f9f2f24b84bb562e Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:25:44 +0800 Subject: [PATCH 4/7] improve exceptions in quest path --- quests/path/game.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/quests/path/game.yml b/quests/path/game.yml index dca6f75..69c312b 100644 --- a/quests/path/game.yml +++ b/quests/path/game.yml @@ -64,13 +64,12 @@ stages: - ^/home/commander/folder2$ exceptions: - condition: - not: - pwd: - - ^/home/commander/folder1$ + pwd: + - ^/home/commander$ responses: - type: narrative content: - - 請先回到 `folder1` 資料夾,並用指定的方式進入 `folder2` 資料夾。 + - 輸入 `cd folder2` 來進入 `folder2` 資料夾 responses: - content: - 你成功的用相對路徑進入了 `folder2` 資料夾。 From d4446186cd0fb6e80ef573a682bd6c2f2c1cb6b8 Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:32:31 +0800 Subject: [PATCH 5/7] improve exceptions --- quests/exceptions.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/quests/exceptions.yml b/quests/exceptions.yml index 7ab256f..ff6b39f 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -50,6 +50,22 @@ exceptions: content: - '!! `ls` 後面要加空格 !!' + - condition: + command: + - ^cat\S*$ + responses: + - type: narrative + content: + - '!! `cat` 後面要加空格 !!' + + - condition: + command: + - ^touch\S*$ + responses: + - type: narrative + content: + - '!! `touch` 後面要加空格 !!' + - condition: not: command: @@ -69,6 +85,14 @@ exceptions: content: - '!! `mv` 後面要加空格 !!' + - condition: + command: + - ^mkdir\S*$ + responses: + - type: narrative + content: + - '!! `mkdir` 後面要加空格 !!' + - condition: command: - ^rmdir\S*$ From c7d18ad95e9280c728a41060ccdc6ba331b34ae6 Mon Sep 17 00:00:00 2001 From: "Lin, Hung-Shin" Date: Sun, 26 Nov 2023 23:43:44 +0800 Subject: [PATCH 6/7] fix: stage re-execute --- server/src/game/commandHandler.js | 2 +- server/src/game/sessionHandler.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/game/commandHandler.js b/server/src/game/commandHandler.js index 4b271ff..e7c5b66 100644 --- a/server/src/game/commandHandler.js +++ b/server/src/game/commandHandler.js @@ -122,7 +122,7 @@ export default class CommandHandler extends SessionHandler { async run() { try { this.quest = await Quest.findById(this.session.quest) - const stages = this.getUnlockedComponents(this.quest.stages) + const stages = this.getStages() if (stages.length === 0) { logger.warn('stage not found', { session: this.session.id }) return {} diff --git a/server/src/game/sessionHandler.js b/server/src/game/sessionHandler.js index a9b89f0..e3e4af0 100644 --- a/server/src/game/sessionHandler.js +++ b/server/src/game/sessionHandler.js @@ -25,8 +25,13 @@ export default class SessionHandler { ) } + getStages() { + const unlockedStages = this.getUnlockedComponents(this.quest.stages) + return unlockedStages.filter((s) => !this.isCompleted(s)) + } + getNewTasks() { - const stages = this.getUnlockedComponents(this.quest.stages) + const stages = this.getStages() return stages .filter((s) => s.task) .filter((s) => !this.session.tasks.some((t) => t.id === s.id)) From a859b4ff3e02c5fff3356d7ccf505a3a46c8a9aa Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Sun, 26 Nov 2023 23:48:55 +0800 Subject: [PATCH 7/7] fix exceptions error --- quests/exceptions.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/quests/exceptions.yml b/quests/exceptions.yml index ff6b39f..1cabbca 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -28,7 +28,7 @@ exceptions: - condition: command: - - ^echo\S*$ + - ^echo\S$ responses: - type: narrative content: @@ -36,7 +36,7 @@ exceptions: - condition: command: - - ^cd\S*$ + - ^cd\S$ responses: - type: narrative content: @@ -44,7 +44,7 @@ exceptions: - condition: command: - - ^ls\S*$ + - ^ls\S$ responses: - type: narrative content: @@ -52,7 +52,7 @@ exceptions: - condition: command: - - ^cat\S*$ + - ^cat\S$ responses: - type: narrative content: @@ -60,7 +60,7 @@ exceptions: - condition: command: - - ^touch\S*$ + - ^touch\S$ responses: - type: narrative content: @@ -71,7 +71,7 @@ exceptions: command: - ^rmdir$ command: - - ^rm\S*$ + - ^rm\S$ responses: - type: narrative content: @@ -79,7 +79,7 @@ exceptions: - condition: command: - - ^mv\S*$ + - ^mv\S$ responses: - type: narrative content: @@ -87,7 +87,7 @@ exceptions: - condition: command: - - ^mkdir\S*$ + - ^mkdir\S$ responses: - type: narrative content: @@ -95,7 +95,7 @@ exceptions: - condition: command: - - ^rmdir\S*$ + - ^rmdir\S$ responses: - type: narrative content: @@ -103,7 +103,7 @@ exceptions: - condition: command: - - ^cp\S*$ + - ^cp\S$ responses: - type: narrative content: