From faad903863504bbc03d417803704339e99bdb064 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Wed, 5 Oct 2022 13:01:32 -0500 Subject: [PATCH] Add `author` (optional) and `version` (required) fields to scenarios (#719) Closes #611 . --- data/scenarios/Challenges/2048.yaml | 2 ++ .../Challenges/Mazes/easy_cave_maze.yaml | 2 ++ .../Challenges/Mazes/easy_spiral_maze.yaml | 2 ++ .../Challenges/Mazes/invisible_maze.yaml | 2 ++ .../Challenges/Mazes/loopy_maze.yaml | 2 ++ data/scenarios/Challenges/chess_horse.yaml | 2 ++ data/scenarios/Challenges/hanoi.yaml | 2 ++ data/scenarios/Challenges/teleport.yaml | 2 ++ data/scenarios/Fun/GoL.yaml | 2 ++ data/scenarios/README.md | 2 ++ data/scenarios/Speedruns/curry.yaml | 2 ++ data/scenarios/Speedruns/forester.yaml | 2 ++ data/scenarios/Speedruns/mithril.yaml | 2 ++ .../201-require-device-creative.yaml | 1 + .../201-require-device-creative1.yaml | 1 + .../201-require/201-require-device.yaml | 1 + .../201-require/201-require-entities-def.yaml | 1 + .../201-require/201-require-entities.yaml | 1 + .../201-require/533-reprogram-simple.yaml | 1 + .../Testing/201-require/533-reprogram.yaml | 1 + data/scenarios/Testing/373-drill.yaml | 1 + data/scenarios/Testing/378-objectives.yaml | 3 ++- data/scenarios/Testing/394-build-drill.yaml | 1 + .../Testing/428-drowning-destroy.yaml | 1 + data/scenarios/Testing/475-wait-one.yaml | 1 + data/scenarios/Testing/479-atomic-race.yaml | 1 + data/scenarios/Testing/479-atomic.yaml | 1 + data/scenarios/Testing/490-harvest.yaml | 1 + data/scenarios/Testing/504-teleport-self.yaml | 1 + .../Testing/508-capability-subset.yaml | 1 + .../Testing/555-teleport-location.yaml | 1 + data/scenarios/Testing/562-lodestone.yaml | 1 + data/scenarios/Testing/684-swap.yaml | 1 + .../699-movement-fail/699-move-blocked.yaml | 1 + .../699-movement-fail/699-move-liquid.yaml | 1 + .../699-teleport-blocked.yaml | 1 + data/scenarios/Testing/710-multi-robot.yaml | 1 + data/scenarios/Tutorials/backstory.yaml | 1 + data/scenarios/Tutorials/bind.yaml | 1 + data/scenarios/Tutorials/build.yaml | 1 + data/scenarios/Tutorials/conditionals.yaml | 1 + data/scenarios/Tutorials/craft.yaml | 1 + data/scenarios/Tutorials/crash.yaml | 1 + data/scenarios/Tutorials/def.yaml | 1 + data/scenarios/Tutorials/farming.yaml | 1 + data/scenarios/Tutorials/grab.yaml | 1 + data/scenarios/Tutorials/install.yaml | 1 + data/scenarios/Tutorials/lambda.yaml | 1 + data/scenarios/Tutorials/move.yaml | 1 + data/scenarios/Tutorials/place.yaml | 1 + data/scenarios/Tutorials/require.yaml | 1 + data/scenarios/Tutorials/requireinv.yaml | 1 + data/scenarios/Tutorials/scan.yaml | 1 + data/scenarios/Tutorials/turn.yaml | 1 + data/scenarios/Tutorials/type-errors.yaml | 1 + data/scenarios/Tutorials/types.yaml | 1 + data/scenarios/Tutorials/world101.yaml | 1 + data/scenarios/classic.yaml | 1 + data/scenarios/creative.yaml | 3 ++- data/schema/scenario.json | 11 ++++++++++- src/Swarm/Game/Scenario.hs | 19 +++++++++++++++++-- src/Swarm/TUI/Attr.hs | 4 ++++ src/Swarm/TUI/View.hs | 9 +++++++-- 63 files changed, 112 insertions(+), 7 deletions(-) diff --git a/data/scenarios/Challenges/2048.yaml b/data/scenarios/Challenges/2048.yaml index 8f13cdde..fd51421c 100644 --- a/data/scenarios/Challenges/2048.yaml +++ b/data/scenarios/Challenges/2048.yaml @@ -1,4 +1,6 @@ +version: 1 name: "2048" +author: Brent Yorgey description: Make 2048! objectives: - goal: diff --git a/data/scenarios/Challenges/Mazes/easy_cave_maze.yaml b/data/scenarios/Challenges/Mazes/easy_cave_maze.yaml index 826b3437..f264230c 100644 --- a/data/scenarios/Challenges/Mazes/easy_cave_maze.yaml +++ b/data/scenarios/Challenges/Mazes/easy_cave_maze.yaml @@ -1,4 +1,6 @@ +version: 1 name: Cave shaped maze +author: Ondřej Šebek description: A maze shaped like a cave. It only goes down or forward. objectives: - goal: diff --git a/data/scenarios/Challenges/Mazes/easy_spiral_maze.yaml b/data/scenarios/Challenges/Mazes/easy_spiral_maze.yaml index 1cb39e8c..cc3ea2e5 100644 --- a/data/scenarios/Challenges/Mazes/easy_spiral_maze.yaml +++ b/data/scenarios/Challenges/Mazes/easy_spiral_maze.yaml @@ -1,4 +1,6 @@ +version: 1 name: Spiral shaped maze +author: Ondřej Šebek description: A maze shaped like a spiral, with a twist! objectives: - goal: diff --git a/data/scenarios/Challenges/Mazes/invisible_maze.yaml b/data/scenarios/Challenges/Mazes/invisible_maze.yaml index 07624575..fe5965dc 100644 --- a/data/scenarios/Challenges/Mazes/invisible_maze.yaml +++ b/data/scenarios/Challenges/Mazes/invisible_maze.yaml @@ -1,4 +1,6 @@ +version: 1 name: Invisible maze +author: Brent Yorgey description: There is a maze, but it can't be seen, only sensed... can you program a robot to navigate it successfully? objectives: diff --git a/data/scenarios/Challenges/Mazes/loopy_maze.yaml b/data/scenarios/Challenges/Mazes/loopy_maze.yaml index c8256d67..10256bc8 100644 --- a/data/scenarios/Challenges/Mazes/loopy_maze.yaml +++ b/data/scenarios/Challenges/Mazes/loopy_maze.yaml @@ -1,4 +1,6 @@ +version: 1 name: Invisible, loopy maze +author: Brent Yorgey description: There is a maze, but it can't be seen, only sensed... can you program a robot to navigate it successfully? objectives: diff --git a/data/scenarios/Challenges/chess_horse.yaml b/data/scenarios/Challenges/chess_horse.yaml index bc021674..ae9029bb 100644 --- a/data/scenarios/Challenges/chess_horse.yaml +++ b/data/scenarios/Challenges/chess_horse.yaml @@ -1,4 +1,6 @@ +version: 1 name: Chess Knight +author: Ondřej Šebek description: In this quirky challenge, you move as the chess knight piece. Can you capture the enemy king? objectives: - goal: diff --git a/data/scenarios/Challenges/hanoi.yaml b/data/scenarios/Challenges/hanoi.yaml index d6d2e1dc..6a3acbf7 100644 --- a/data/scenarios/Challenges/hanoi.yaml +++ b/data/scenarios/Challenges/hanoi.yaml @@ -1,4 +1,6 @@ +version: 1 name: Towers of Hanoi +author: Ondřej Šebek and Brent Yorgey description: The classic Towers of Hanoi puzzle with three disks. objectives: - goal: diff --git a/data/scenarios/Challenges/teleport.yaml b/data/scenarios/Challenges/teleport.yaml index ddf4345d..9cb57375 100644 --- a/data/scenarios/Challenges/teleport.yaml +++ b/data/scenarios/Challenges/teleport.yaml @@ -1,4 +1,6 @@ +version: 1 name: Portal room +author: Ondřej Šebek description: An impossible challenge - can you magically jump across the water? objectives: - goal: diff --git a/data/scenarios/Fun/GoL.yaml b/data/scenarios/Fun/GoL.yaml index 92cfe19b..f3e172de 100644 --- a/data/scenarios/Fun/GoL.yaml +++ b/data/scenarios/Fun/GoL.yaml @@ -1,4 +1,6 @@ +version: 1 name: Conway's Game of Life +author: Brent Yorgey description: A basic implementation of the rules of the Game of Life. robots: - name: base diff --git a/data/scenarios/README.md b/data/scenarios/README.md index 965805fb..7316f5a4 100644 --- a/data/scenarios/README.md +++ b/data/scenarios/README.md @@ -120,8 +120,10 @@ described by the following table. | Key | Default? | Type | Description | |----------------|----------|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `version` | | `int` | The version number of the scenario schema. Currently, this should always be 1. | | `name` | | `string` | The name of the scenario. For official scenarios, this is what shows up in the new game menu. | | `description` | `""` | `string` | A short description of the scenario. This shows up next to the new game menu when the scenario is selected. | +| `author` | `null` | `string` | The author of the scenario (optional). Typically this is a person's name, but it can be any string. It is displayed under the scenario description in the new game menu. | | `creative` | `False` | `boolean` | Whether the scenario should start out in creative mode. | | `seed` | `null` | `int` | An optional seed that will be used to seed the random number generator. If a procedurally generated world is used, the seed hence determines the world. Hence, if the seed is specified, the procedurally generated world will be exactly the same every time, for every player. If omitted, a random seed will be used every time the scenario is loaded. | | `entities` | `[]` | [`entity`](#entities) list | An optional list of custom entities, to be used in addition to the built-in entities. See [Entities](#entities). | diff --git a/data/scenarios/Speedruns/curry.yaml b/data/scenarios/Speedruns/curry.yaml index 603029cc..d473ef61 100644 --- a/data/scenarios/Speedruns/curry.yaml +++ b/data/scenarios/Speedruns/curry.yaml @@ -1,4 +1,6 @@ +version: 1 name: Curry +author: Brent Yorgey description: Race to make a bowl of curry as fast as possible. See the Swarm wiki for more information on Swarm speedrunning. objectives: diff --git a/data/scenarios/Speedruns/forester.yaml b/data/scenarios/Speedruns/forester.yaml index ade36f5c..fcf6c34c 100644 --- a/data/scenarios/Speedruns/forester.yaml +++ b/data/scenarios/Speedruns/forester.yaml @@ -1,4 +1,6 @@ +version: 1 name: Forester +author: Brent Yorgey description: Race to harvest 1024 trees as quickly as possible. See the Swarm wiki for more information on Swarm speedrunning. objectives: diff --git a/data/scenarios/Speedruns/mithril.yaml b/data/scenarios/Speedruns/mithril.yaml index c9895fc3..8a838ab2 100644 --- a/data/scenarios/Speedruns/mithril.yaml +++ b/data/scenarios/Speedruns/mithril.yaml @@ -1,4 +1,6 @@ +version: 1 name: Mithril +author: Brent Yorgey description: Race to mine some mithril. See the Swarm wiki for more information on Swarm speedrunning. objectives: diff --git a/data/scenarios/Testing/201-require/201-require-device-creative.yaml b/data/scenarios/Testing/201-require/201-require-device-creative.yaml index a3bfaa64..fd933b16 100644 --- a/data/scenarios/Testing/201-require/201-require-device-creative.yaml +++ b/data/scenarios/Testing/201-require/201-require-device-creative.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require device in creative mode description: | Require a device using the 'require' command in creative mode. diff --git a/data/scenarios/Testing/201-require/201-require-device-creative1.yaml b/data/scenarios/Testing/201-require/201-require-device-creative1.yaml index 00f5227a..484d3b03 100644 --- a/data/scenarios/Testing/201-require/201-require-device-creative1.yaml +++ b/data/scenarios/Testing/201-require/201-require-device-creative1.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require existing device in creative mode description: | Require a device the base has using the 'require' command in creative mode. diff --git a/data/scenarios/Testing/201-require/201-require-device.yaml b/data/scenarios/Testing/201-require/201-require-device.yaml index b92c610f..2f7174b4 100644 --- a/data/scenarios/Testing/201-require/201-require-device.yaml +++ b/data/scenarios/Testing/201-require/201-require-device.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require device description: | Require a device using the 'require' command. diff --git a/data/scenarios/Testing/201-require/201-require-entities-def.yaml b/data/scenarios/Testing/201-require/201-require-entities-def.yaml index 3dd1c1aa..f6c54dfc 100644 --- a/data/scenarios/Testing/201-require/201-require-entities-def.yaml +++ b/data/scenarios/Testing/201-require/201-require-entities-def.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require entities with definition description: | Require some entities using the 'require' command, and a definition. diff --git a/data/scenarios/Testing/201-require/201-require-entities.yaml b/data/scenarios/Testing/201-require/201-require-entities.yaml index 4b8d70ee..b46e8251 100644 --- a/data/scenarios/Testing/201-require/201-require-entities.yaml +++ b/data/scenarios/Testing/201-require/201-require-entities.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require entities description: | Require some entities using the 'require' command. diff --git a/data/scenarios/Testing/201-require/533-reprogram-simple.yaml b/data/scenarios/Testing/201-require/533-reprogram-simple.yaml index d0207835..e3806d99 100644 --- a/data/scenarios/Testing/201-require/533-reprogram-simple.yaml +++ b/data/scenarios/Testing/201-require/533-reprogram-simple.yaml @@ -1,3 +1,4 @@ +version: 1 name: Install devices while reprogramming description: | While executing 'reprogram', we should install any required devices which diff --git a/data/scenarios/Testing/201-require/533-reprogram.yaml b/data/scenarios/Testing/201-require/533-reprogram.yaml index dc33b250..9b4ef9f0 100644 --- a/data/scenarios/Testing/201-require/533-reprogram.yaml +++ b/data/scenarios/Testing/201-require/533-reprogram.yaml @@ -1,3 +1,4 @@ +version: 1 name: Install devices + entities while reprogramming description: | While executing 'reprogram', we should install any required devices and diff --git a/data/scenarios/Testing/373-drill.yaml b/data/scenarios/Testing/373-drill.yaml index 76432afd..b4741c89 100644 --- a/data/scenarios/Testing/373-drill.yaml +++ b/data/scenarios/Testing/373-drill.yaml @@ -1,3 +1,4 @@ +version: 1 name: Drill test description: A developer playground for drilling. objectives: diff --git a/data/scenarios/Testing/378-objectives.yaml b/data/scenarios/Testing/378-objectives.yaml index 4f29b966..9601370b 100644 --- a/data/scenarios/Testing/378-objectives.yaml +++ b/data/scenarios/Testing/378-objectives.yaml @@ -1,3 +1,4 @@ +version: 1 name: Complete two objectives in succession. description: | First, get some trees; then, use them to build a harvester. @@ -57,4 +58,4 @@ world: map: | ┌────────┐ │Ω.TTTTTT│ - └────────┘ \ No newline at end of file + └────────┘ diff --git a/data/scenarios/Testing/394-build-drill.yaml b/data/scenarios/Testing/394-build-drill.yaml index 7adbb1f2..1d09d720 100644 --- a/data/scenarios/Testing/394-build-drill.yaml +++ b/data/scenarios/Testing/394-build-drill.yaml @@ -1,3 +1,4 @@ +version: 1 name: Test build with drill description: | Inner build does not correctly require Drill. diff --git a/data/scenarios/Testing/428-drowning-destroy.yaml b/data/scenarios/Testing/428-drowning-destroy.yaml index 9bf2657c..50f73c2e 100644 --- a/data/scenarios/Testing/428-drowning-destroy.yaml +++ b/data/scenarios/Testing/428-drowning-destroy.yaml @@ -1,3 +1,4 @@ +version: 1 name: Drowning results in destruction description: | Destroying robots doesn't work. diff --git a/data/scenarios/Testing/475-wait-one.yaml b/data/scenarios/Testing/475-wait-one.yaml index f0f95dc6..fc146444 100644 --- a/data/scenarios/Testing/475-wait-one.yaml +++ b/data/scenarios/Testing/475-wait-one.yaml @@ -1,3 +1,4 @@ +version: 1 name: Wait for one tick description: | Robots waiting for one tick should not be put into inactive robot queue. diff --git a/data/scenarios/Testing/479-atomic-race.yaml b/data/scenarios/Testing/479-atomic-race.yaml index dd48a720..63be6354 100644 --- a/data/scenarios/Testing/479-atomic-race.yaml +++ b/data/scenarios/Testing/479-atomic-race.yaml @@ -15,6 +15,7 @@ # This may work slightly less well once we implement #502, but I think it should # still work. +version: 1 name: Grab/harvest/place (with race) description: | Make sure we can cause a robot to crash due to a race condition, in order to diff --git a/data/scenarios/Testing/479-atomic.yaml b/data/scenarios/Testing/479-atomic.yaml index d01b7258..10ef68de 100644 --- a/data/scenarios/Testing/479-atomic.yaml +++ b/data/scenarios/Testing/479-atomic.yaml @@ -1,5 +1,6 @@ # See also 479-atomic-race. +version: 1 name: Atomic grab/harvest/place description: | 'atomic' blocks should be able to prevent crashes due to race conditions diff --git a/data/scenarios/Testing/490-harvest.yaml b/data/scenarios/Testing/490-harvest.yaml index 23d619e1..8a93d84a 100644 --- a/data/scenarios/Testing/490-harvest.yaml +++ b/data/scenarios/Testing/490-harvest.yaml @@ -1,3 +1,4 @@ +version: 1 name: Test harvest command description: | Test the difference between the grab and harvest commands, diff --git a/data/scenarios/Testing/504-teleport-self.yaml b/data/scenarios/Testing/504-teleport-self.yaml index 5aa2664b..9dc3118f 100644 --- a/data/scenarios/Testing/504-teleport-self.yaml +++ b/data/scenarios/Testing/504-teleport-self.yaml @@ -1,3 +1,4 @@ +version: 1 name: Teleport self in win condition check description: | `teleport self` did not work in the win condition check. diff --git a/data/scenarios/Testing/508-capability-subset.yaml b/data/scenarios/Testing/508-capability-subset.yaml index 841c4c77..aee04656 100644 --- a/data/scenarios/Testing/508-capability-subset.yaml +++ b/data/scenarios/Testing/508-capability-subset.yaml @@ -1,3 +1,4 @@ +version: 1 name: Install one device description: | Install least amount of devices that provide needed capabilities diff --git a/data/scenarios/Testing/555-teleport-location.yaml b/data/scenarios/Testing/555-teleport-location.yaml index b314ca06..4a5828bf 100644 --- a/data/scenarios/Testing/555-teleport-location.yaml +++ b/data/scenarios/Testing/555-teleport-location.yaml @@ -1,3 +1,4 @@ +version: 1 name: Teleport updates robotsByLocation description: | Teleporting another robot should correctly update the robotsByLocation map. diff --git a/data/scenarios/Testing/562-lodestone.yaml b/data/scenarios/Testing/562-lodestone.yaml index 95a178a3..e8e5d9f9 100644 --- a/data/scenarios/Testing/562-lodestone.yaml +++ b/data/scenarios/Testing/562-lodestone.yaml @@ -1,3 +1,4 @@ +version: 1 name: Test lodestone description: Pick or drill lodestone and use it to flip bits. goal: diff --git a/data/scenarios/Testing/684-swap.yaml b/data/scenarios/Testing/684-swap.yaml index d4e86847..11fb64eb 100644 --- a/data/scenarios/Testing/684-swap.yaml +++ b/data/scenarios/Testing/684-swap.yaml @@ -1,3 +1,4 @@ +version: 1 name: Swap in one tick description: | Swapping an entity should be done in one tick. diff --git a/data/scenarios/Testing/699-movement-fail/699-move-blocked.yaml b/data/scenarios/Testing/699-movement-fail/699-move-blocked.yaml index 1bc30e96..791bdfcb 100644 --- a/data/scenarios/Testing/699-movement-fail/699-move-blocked.yaml +++ b/data/scenarios/Testing/699-movement-fail/699-move-blocked.yaml @@ -1,3 +1,4 @@ +version: 1 name: Move to blocked description: | Robot moving to blocked location results in its destruction. diff --git a/data/scenarios/Testing/699-movement-fail/699-move-liquid.yaml b/data/scenarios/Testing/699-movement-fail/699-move-liquid.yaml index 04886aab..59132b7f 100644 --- a/data/scenarios/Testing/699-movement-fail/699-move-liquid.yaml +++ b/data/scenarios/Testing/699-movement-fail/699-move-liquid.yaml @@ -1,3 +1,4 @@ +version: 1 name: Move to liquid description: | Robot moving to water location results in its drowning. diff --git a/data/scenarios/Testing/699-movement-fail/699-teleport-blocked.yaml b/data/scenarios/Testing/699-movement-fail/699-teleport-blocked.yaml index ea643cf1..ef9b1e29 100644 --- a/data/scenarios/Testing/699-movement-fail/699-teleport-blocked.yaml +++ b/data/scenarios/Testing/699-movement-fail/699-teleport-blocked.yaml @@ -1,3 +1,4 @@ +version: 1 name: Teleport to blocked description: | Teleporting self or another robot to blocked location results in destruction of that robot. diff --git a/data/scenarios/Testing/710-multi-robot.yaml b/data/scenarios/Testing/710-multi-robot.yaml index 72f929ff..b6f8f488 100644 --- a/data/scenarios/Testing/710-multi-robot.yaml +++ b/data/scenarios/Testing/710-multi-robot.yaml @@ -1,3 +1,4 @@ +version: 1 name: Multiple robots in palette description: | Using multiple robots in palette to open new rooms. diff --git a/data/scenarios/Tutorials/backstory.yaml b/data/scenarios/Tutorials/backstory.yaml index 5e8d379e..c8caec21 100644 --- a/data/scenarios/Tutorials/backstory.yaml +++ b/data/scenarios/Tutorials/backstory.yaml @@ -1,3 +1,4 @@ +version: 1 name: Backstory description: | Introduction to the backstory of Swarm. diff --git a/data/scenarios/Tutorials/bind.yaml b/data/scenarios/Tutorials/bind.yaml index 8e8e7e21..322d198d 100644 --- a/data/scenarios/Tutorials/bind.yaml +++ b/data/scenarios/Tutorials/bind.yaml @@ -1,3 +1,4 @@ +version: 1 name: Bind notation description: | Learn about command return types and how to bind the results. diff --git a/data/scenarios/Tutorials/build.yaml b/data/scenarios/Tutorials/build.yaml index d670fc26..e2e7fdb2 100644 --- a/data/scenarios/Tutorials/build.yaml +++ b/data/scenarios/Tutorials/build.yaml @@ -1,3 +1,4 @@ +version: 1 name: Build description: | Learn how to build robots to carry out simple tasks. diff --git a/data/scenarios/Tutorials/conditionals.yaml b/data/scenarios/Tutorials/conditionals.yaml index 8078fbe0..0975eef1 100644 --- a/data/scenarios/Tutorials/conditionals.yaml +++ b/data/scenarios/Tutorials/conditionals.yaml @@ -1,3 +1,4 @@ +version: 1 name: Conditionals description: | Learn how to write conditional expressions. diff --git a/data/scenarios/Tutorials/craft.yaml b/data/scenarios/Tutorials/craft.yaml index 6ca2d857..2f6a8c43 100644 --- a/data/scenarios/Tutorials/craft.yaml +++ b/data/scenarios/Tutorials/craft.yaml @@ -1,3 +1,4 @@ +version: 1 name: Crafting description: | Learn how to make new things using recipes. diff --git a/data/scenarios/Tutorials/crash.yaml b/data/scenarios/Tutorials/crash.yaml index 78caf7f9..808f8dc7 100644 --- a/data/scenarios/Tutorials/crash.yaml +++ b/data/scenarios/Tutorials/crash.yaml @@ -1,3 +1,4 @@ +version: 1 name: Debug description: | Learn how to view built robots and debug them. diff --git a/data/scenarios/Tutorials/def.yaml b/data/scenarios/Tutorials/def.yaml index 5c837cae..4850e440 100644 --- a/data/scenarios/Tutorials/def.yaml +++ b/data/scenarios/Tutorials/def.yaml @@ -1,3 +1,4 @@ +version: 1 name: Define description: | Learn how to define new commands. diff --git a/data/scenarios/Tutorials/farming.yaml b/data/scenarios/Tutorials/farming.yaml index f20df6d3..c7d7ef48 100644 --- a/data/scenarios/Tutorials/farming.yaml +++ b/data/scenarios/Tutorials/farming.yaml @@ -1,3 +1,4 @@ +version: 1 name: Farming description: | Learn how to build a farm to grow and harvest items. diff --git a/data/scenarios/Tutorials/grab.yaml b/data/scenarios/Tutorials/grab.yaml index 983f48d3..acabbc9a 100644 --- a/data/scenarios/Tutorials/grab.yaml +++ b/data/scenarios/Tutorials/grab.yaml @@ -1,3 +1,4 @@ +version: 1 name: Grab description: | Learn how to interact with the world by grabbing entities. diff --git a/data/scenarios/Tutorials/install.yaml b/data/scenarios/Tutorials/install.yaml index 22284995..bdab354d 100644 --- a/data/scenarios/Tutorials/install.yaml +++ b/data/scenarios/Tutorials/install.yaml @@ -1,3 +1,4 @@ +version: 1 name: Install description: | Learn how to install devices and gain new capabilities. diff --git a/data/scenarios/Tutorials/lambda.yaml b/data/scenarios/Tutorials/lambda.yaml index 0dab430e..8255f631 100644 --- a/data/scenarios/Tutorials/lambda.yaml +++ b/data/scenarios/Tutorials/lambda.yaml @@ -1,3 +1,4 @@ +version: 1 name: Lambda description: | Learn how to define functions. diff --git a/data/scenarios/Tutorials/move.yaml b/data/scenarios/Tutorials/move.yaml index 05e57548..0c0eae69 100644 --- a/data/scenarios/Tutorials/move.yaml +++ b/data/scenarios/Tutorials/move.yaml @@ -1,3 +1,4 @@ +version: 1 name: Moving, part 1 description: | Learn how to move and chain commands. diff --git a/data/scenarios/Tutorials/place.yaml b/data/scenarios/Tutorials/place.yaml index 536b2055..83305034 100644 --- a/data/scenarios/Tutorials/place.yaml +++ b/data/scenarios/Tutorials/place.yaml @@ -1,3 +1,4 @@ +version: 1 name: Place description: | Learn how to interact with the world by harvesting entities and placing them. diff --git a/data/scenarios/Tutorials/require.yaml b/data/scenarios/Tutorials/require.yaml index 203918b4..28b2f5f5 100644 --- a/data/scenarios/Tutorials/require.yaml +++ b/data/scenarios/Tutorials/require.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require devices description: | Learn how to require additional devices that would otherwise not be installed. diff --git a/data/scenarios/Tutorials/requireinv.yaml b/data/scenarios/Tutorials/requireinv.yaml index 60cc304f..0c4382ba 100644 --- a/data/scenarios/Tutorials/requireinv.yaml +++ b/data/scenarios/Tutorials/requireinv.yaml @@ -1,3 +1,4 @@ +version: 1 name: Require inventory description: | Learn how to require inventory when building robots. diff --git a/data/scenarios/Tutorials/scan.yaml b/data/scenarios/Tutorials/scan.yaml index 25eca71b..995cb98a 100644 --- a/data/scenarios/Tutorials/scan.yaml +++ b/data/scenarios/Tutorials/scan.yaml @@ -1,3 +1,4 @@ +version: 1 name: Scan description: | Learn how to send robots to safely scan your surroundings. diff --git a/data/scenarios/Tutorials/turn.yaml b/data/scenarios/Tutorials/turn.yaml index 4eecf386..48dacb5f 100644 --- a/data/scenarios/Tutorials/turn.yaml +++ b/data/scenarios/Tutorials/turn.yaml @@ -1,3 +1,4 @@ +version: 1 name: Moving, part 2 description: | Learn how to turn in some direction and pass parameters to commands. diff --git a/data/scenarios/Tutorials/type-errors.yaml b/data/scenarios/Tutorials/type-errors.yaml index bcacbc72..5ae863f1 100644 --- a/data/scenarios/Tutorials/type-errors.yaml +++ b/data/scenarios/Tutorials/type-errors.yaml @@ -1,3 +1,4 @@ +version: 1 name: Type errors description: | Learn how to discover type errors. diff --git a/data/scenarios/Tutorials/types.yaml b/data/scenarios/Tutorials/types.yaml index 7207c621..152e2855 100644 --- a/data/scenarios/Tutorials/types.yaml +++ b/data/scenarios/Tutorials/types.yaml @@ -1,3 +1,4 @@ +version: 1 name: Types description: | Learn about the Swarm type system. diff --git a/data/scenarios/Tutorials/world101.yaml b/data/scenarios/Tutorials/world101.yaml index 51720804..a5f7555d 100644 --- a/data/scenarios/Tutorials/world101.yaml +++ b/data/scenarios/Tutorials/world101.yaml @@ -1,3 +1,4 @@ +version: 1 name: First steps description: | Learn some of the first steps you might take on the new planet. diff --git a/data/scenarios/classic.yaml b/data/scenarios/classic.yaml index a1207b57..0f5c4168 100644 --- a/data/scenarios/classic.yaml +++ b/data/scenarios/classic.yaml @@ -1,3 +1,4 @@ +version: 1 name: Classic game description: The classic open-world, resource-gathering version of the game. You start with a few basic supplies and have to program robots to explore and collect resources. robots: diff --git a/data/scenarios/creative.yaml b/data/scenarios/creative.yaml index 80a9549f..30b48fad 100644 --- a/data/scenarios/creative.yaml +++ b/data/scenarios/creative.yaml @@ -1,3 +1,4 @@ +version: 1 name: Creative game description: No constraints! Do whatever you want, create any items you want out of thin air, build robots to your heart's content. @@ -12,4 +13,4 @@ robots: attr: robot world: seed: null - offset: true \ No newline at end of file + offset: true diff --git a/data/schema/scenario.json b/data/schema/scenario.json index 148f87d0..96e51ba7 100644 --- a/data/schema/scenario.json +++ b/data/schema/scenario.json @@ -5,6 +5,10 @@ "description": "Scenario for the swarm game", "type": "object", "properties": { + "version": { + "description": "The version number of the scenario schema. Currently, this should always be 1.", + "type": "number" + }, "name": { "description": "The name of the scenario. For official scenarios, this is what shows up in the new game menu.", "type": "string" @@ -13,6 +17,10 @@ "description": "A short description of the scenario. This shows up next to the new game menu when the scenario is selected.", "type": "string" }, + "author": { + "description": "The author of the scenario (optional). Typically this is a person's name, but it can be any string. It is displayed under the scenario description in the new game menu.", + "type": "string" + }, "creative": { "description": "Whether the scenario should start out in creative mode.", "default": false, @@ -90,8 +98,9 @@ } }, "required": [ + "version", "name", "world", "robots" ] -} \ No newline at end of file +} diff --git a/src/Swarm/Game/Scenario.hs b/src/Swarm/Game/Scenario.hs index 46a3cbc9..f465ce76 100644 --- a/src/Swarm/Game/Scenario.hs +++ b/src/Swarm/Game/Scenario.hs @@ -30,7 +30,9 @@ module Swarm.Game.Scenario ( Scenario, -- ** Fields + scenarioVersion, scenarioName, + scenarioAuthor, scenarioDescription, scenarioCreative, scenarioSeed, @@ -233,7 +235,9 @@ paintMap pal = traverse (traverse toCell . into @String) . T.lines -- | A 'Scenario' contains all the information to describe a -- scenario. data Scenario = Scenario - { _scenarioName :: Text + { _scenarioVersion :: Int + , _scenarioName :: Text + , _scenarioAuthor :: Maybe Text , _scenarioDescription :: Text , _scenarioCreative :: Bool , _scenarioSeed :: Maybe Int @@ -270,7 +274,9 @@ instance FromJSONE EntityMap Scenario where let rsMap = buildRobotMap rs Scenario - <$> liftE (v .: "name") + <$> liftE (v .: "version") + <*> liftE (v .: "name") + <*> liftE (v .:? "author") <*> liftE (v .:? "description" .!= "") <*> liftE (v .:? "creative" .!= False) <*> liftE (v .:? "seed") @@ -286,9 +292,18 @@ instance FromJSONE EntityMap Scenario where -------------------------------------------------- -- Lenses +-- | The version number of the scenario schema. Currently, this +-- should always be 1, but it is ignored. In the future, this may +-- be used to convert older formats to newer ones, or simply to +-- print a nice error message when we can't read an older format. +scenarioVersion :: Lens' Scenario Int + -- | The name of the scenario. scenarioName :: Lens' Scenario Text +-- | The author of the scenario. +scenarioAuthor :: Lens' Scenario (Maybe Text) + -- | A high-level description of the scenario, shown /e.g./ in the -- menu. scenarioDescription :: Lens' Scenario Text diff --git a/src/Swarm/TUI/Attr.hs b/src/Swarm/TUI/Attr.hs index c6fb90d8..3d84b5e0 100644 --- a/src/Swarm/TUI/Attr.hs +++ b/src/Swarm/TUI/Attr.hs @@ -39,6 +39,7 @@ module Swarm.TUI.Attr ( notifAttr, infoAttr, boldAttr, + dimAttr, cyanAttr, yellowAttr, blueAttr, @@ -74,6 +75,7 @@ swarmAttrMap = , (infoAttr, fg (V.rgbColor @Int 50 50 50)) , (buttonSelectedAttr, bg V.blue) , (notifAttr, fg V.yellow `V.withStyle` V.bold) + , (dimAttr, V.defAttr `V.withStyle` V.dim) , (boldAttr, V.defAttr `V.withStyle` V.bold) , -- Basic colors (redAttr, fg V.red) @@ -148,12 +150,14 @@ highlightAttr , notifAttr , infoAttr , boldAttr + , dimAttr , defAttr :: AttrName highlightAttr = attrName "highlight" notifAttr = attrName "notif" infoAttr = attrName "info" boldAttr = attrName "bold" +dimAttr = attrName "dim" defAttr = attrName "def" -- | Some basic colors used in TUI. diff --git a/src/Swarm/TUI/View.hs b/src/Swarm/TUI/View.hs index 212e5c35..6114251c 100644 --- a/src/Swarm/TUI/View.hs +++ b/src/Swarm/TUI/View.hs @@ -75,7 +75,7 @@ import Swarm.Game.Display import Swarm.Game.Entity as E import Swarm.Game.Recipe import Swarm.Game.Robot -import Swarm.Game.Scenario (scenarioDescription, scenarioName, scenarioObjectives) +import Swarm.Game.Scenario (scenarioAuthor, scenarioDescription, scenarioName, scenarioObjectives) import Swarm.Game.ScenarioInfo ( ScenarioItem (..), ScenarioStatus (..), @@ -219,12 +219,17 @@ drawNewGameMenuUI (l :| ls) = let lastText = let la = "last:" in padRight (Pad $ T.length bestRealTime - T.length la) (txt la) vBox . catMaybes $ [ Just $ txtWrap (nonBlank (s ^. scenarioDescription)) + , padTop (Pad 1) + . withAttr dimAttr + . (txt "Author: " <+>) + . txt + <$> (s ^. scenarioAuthor) , Just $ padTop (Pad 3) $ padRight (Pad 1) (txt bestRealTime) <+> describeStatus (si ^. scenarioBestTime) , noSame $ -- hide best game time if it is same as best real time padTop (Pad 1) $ - padRight (Pad 1) (txt "best game time:") <+> describeStatus (si ^. scenarioBestTicks) + txt "best game time: " <+> describeStatus (si ^. scenarioBestTicks) , Just $ padTop (Pad 1) $ padRight (Pad 1) lastText <+> describeStatus (si ^. scenarioStatus)