Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensible terrain #1775

Merged
merged 4 commits into from
Feb 29, 2024
Merged

extensible terrain #1775

merged 4 commits into from
Feb 29, 2024

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Feb 20, 2024

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

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

@kostmo kostmo force-pushed the feature/extensible-terrain branch 4 times, most recently from 438c399 to 644ea72 Compare February 22, 2024 03:05
@kostmo kostmo force-pushed the feature/extensible-terrain branch 3 times, most recently from 505d6c1 to 5c3dc2d Compare February 23, 2024 01:04
@kostmo kostmo changed the title [WIP] extensible terrain extensible terrain Feb 23, 2024
@kostmo kostmo marked this pull request as ready for review February 23, 2024 02:17
@kostmo kostmo requested a review from byorgey February 23, 2024 02:17
@byorgey
Copy link
Member

byorgey commented Feb 26, 2024

Cool! Working through reviewing this slowly but surely.

Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Many nice code improvements, and I like the added flexibility of custom terrain. It seems like this is also a good first step towards things like #742 and #205 .

data/schema/scenario.json Show resolved Hide resolved
data/schema/terrains.json Outdated Show resolved Hide resolved
src/Swarm/TUI/Editor/Controller.hs Outdated Show resolved Hide resolved
data/terrains.yaml Show resolved Hide resolved
src/swarm-scenario/Swarm/Game/Terrain.hs Outdated Show resolved Hide resolved
src/Swarm/TUI/Editor/View.hs Outdated Show resolved Hide resolved
@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Feb 29, 2024
@mergify mergify bot merged commit 936b30d into main Feb 29, 2024
11 checks passed
@mergify mergify bot deleted the feature/extensible-terrain branch February 29, 2024 06:22
@byorgey byorgey mentioned this pull request Mar 15, 2024
@byorgey byorgey added the CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom scenario-defined terrain types
2 participants