diff options
author | stuebinm | 2021-12-27 18:03:27 +0100 |
---|---|---|
committer | stuebinm | 2022-01-02 01:55:49 +0100 |
commit | 1630bd4b7daf7d842575781d4aa146dd812c877b (patch) | |
tree | 0938820ddffacbcdfdd697e2134fb393b51a63e6 | |
parent | d0f22e513650b73e1335f471a6bc60eb2b2d27a9 (diff) |
warn if main.json does not link back to lobby
-rw-r--r-- | lib/CheckMap.hs | 19 |
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 |