-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1641 The `data/terrain.yaml` file is now the authoritative source of terrains, though `BlankT` is still a hard-coded special case. I have not changed the underlying integer representation of terrain in the world function, which means that the `terrainIndexByName` Map in the `TerrainMap` record is needed for translating between `Int` and `TerrainType`. # Demo scripts/play.sh -i data/scenarios/Testing/1775-custom-terrain.yaml ![Screenshot from 2024-02-22 16-51-53](https://github.com/swarm-game/swarm/assets/261693/1d263c8b-4e9c-40bf-bdc8-bf5ba8e33c4d) # Changes * There used to be a function called `integrateScenarioEntities` that combined the `EntityMap` stored in the `Scenario` record with the global entity map. However, the global entity map is accessible at parse time of the `Scenario`, so we do the combining there and only ever store the combined map in the `Scenario` record. * JSON Schema for terrain * Removed the distinction between "World" attributes and "Terrain" attributes * Unit tests for scenario-defined terrain and related validations * Validate existence of referenced terrain at scenario parse time * Validate attributes referenced by terrains at parse time
- Loading branch information
Showing
58 changed files
with
732 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
version: 1 | ||
name: Demo custom terrain | ||
description: | | ||
Colorful new terrain | ||
creative: false | ||
attrs: | ||
- name: beachsand | ||
bg: "#c2b280" | ||
- name: lava | ||
bg: "#dd7733" | ||
- name: lilac | ||
bg: "#a4a4bb" | ||
terrains: | ||
- name: beach | ||
attr: beachsand | ||
description: | | ||
Shoreline covering, laborious to cross | ||
- name: lava | ||
attr: lava | ||
description: | | ||
Scorching, liquid rock | ||
- name: heather | ||
attr: lilac | ||
description: | | ||
Flowery ground cover | ||
objectives: | ||
- goal: | ||
- | | ||
No entities should be here | ||
condition: | | ||
as base { | ||
isEmpty | ||
} | ||
solution: | | ||
noop | ||
robots: | ||
- name: base | ||
dir: east | ||
known: [] | ||
world: | ||
dsl: | | ||
{grass} | ||
palette: | ||
'B': [heather, null, base] | ||
'.': [heather] | ||
'i': [ice] | ||
'b': [beach] | ||
'v': [lava] | ||
upperleft: [0, 0] | ||
map: | | ||
vvvvvvvv | ||
vvvvvvvv | ||
B....... | ||
........ | ||
iiiiiiii | ||
iiiiiiii | ||
bbbbbbbb | ||
bbbbbbbb |
27 changes: 27 additions & 0 deletions
27
data/scenarios/Testing/_Validation/1775-invalid-terrain-attr.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 1 | ||
name: Custom terrain - invalid attribute | ||
description: | | ||
Colorful new terrain | ||
creative: false | ||
attrs: | ||
- name: lava | ||
bg: "#dd7733" | ||
terrains: | ||
- name: lava | ||
attr: baklava | ||
description: | | ||
Scorching, liquid rock | ||
robots: | ||
- name: base | ||
dir: east | ||
known: [] | ||
world: | ||
dsl: | | ||
{grass} | ||
palette: | ||
'B': [grass, null, base] | ||
'.': [lava] | ||
upperleft: [0, 0] | ||
map: | | ||
B. | ||
.. |
27 changes: 27 additions & 0 deletions
27
data/scenarios/Testing/_Validation/1775-invalid-terrain-reference.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 1 | ||
name: Custom terrain - invalid terrain reference | ||
description: | | ||
Colorful new terrain | ||
creative: false | ||
attrs: | ||
- name: lava | ||
bg: "#dd7733" | ||
terrains: | ||
- name: lava | ||
attr: lava | ||
description: | | ||
Scorching, liquid rock | ||
robots: | ||
- name: base | ||
dir: east | ||
known: [] | ||
world: | ||
dsl: | | ||
{grass} | ||
palette: | ||
'B': [grass, null, base] | ||
'.': [liver] | ||
upperleft: [0, 0] | ||
map: | | ||
B. | ||
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/terrain.json", | ||
"title": "Terrain", | ||
"description": "Description of a terrain in the Swarm game", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "The name of the terrain." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "A description of the terrain." | ||
}, | ||
"attr": { | ||
"type": "string", | ||
"examples": [ | ||
"red", | ||
"ice", | ||
"dirt" | ||
], | ||
"description": "The name of the attribute that should be used to style the robot or entity. A list of currently valid attributes can be found [here](https://github.com/swarm-game/swarm/blob/main/src/Swarm/TUI/View/Attribute/Attr.hs)." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/terrains.json", | ||
"title": "Terrains", | ||
"description": "Description of terrains in the Swarm game", | ||
"type": "array", | ||
"items": { | ||
"$ref": "terrain.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- name: stone | ||
attr: stone | ||
description: | | ||
Solid, impenetrable material | ||
- name: dirt | ||
attr: dirt | ||
description: | | ||
Soil amenable to plant growth | ||
- name: grass | ||
attr: grass | ||
description: | | ||
Soft, verdant ground | ||
- name: ice | ||
attr: ice | ||
description: | | ||
Cold, solid, and slippery. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.