diff options
author | Griffin Smith <root@gws.fyi> | 2019-09-02T17·56-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-09-02T17·59-0400 |
commit | 4d270712aecf1b61249086718852b96968de2bd8 (patch) | |
tree | bbceb63b5b7e5ade5025472f343b1ff1b3b96c65 /src/Xanthous/Entities/Raws.hs | |
parent | 243104c410da7e2064972b98cda757558b4e3913 (diff) |
Add raws, loaded statically from a folder
Add raw types with support for both creatures and items, loaded statically from a "raws" folder just like in the Rust version.
Diffstat (limited to 'src/Xanthous/Entities/Raws.hs')
-rw-r--r-- | src/Xanthous/Entities/Raws.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Xanthous/Entities/Raws.hs b/src/Xanthous/Entities/Raws.hs new file mode 100644 index 000000000000..4a4cba8c9a19 --- /dev/null +++ b/src/Xanthous/Entities/Raws.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Xanthous.Entities.Raws + ( raws + , raw + ) where + +import Data.FileEmbed +import qualified Data.Yaml as Yaml +import Xanthous.Prelude +import System.FilePath.Posix + +import Xanthous.Entities.RawTypes + +rawRaws :: [(FilePath, ByteString)] +rawRaws = $(embedDir "src/Xanthous/Entities/Raws") + +raws :: HashMap Text EntityRaw +raws + = mapFromList + . map (bimap + (pack . takeBaseName) + (either (error . Yaml.prettyPrintParseException) id + . Yaml.decodeEither')) + $ rawRaws + +raw :: Text -> Maybe EntityRaw +raw n = raws ^. at n |