summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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