summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2021-12-27 18:03:27 +0100
committerstuebinm2021-12-27 18:03:27 +0100
commit8b96ea32accff561f4f2a33b604a9a2bbe0a9168 (patch)
tree0938820ddffacbcdfdd697e2134fb393b51a63e6
parent27c44dc97472d89783068b4c280b98a1b8301600 (diff)
warn if main.json does not link back to lobby
-rw-r--r--lib/CheckMap.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 8854b4c..2677a30 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -31,9 +31,10 @@ import Tiled (Layer (layerLayers, layerName),
LoadResult (..),
Tiledmap (tiledmapLayers, tiledmapTilesets),
loadTiledmap)
-import Types (Dep, Hint (Hint, hintLevel, hintMsg),
+import Types (Dep (MapLink), Hint (Hint, hintLevel, hintMsg),
Level (..), lintsToHints)
import Util (PrettyPrint (prettyprint), prettyprint)
+import System.FilePath (takeFileName)
@@ -84,16 +85,18 @@ loadAndLintMap config path depth = loadTiledmap path <&> (\case
])
IOErr _ -> Nothing
Loaded waMap ->
- Just (runLinter config waMap depth))
+ Just (runLinter (takeFileName path == "main.json") config waMap depth))
-- | lint a loaded map
-runLinter :: LintConfig' -> Tiledmap -> Int -> MapResult
-runLinter config tiledmap depth = MapResult
+runLinter :: Bool -> LintConfig' -> Tiledmap -> Int -> MapResult
+runLinter isMain config tiledmap depth = MapResult
{ mapresultLayer = invertThing layer
, mapresultTileset = invertThing tileset
- , mapresultGeneral = lintsToHints $ resultToLints generalResult
+ , mapresultGeneral =
+ ([Hint Warning "main.json should link back to the lobby" | isMain && not (any linksLobby layerDeps)])
+ <> lintsToHints (resultToLints generalResult)
, mapresultDepends = resultToDeps generalResult
- <> concatMap resultToDeps layer
+ <> layerDeps
<> concatMap resultToDeps tileset
, mapresultProvides = concatMap resultToOffers layer
, mapresultAdjusted = Just adjustedMap
@@ -101,6 +104,10 @@ runLinter config tiledmap depth = MapResult
<> resultToBadges generalResult
}
where
+ linksLobby = \case
+ MapLink link -> "/@/rc3_21/lobby" `T.isPrefixOf` link
+ _ -> False
+ layerDeps = concatMap resultToDeps layer
layer = checkLayerRec config depth (V.toList $ tiledmapLayers tiledmap)
tileset = checkThing tiledmapTilesets checkTileset
generalResult = runLintWriter config tiledmap depth checkMap