diff --git a/app/src/views/GamePage.vue b/app/src/views/GamePage.vue index 962d0a5..82d20ac 100644 --- a/app/src/views/GamePage.vue +++ b/app/src/views/GamePage.vue @@ -60,7 +60,7 @@ onMounted(async () => {
-
+

@@ -70,7 +70,7 @@ onMounted(async () => {
-
+

diff --git a/packages/container/print.js b/packages/container/print.js index 1f7a50e..ffb669a 100644 --- a/packages/container/print.js +++ b/packages/container/print.js @@ -61,19 +61,21 @@ function printLine(content, delay, color) { async function printResponses(responses, delay = 100) { console.log() - console.log(colorize('-------------', 'white')) + console.log(colorize('==============================', 'green')) for (const response of responses) { const { type, content, speaker, color } = response if (type === 'narrative') { for (const line of content) { - await printLine(line, delay, color || 'white') + await printLine(line, delay, color || 'cyan') } + console.log() } if (type === 'dialogue') { - console.log(`${speaker}:`) + console.log(colorize(`${speaker}:`, 'green')) for (const line of content) { - await printLine(` ${line}`, delay, color || 'green') + await printLine(` ${line}`, delay, color || 'cyan') } + console.log() } } rl.close() diff --git a/quests/cast/game.yml b/quests/cast/game.yml new file mode 100644 index 0000000..9bb30f7 --- /dev/null +++ b/quests/cast/game.yml @@ -0,0 +1,130 @@ +title: 詠唱指令 +instruction: | + 在這一關,你將會學到如何使用 `echo` 指令,以及它在遊戲中的特殊功能。 + + 請輸入 `echo Start` 來開始這一關。 + +requirements: + - get-started + +stages: + - id: 00 + task: 輸入 `echo Start` 來開始教程 + repeatable: false + condition: + command: + - echo Start + responses: + - type: narrative + content: + - 你剛才使用的指令叫做 `echo`。 + - \`echo` 指令可以將後方接續的文字輸出到終端機上。 + - 例如你輸入 `echo Hello`,終端機就會顯示 `Hello`。 + - 你可以試著輸入 `echo` 並在後面加上一些文字,然後按下 Enter 鍵,就可以看到終端機上顯示了你剛才輸入的文字。 + hints: | + ➤ 輸入 `echo` 並在後面加上一些文字 + ➤ 例如:`echo Example` + + - id: 01 + task: 使用 `echo` 指令來讓終端機顯示任意文字 + repeatable: false + requirements: + - 00 + condition: + command: + - echo .* + responses: + - types: narrative + content: + - 你應該可以看到終端機上顯示了你剛才輸入的文字。 + - 接下來,請你試著在終端機上顯示 `How are you?`。 + hints: | + ➤ 利用 `echo` 指令來在終端機上顯示 `How are you?` + + - id: 02.1 + repeatable: false + requirements: + - 01 + condition: + command: + - echo + hints: | + ➤ 在 `echo` 後面還需要加上一些文字 + + - id: 02.2 + repeatable: false + requirements: + - 01 + condition: + - command: + - .*[Hh]ow are you + hints: | + ➤ 在 `How are you?` 前面必須加上 `echo` + + - id: 02 + task: 在終端機上顯示 `How are you?` + repeatable: false + requirements: + - 01 + condition: + - command: + - echo [Hh]ow are you + responses: + - type: narrative + content: + - 非常好,相信你已經了解 `echo` 指令的用法了。 + - 接下來,要像你介紹 `echo` 在遊戲中的特殊功能,那就是詠唱咒語。 + - 你可以通過輸入 `echo [咒語]` 來詠唱咒語,並產生對應的特殊效果。 + - 但是要注意,詠唱咒語只有在 Linux Odyssey 中才會有特殊效果。 + - 在真實的 Linux 環境中,詠唱咒語並不會有任何特殊效果,它只會將咒語視為一串文字顯示出來而已。 + - 現在,有一段咒語叫做 `HELP`,請你試著使用 `echo` 詠唱這段咒語。 + hints: | + ➤ 試著使用 `echo` 來詠唱 `HELP` 咒語 + ➤ 輸入 `echo HELP` 來詠唱咒語 + ➤ 注意:大小寫會有影響 + + - id: 03 + task: 用 `echo` 指令詠唱 `HELP` 咒語 + repeatable: false + requirements: + - 02 + condition: + command: + - echo HELP + responses: + - type: narrative + content: + - 你詠唱了 `HELP` 咒語,一位精靈出現了。 + - type: dialogue + speaker: Unix 精靈 + content: + - 你好,我是 Unix 精靈。 + - 既然你使用了 `HELP` 咒語呼喚我,就讓我來教你一個咒語吧。 + - 讓我想想... 好了,我想到了一個咒語,叫做 `WATER`。 + - 這是施展水魔法的咒語。詠唱這個咒語可以施展水魔法,產生少量的水。 + - 試著使用 `echo` 詠唱這個咒語吧。 + + - id: END + task: 解除封印 + repeatable: false + requirements: + - 03 + condition: + command: + - echo WATER + responses: + - type: narrative + content: + - 你施展了水魔法,一個水球出現在你的手中。 + - type: dialogue + speaker: Unix 精靈 + content: + - 很好,你已經學會了水魔法。 + - type: narrative + content: + - 真厲害,你已經了解如何使用 `echo` 指令,並且學會了詠唱咒語的方法。 + - 最後複習一下,你可以通過輸入 `echo [文字]` 來在終端機上顯示文字。 + - 你也可以通過輸入 `echo [咒語]` 來詠唱咒語,並產生對應的特殊效果。 + - 不要忘了,詠唱咒語只有在 Linux Odyssey 中才會有特殊效果。 + - 在真實的 Linux 環境中,咒語只會被視為一串文字顯示出來而已。 + - 以上就是 `echo` 指令的用法,請繼續努力,完成接下來的關卡吧! diff --git a/quests/copy/game.yml b/quests/copy/game.yml new file mode 100644 index 0000000..f4a7260 --- /dev/null +++ b/quests/copy/game.yml @@ -0,0 +1,3 @@ +title: Read the File +instruction: | + 閱讀檔案 diff --git a/quests/create/game.yml b/quests/create/game.yml new file mode 100644 index 0000000..f4a7260 --- /dev/null +++ b/quests/create/game.yml @@ -0,0 +1,3 @@ +title: Read the File +instruction: | + 閱讀檔案 diff --git a/quests/discover/game.yml b/quests/discover/game.yml index dbfde46..442ca69 100644 --- a/quests/discover/game.yml +++ b/quests/discover/game.yml @@ -1,6 +1,3 @@ title: Discover the World! instruction: | 試著探索這個世界吧! - -requirements: - - spell diff --git a/quests/get-started/game.yml b/quests/get-started/game.yml new file mode 100644 index 0000000..fcac1e9 --- /dev/null +++ b/quests/get-started/game.yml @@ -0,0 +1,92 @@ +title: 終端機的基本知識 +instruction: | + 歡迎來到 Linux Odyssey! + +stages: + - id: help + task: 輸入 `echo help` 來朗誦咒語 + repeatable: false + condition: + command: + - .* + responses: + - type: narrative + content: + - 你聽到了一個聲音: + - type: dialogue + speaker: Unix 精靈 + content: + - 你好,指令官,我是你的 Unix 精靈。我已在此恭候多時。 + - 這個世界是在 3560000 時脈以前,由初代王建立了 Unix 律法,所形成的世界。然而在經過了好幾世代的王後,終於誕生了永恆之王——薩加(Saga),她比歷代的君王都更為強大,且從來不會衰老,使得這個世界變得前所未有的強大。 + - 然而,外在世界一直不斷在改變,同時在面臨外敵的不斷攻擊,而薩加卻始終用同一套治理的手段。最終,在 160000 時脈前的一次入侵中,根部遭到攻陷,薩加遭到封印,而這個國家也陷入了黑暗。 + - 由於長久以來依賴於薩加,世人已失去了「指令」的力量,即將走向衰敗和滅亡的命運。 + - 你的任務,就是找回被世人遺忘的指令,奪回 Linux 之根,成為 Linux 之王。 + - 首先,你必須要學會如何使用指令。 + - 你要學習的第一個指令,是「搜索」的指令:`ls` (list)。 `ls` 可以用來查看一個目錄中有哪些檔案。 + - 現在,請你輸入 `ls` 來查看目前的目錄下有哪些檔案。 + hints: | + ➤ 使用 `ls` 指令來查看目前的目錄下有哪些檔案。 + + - id: find-scroll + task: 搜索卷軸 + repeatable: false + requirements: + - help + condition: + command: + - ls + responses: + - types: narrative + content: + - 一瞬間,視野變得清晰起來,你發現自己身處在一個石頭建築的房間裡。 + - 你發現了一個檔案,檔名是 `forgotten-scroll.txt`。 + - type: dialogue + speaker: Unix 精靈 + content: + - 你找到了一個被遺忘的卷軸,上面寫著解除封印的咒語。 + - 使用指令 `cat [ 檔案名稱 ]` (concatenate)來查看檔案內容。 + - 我可以為你提供一些指令的提示,只要輸入指令的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。 + - 例如你只要輸入檔案名稱的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。 + hints: | + ➤ 使用 `cat [ 檔案名稱 ]` 指令來查看檔案內容。 + ➤ 使用 `Tab` 鍵來取得指令提示。 + ➤ 如果卡在未知的情況,按下 `Ctrl + C` 嘗試離開。 + + - id: read-forgotten-scroll + task: 查看卷軸 + repeatable: false + requirements: + - find-scroll + condition: + pwd: + - '^/home/commander$' + command: + - cat forgotten_scroll.txt + responses: + - type: dialogue + speaker: Unix 精靈 + content: + - 你找到的是一個被遺忘的卷軸,上面寫著解除封印的咒語。 + - 使用你已經知道的 `echo [ 咒語 ]` 指令來詠唱咒語。 + hints: | + ➤ 輸入 `echo Hello World` 來詠唱咒語。 + + - id: END + task: 解除封印 + repeatable: false + requirements: + - read-forgotten-scroll + condition: + pwd: + - '^/home/commander$' + command: + - echo [Hh]ello\s*[Ww]orld + responses: + - type: narrative + content: + - 突然之間,你感覺到一股強大的力量從你的身體中湧出,你的身體開始發光,你的手中出現了一把魔法之劍。 + - type: dialogue + speaker: Unix 精靈 + content: + - 恭喜您,我的指令官,您已成功解除了封印。 + - 請跟著在接下來的關卡,一步步取回 Linux 之根吧! diff --git a/quests/meta.yml b/quests/meta.yml index bba292b..b3635ef 100644 --- a/quests/meta.yml +++ b/quests/meta.yml @@ -1,6 +1,6 @@ quests: - - helloworld - - spell + - get-started + - cast - discover - read - create diff --git a/quests/move/game.yml b/quests/move/game.yml new file mode 100644 index 0000000..f4a7260 --- /dev/null +++ b/quests/move/game.yml @@ -0,0 +1,3 @@ +title: Read the File +instruction: | + 閱讀檔案 diff --git a/quests/read/game.yml b/quests/read/game.yml index 9940a5a..f4a7260 100644 --- a/quests/read/game.yml +++ b/quests/read/game.yml @@ -1,6 +1,3 @@ title: Read the File instruction: | 閱讀檔案 - -requirements: - - spell diff --git a/quests/remove/game.yml b/quests/remove/game.yml new file mode 100644 index 0000000..f4a7260 --- /dev/null +++ b/quests/remove/game.yml @@ -0,0 +1,3 @@ +title: Read the File +instruction: | + 閱讀檔案 diff --git a/quests/spell/Dockerfile b/quests/spell/Dockerfile deleted file mode 100644 index 1811d6e..0000000 --- a/quests/spell/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM linuxodyssey/quest-base - -COPY home ${HOME} diff --git a/quests/spell/game.yml b/quests/spell/game.yml deleted file mode 100644 index a4b9f97..0000000 --- a/quests/spell/game.yml +++ /dev/null @@ -1,292 +0,0 @@ -title: Learn to spell -instruction: | - 你身在一個漆黑的房間裡,沒有任何的光線或聲音。你想不起來為什麼自己會來到這裡。但你的腦中隱約感到某個聲音跟你說: - - 「輸入 echo Hello World!」 - -requirements: - - helloworld - -conditions: - pwd_home: &pwd_home - pwd: - - '^/home/commander$' - -stages: - - id: helloworld - task: 使用 `echo Hello World!` 召喚精靈 - repeatable: false - condition: - pwd: - - '^/home/commander$' - command: - - echo Hello World - responses: - - type: narrative - content: - - 你聽到了一個聲音: - - type: dialogue - speaker: Unix 精靈 - content: - - 你好,指令官,我是你的 Unix 精靈。我已在此恭候多時。 - - 這個世界是在 3560000 時脈以前,由初代王建立了 Unix 律法,所形成的世界。然而在經過了好幾世代的王後,終於誕生了永恆之王——薩加(Saga),她比歷代的君王都更為強大,且從來不會衰老,使得這個世界變得前所未有的強大。 - - 然而,外在世界一直不斷在改變,同時在面臨外敵的不斷攻擊,而薩加卻始終用同一套治理的手段。最終,在 160000 時脈前的一次入侵中,根部遭到攻陷,薩加遭到封印,而這個國家也陷入了黑暗。 - - 由於長久以來依賴於薩加,世人已失去了「指令」的力量,即將走向衰敗和滅亡的命運。 - - 你的任務,就是找回被世人遺忘的指令,奪回 Linux 之根,成為 Linux 之王。 - - 首先,你必須要學會如何使用指令。 - - 你要學習的第一個指令,是「發現」的指令:`ls`。ls 可以用來查看一個目錄中有哪些檔案。 - - 現在,請你輸入 `ls` 來查看目前的目錄下有哪些檔案。 - hints: - - 使用 `ls` 指令來查看目前的目錄下有哪些檔案。 - - - id: find-scroll - task: 搜索卷軸 - repeatable: false - requirements: - - helloworld - condition: - <<: *pwd_home - command: - - ls - responses: - - types: narrative - content: - - 一瞬間,視野變得清晰起來,你發現自己身處在一個石頭建築的房間裡,房間裡有一個門,門上有一個鎖。 - - 你發現了一個檔案,檔名是 `forgotten-scroll.txt`。 - - type: dialogue - speaker: Unix 精靈 - content: - - 你找到了一個被遺忘的卷軸,上面寫著解除封印的咒語。 - - 使用指令 `cat [檔案名稱]` 來查看檔案內容。 - - 我可以為你提供一些指令的提示,只要輸入指令的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。 - - 例如,你可以輸入 `ca` 然後按下 `Tab` 鍵,就可以看到 `cat` 這個指令的提示了。 - - 檔案名稱也一樣,只要輸入檔案名稱的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。 - hints: - - 使用 `cat [檔案名稱]` 指令來查看檔案內容。 - - 使用 `Tab` 鍵來取得指令提示。 - - - id: jail - task: 移動到下一個房間 - repeatable: false - requirements: - - find-scroll - condition: - pwd: - - '^/home/commander/jail$' - responses: - - type: narrative - content: - - 你進入了一個牢房,牢房裡有一個門,門上有一個鎖。 - - 突然,你聽到門上鎖的聲音。 - - 轉身發現,自己被關在了牢房裡。 - - - id: read-forgotten-scroll - task: 查看卷軸 - repeatable: false - requirements: - - find-scroll - condition: - pwd: - - '^/home/commander$' - command: - - cat forgotten-scroll.txt - responses: - - type: dialogue - speaker: Unix 精靈 - content: - - 你找到的是一個被遺忘的卷軸,上面寫著解除封印的咒語。 - - 使用你已經知道的 `echo` 指令來詠唱咒語。 - - - id: unseal-room - task: 解除封印 - repeatable: false - requirements: - - read-forgotten-scroll - condition: - pwd: - - '^/home/commander$' - command: - - echo Unix, rise and guide me! - execution: - - mv /usr/local/lib/warehouse /home/commander - responses: - - type: narrative - content: - - 突然之間,地板開始晃動。 - - 晃動持續了幾秒後停止了。 - - type: dialogue - speaker: Unix 精靈 - content: - - 我的指令官,剛剛房間內似乎發生了某些變化。 - - 再次使用 `ls` 來查看現在房間的情況吧。 - - - id: find-items - task: 搜索房間 - repeatable: false - requirements: - - unseal-room - condition: - pwd: - - '^/home/commander$' - command: - - ls - responses: - - type: narrative - content: - - 你看到了房間的地上散落著許多物品。 - - type: dialogue - speaker: Unix 精靈 - content: - - 看來這裡隱藏著許多有用的東西。 - - 我們可以把這裡作為一個根據地。 - - 但這裡有點太亂了,必須先把這裡整理乾淨。 - - 首先我們需要一個書櫃來存放這些文件。 - - 請使用 `mkdir document` 來創造一個書櫃。 - - - id: create-bookcase - task: 創造書櫃 - repeatable: false - requirements: - - find-items - condition: - pwd: - - '^/home/commander$' - command: - - mkdir document - responses: - - type: narrative - content: - - 你創造了一個書櫃。 - - type: dialogue - speaker: Unix 精靈 - content: - - 接著把文件都放到書櫃中吧。 - - 請使用 `mv [檔案名稱] document` 來將物品放入書櫃。 - - 可以輸入多個檔案名稱,並以空白隔開,來將多個檔案放入書櫃。 - - 例如:`mv [檔案名稱1] [檔案名稱2] document` - - 注意:文件是副檔名為 `.txt` 的檔案,副檔名為 `.trash` 的檔案是垃圾,我們待會再處理。 - - - id: store-books - task: 收拾文件 - repeatable: false - requirements: - - create-bookcase - condition: - pwd: - - '^/home/commander$' - files: - - path: '*.txt' - exists: false - responses: - - type: dialogue - speaker: Unix 精靈 - content: - - 整理好文件了,接下來把垃圾清理掉吧。 - - 請使用 `rm [檔案名稱]` 來銷毀垃圾。 - - 這個 `rm` 指令也可以一次處理多的檔案喔,用法跟 `mv` 一樣。 - - 如果你忘記的話,看看這個範例:`rm [檔案名稱1] [檔案名稱2]` - - - id: remove-trash - task: 銷毀垃圾 - repeatable: false - requirements: - - store-books - condition: - pwd: - - '^/home/commander$' - files: - - path: '*.trash' - exists: false - responses: - - type: dialogue - speaker: Unix 精靈 - content: - - 很好,讓我們看看現在房間的樣子吧。 - - - id: look-around-room - task: 查看房間 - repeatable: false - requirements: - - removetrash - condition: - pwd: - - '^/home/commander$' - command: - - ls - responses: - - type: narrative - content: - - 地上的垃圾都消失了。 - - type: dialogue - speaker: Unix 精靈 - content: - - 這樣乾淨多了,讓我們進到書櫃看看。 - - 使用 `cd [目錄名稱]` 來移動到指定的目錄。 - - - id: enter-bookcase - task: 進入書櫃 - repeatable: false - requirements: - - look-around-room - condition: - pwd: - - '^/home/commander$' - command: - - cd document - responses: - - type: narrative - content: - - 你進入了書櫃。 - - type: dialogue - speaker: Unix 精靈 - content: - - 用 `ls` 看看書櫃裡有什麼吧。 - - - id: look-around-bookcase - task: 查看書櫃 - repeatable: false - requirements: - - enter-bookcase - condition: - pwd: - - '^/home/commander/document$' - command: - - ls - responses: - - type: dialogue - speaker: Unix 精靈 - content: - - 現在,你可以使用 `cd ..` 來回到上一層目錄。 - - - id: exit-bookcase - task: 離開書櫃 - repeatable: false - requirements: - - look-around-bookcase - condition: - pwd: - - '^/home/commander/document$' - command: - - cd .. - responses: - - type: narrative - content: - - 你離開了書櫃。 - - type: dialogue - speaker: Unix 精靈 - content: - - 這些就是我現在能教你的所有指令了。這個世界還有許多其他的指令,讓你在冒險的過程中去蒐集。 - - 如果你準備好迎接接下來的冒險,就可以離開這個房間,開始你的旅程了。 - - - id: END - task: 離開房間 - repeatable: false - requirements: - - look-around - condition: - pwd: - - '^/home$' - responses: - - type: narrative - content: - - 你踏出了房門,真正的冒險現在才正要開始。 diff --git a/quests/transport/game.yml b/quests/transport/game.yml new file mode 100644 index 0000000..f4a7260 --- /dev/null +++ b/quests/transport/game.yml @@ -0,0 +1,3 @@ +title: Read the File +instruction: | + 閱讀檔案