diff --git a/packages/models/quest.js b/packages/models/quest.js index 84c1966..bb4ca73 100644 --- a/packages/models/quest.js +++ b/packages/models/quest.js @@ -10,6 +10,25 @@ const responseSchema = new Schema({ color: String, }) +const fileConditionSchema = new Schema({ + path: String, + type: String, + exists: Boolean, +}) + +const conditionSchema = new Schema({ + command: [String], + output: [String], + error: [String], + pwd: [String], + files: [fileConditionSchema], +}) + +conditionSchema.add({ + OR: [conditionSchema], + NOT: conditionSchema, +}) + const stageSchema = new Schema({ id: { type: String, @@ -29,12 +48,7 @@ const stageSchema = new Schema({ required: true, default: false, }, - condition: { - command: [String], - output: [String], - error: [String], - pwd: [String], - }, + condition: conditionSchema, responses: { type: [responseSchema], required: true, @@ -52,18 +66,6 @@ const Quest = model( title: String, order: Number, instruction: String, - tasks: { - id: String, - content: String, - display: { - type: Boolean, - default: false, - }, - completed: { - type: Boolean, - default: false, - }, - }, stages: [stageSchema], }) ) diff --git a/quests/helloworld/game.yml b/quests/helloworld/game.yml index 5a3be6a..c9e7fb7 100644 --- a/quests/helloworld/game.yml +++ b/quests/helloworld/game.yml @@ -168,8 +168,9 @@ stages: condition: pwd: - '^/home/commander$' - include: - - !*.txt + files: + - path: '*.txt' + exists: false responses: - type: dialogue speaker: Unix 精靈 @@ -178,7 +179,7 @@ stages: - 請使用 `rm [檔案名稱]` 來銷毀垃圾。 - 這個 `rm` 指令也可以一次處理多的檔案喔,用法跟 `mv` 一樣。 - 如果你忘記的話,看看這個範例:`rm [檔案名稱1] [檔案名稱2]` -scroll + - id: remove-trash task: 銷毀垃圾 repeatable: false @@ -187,8 +188,9 @@ scroll condition: pwd: - '^/home/commander$' - include: - - !*.trash + files: + - path: '*.trash' + exists: false responses: - type: dialogue speaker: Unix 精靈 @@ -248,7 +250,7 @@ scroll - type: dialogue speaker: Unix 精靈 content: - - 現在,你可以使用 `cd ..` 來回到上一層目錄。 + - 現在,你可以使用 `cd ..` 來回到上一層目錄。 - id: exit-bookcase task: 離開書櫃 @@ -282,4 +284,3 @@ scroll - type: narrative content: - 你踏出了房門,真正的冒險現在才正要開始。 - \ No newline at end of file