Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
5b8ed8ad
Unverified
Commit
5b8ed8ad
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
lint map things that aren't custom properties
parent
968038c4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/CheckMap.hs
+5
-8
5 additions, 8 deletions
lib/CheckMap.hs
lib/Properties.hs
+31
-4
31 additions, 4 deletions
lib/Properties.hs
with
36 additions
and
12 deletions
lib/CheckMap.hs
+
5
−
8
View file @
5b8ed8ad
...
...
@@ -17,12 +17,10 @@ import qualified Data.Vector as V
import
GHC.Generics
(
Generic
)
import
LintWriter
(
LintResult
(
..
),
LintWriter
,
lintsToDeps
,
resultToLints
,
runLintWriter
)
import
Properties
(
checkLayerProperty
,
checkMapProperty
)
lintsToDeps
,
runLintWriter
)
import
Properties
(
checkLayerProperty
,
checkMap
)
import
Tiled2
(
Layer
(
layerName
,
layerProperties
),
Tiledmap
(
tiledmapLayers
,
tiledmapProperties
),
Tiledmap
(
tiledmapLayers
),
loadTiledmap
)
import
Types
(
Dep
,
Level
(
..
),
Lint
(
..
),
hint
,
lintLevel
)
...
...
@@ -57,7 +55,7 @@ loadAndLintMap path = loadTiledmap path >>= pure . \case
runLinter
::
Tiledmap
->
MapResult
()
runLinter
tiledmap
=
MapResult
{
mapresultLayer
=
Just
layerMap
,
mapresultGeneral
=
property
Lints
-- no general lints for now
,
mapresultGeneral
=
general
Lints
-- no general lints for now
,
mapresultDepends
=
concatMap
(
lintsToDeps
.
snd
)
layer
}
where
...
...
@@ -67,8 +65,7 @@ runLinter tiledmap = MapResult
where
runCheck
l
=
(
layerName
l
,
LintResult
$
runWriterT
(
checkLayer
l
))
-- lints collected from properties
propertyLints
=
runLintWriter
$
mapM_
(
checkMapProperty
tiledmap
)
(
tiledmapProperties
tiledmap
)
generalLints
=
runLintWriter
(
checkMap
tiledmap
)
-- | collect lints on a single map layer
...
...
This diff is collapsed.
Click to expand it.
lib/Properties.hs
+
31
−
4
View file @
5b8ed8ad
...
...
@@ -3,13 +3,13 @@
{-# LANGUAGE OverloadedStrings #-}
-- | Contains checks for custom properties of the map json
module
Properties
(
checkLayerProperty
,
checkMap
Property
)
where
module
Properties
(
checkLayerProperty
,
checkMap
)
where
import
Control.Monad
(
unless
,
when
)
import
Data.Text
(
Text
,
isPrefixOf
)
import
Tiled2
(
Layer
(
layer
Propert
ies
),
Property
(
..
),
PropertyValue
(
..
),
Tiledmap
)
import
Tiled2
(
Layer
(
..
),
Propert
y
(
..
),
Property
Value
(
..
),
Tiledmap
(
..
)
)
import
Util
(
layerIsEmpty
,
prettyprint
)
import
LintWriter
(
LintWriter
,
complain
,
dependsOn
,
forbid
,
info
,
...
...
@@ -122,7 +122,34 @@ checkMapProperty map (Property name value) = case name of
-- | this property is forbidden and should not be used
isForbidden
=
forbid
$
"property "
<>
prettyprint
name
<>
" should not be used"
-- | Checks an entire map for "general" lints.
--
-- Note that it does /not/ call checkMapProperty; this is handled
-- seperately in CheckMap.hs, since these lints go into a different
-- field of the resulting json.
checkMap
::
Tiledmap
->
LintWriter
()
checkMap
tiledmap
=
do
-- check properties
mapM_
(
checkMapProperty
tiledmap
)
(
tiledmapProperties
tiledmap
)
-- some layers should exist
hasLayerNamed
"start"
(
const
True
)
"The map must have one layer named
\"
start
\"
"
hasLayerNamed
"floorLayer"
((
==
)
"objectgroup"
.
layerType
)
"The map must have one layer named
\"
floorLayer
\"
of type
\"
objectgroup
\"
"
hasLayer
(
flip
containsProperty
"exitUrl"
.
layerProperties
)
"The map must contain at least one layer with the property
\"
exitUrl
\"
set"
-- reject maps not suitable for workadventure
unless
(
tiledmapOrientation
tiledmap
==
"orthogonal"
)
$
complain
"The map's orientation must be set to
\"
orthogonal
\"
"
unless
(
tiledmapTileheight
tiledmap
==
32
&&
tiledmapTilewidth
tiledmap
==
32
)
$
complain
"The map's tile size must be 32 by 32 pixels"
where
layers
=
tiledmapLayers
tiledmap
hasLayerNamed
name
pred
=
hasLayer
(
\
l
->
layerName
l
==
name
&&
pred
l
)
hasLayer
pred
err
=
unless
(
any
pred
layers
)
$
complain
err
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment