mirror of
https://github.com/swarm-game/swarm.git
synced 2024-08-16 18:10:23 +03:00
Add author
(optional) and version
(required) fields to scenarios (#719)
Closes #611 .
This commit is contained in:
parent
871e68b38f
commit
faad903863
@ -1,4 +1,6 @@
|
||||
version: 1
|
||||
name: "2048"
|
||||
author: Brent Yorgey
|
||||
description: Make 2048!
|
||||
objectives:
|
||||
- goal:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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). |
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require device in creative mode
|
||||
description: |
|
||||
Require a device using the 'require' command in creative mode.
|
||||
|
@ -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.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require device
|
||||
description: |
|
||||
Require a device using the 'require' command.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require entities with definition
|
||||
description: |
|
||||
Require some entities using the 'require' command, and a definition.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require entities
|
||||
description: |
|
||||
Require some entities using the 'require' command.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Install devices while reprogramming
|
||||
description: |
|
||||
While executing 'reprogram', we should install any required devices which
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Install devices + entities while reprogramming
|
||||
description: |
|
||||
While executing 'reprogram', we should install any required devices and
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Drill test
|
||||
description: A developer playground for drilling.
|
||||
objectives:
|
||||
|
@ -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│
|
||||
└────────┘
|
||||
└────────┘
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Test build with drill
|
||||
description: |
|
||||
Inner build does not correctly require Drill.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Drowning results in destruction
|
||||
description: |
|
||||
Destroying robots doesn't work.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Test harvest command
|
||||
description: |
|
||||
Test the difference between the grab and harvest commands,
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Teleport self in win condition check
|
||||
description: |
|
||||
`teleport self` did not work in the win condition check.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Install one device
|
||||
description: |
|
||||
Install least amount of devices that provide needed capabilities
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Teleport updates robotsByLocation
|
||||
description: |
|
||||
Teleporting another robot should correctly update the robotsByLocation map.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Test lodestone
|
||||
description: Pick or drill lodestone and use it to flip bits.
|
||||
goal:
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Swap in one tick
|
||||
description: |
|
||||
Swapping an entity should be done in one tick.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Move to blocked
|
||||
description: |
|
||||
Robot moving to blocked location results in its destruction.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Move to liquid
|
||||
description: |
|
||||
Robot moving to water location results in its drowning.
|
||||
|
@ -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.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Multiple robots in palette
|
||||
description: |
|
||||
Using multiple robots in palette to open new rooms.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Backstory
|
||||
description: |
|
||||
Introduction to the backstory of Swarm.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Bind notation
|
||||
description: |
|
||||
Learn about command return types and how to bind the results.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Build
|
||||
description: |
|
||||
Learn how to build robots to carry out simple tasks.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Conditionals
|
||||
description: |
|
||||
Learn how to write conditional expressions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Crafting
|
||||
description: |
|
||||
Learn how to make new things using recipes.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Debug
|
||||
description: |
|
||||
Learn how to view built robots and debug them.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Define
|
||||
description: |
|
||||
Learn how to define new commands.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Farming
|
||||
description: |
|
||||
Learn how to build a farm to grow and harvest items.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Grab
|
||||
description: |
|
||||
Learn how to interact with the world by grabbing entities.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Install
|
||||
description: |
|
||||
Learn how to install devices and gain new capabilities.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Lambda
|
||||
description: |
|
||||
Learn how to define functions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Moving, part 1
|
||||
description: |
|
||||
Learn how to move and chain commands.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Place
|
||||
description: |
|
||||
Learn how to interact with the world by harvesting entities and placing them.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require devices
|
||||
description: |
|
||||
Learn how to require additional devices that would otherwise not be installed.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Require inventory
|
||||
description: |
|
||||
Learn how to require inventory when building robots.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Scan
|
||||
description: |
|
||||
Learn how to send robots to safely scan your surroundings.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Moving, part 2
|
||||
description: |
|
||||
Learn how to turn in some direction and pass parameters to commands.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Type errors
|
||||
description: |
|
||||
Learn how to discover type errors.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: Types
|
||||
description: |
|
||||
Learn about the Swarm type system.
|
||||
|
@ -1,3 +1,4 @@
|
||||
version: 1
|
||||
name: First steps
|
||||
description: |
|
||||
Learn some of the first steps you might take on the new planet.
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
offset: true
|
||||
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user