-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make structures parseable independently of entity definitions
- Loading branch information
Showing
25 changed files
with
350 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
structures: | ||
- name: cross | ||
structure: | ||
structures: | ||
- name: beam | ||
structure: | ||
palette: | ||
't': true | ||
'f': false | ||
map: | | ||
ttt | ||
ttt | ||
ttt | ||
ttt | ||
ttt | ||
ttt | ||
fff | ||
fff | ||
fff | ||
placements: | ||
- src: beam | ||
offset: [0, 3] | ||
truncate: false | ||
- src: beam | ||
offset: [-3, -3] | ||
truncate: false | ||
orient: | ||
up: east | ||
map: "" | ||
- name: disc | ||
structure: | ||
mask: '.' | ||
palette: | ||
't': true | ||
map: | | ||
..tttt.. | ||
.tttttt. | ||
ttt..ttt | ||
tt....tt | ||
tt....tt | ||
ttt..ttt | ||
.tttttt. | ||
..tttt.. | ||
placements: | ||
- src: cross | ||
offset: [0, -15] | ||
truncate: false | ||
- src: cross | ||
offset: [0, 0] | ||
truncate: false | ||
orient: | ||
up: east | ||
- src: cross | ||
offset: [15, 0] | ||
truncate: false | ||
orient: | ||
up: south | ||
- src: cross | ||
offset: [15, -15] | ||
truncate: false | ||
orient: | ||
up: west | ||
- src: disc | ||
offset: [8, -8] | ||
truncate: false | ||
map: "" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
#!/bin/bash -xe | ||
|
||
# Run this locally before pushing a branch to save some CI cycles | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd $SCRIPT_DIR/../.. | ||
|
||
scripts/normalize/cabal.sh | ||
scripts/normalize/code-format.sh | ||
scripts/normalize/yaml.sh | ||
hlint . |
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
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
41 changes: 41 additions & 0 deletions
41
src/swarm-topography/Swarm/Game/Scenario/Topography/ProtoCell.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,41 @@ | ||
{-# LANGUAGE DerivingVia #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
-- | | ||
-- SPDX-License-Identifier: BSD-3-Clause | ||
module Swarm.Game.Scenario.Topography.ProtoCell ( | ||
SignpostableCell (..), | ||
StructurePalette (..), | ||
) where | ||
|
||
import Control.Applicative ((<|>)) | ||
import Data.Aeson.KeyMap (KeyMap) | ||
import Data.Yaml as Y | ||
import Swarm.Game.Scenario.Topography.Navigation.Waypoint (WaypointConfig) | ||
import Swarm.Util.Yaml | ||
|
||
newtype StructurePalette e = StructurePalette | ||
{unPalette :: KeyMap (SignpostableCell e)} | ||
deriving (Eq, Show) | ||
|
||
instance (FromJSONE e a) => FromJSONE e (StructurePalette a) where | ||
parseJSONE = | ||
withObjectE "palette" $ | ||
fmap StructurePalette . mapM parseJSONE | ||
|
||
-- | Supplements a cell with waypoint information | ||
data SignpostableCell c = SignpostableCell | ||
{ waypointCfg :: Maybe WaypointConfig | ||
, standardCell :: c | ||
} | ||
deriving (Eq, Show) | ||
|
||
instance (FromJSONE e a) => FromJSONE e (SignpostableCell a) where | ||
parseJSONE x = | ||
withObjectE "SignpostableCell" objParse x | ||
<|> (SignpostableCell Nothing <$> parseJSONE x) | ||
where | ||
objParse v = | ||
SignpostableCell | ||
<$> liftE (v .:? "waypoint") | ||
<*> v ..: "cell" |
Oops, something went wrong.