diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-06-18T16·42-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2021-06-18T17·51+0000 |
commit | fb5bec8d952b57fe4afa0d842ee606cf4e548563 (patch) | |
tree | 8bde10c0136c5913ef8f3afd2c2b3beba1571c47 /users/grfn/xanthous/src/Xanthous/Orphans.hs | |
parent | 88b0d0eecc8ea87e848f2e78ebae08f3361dbeaa (diff) |
feat(xanthous): Add configurable natural attacks r/2674
Allow configuring the natural attacks (eg, part of their body rather than an item) of a creature. Each attack has a description and a damage associated with it. Change-Id: I69698a8ac4ee2da91e4c88e419593627519522a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3220 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Orphans.hs')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Orphans.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Orphans.hs b/users/grfn/xanthous/src/Xanthous/Orphans.hs index 2a9a7a7ebc29..e6ea1310319b 100644 --- a/users/grfn/xanthous/src/Xanthous/Orphans.hs +++ b/users/grfn/xanthous/src/Xanthous/Orphans.hs @@ -300,9 +300,21 @@ deriving stock instance Ord Attr -------------------------------------------------------------------------------- +instance (SemiSequence a, Arbitrary (Element a), Arbitrary a) + => Arbitrary (NonNull a) where + arbitrary = ncons <$> arbitrary <*> arbitrary + +instance ToJSON a => ToJSON (NonNull a) where + toJSON = toJSON . toNullable + +instance (FromJSON a, MonoFoldable a) => FromJSON (NonNull a) where + parseJSON = maybe (fail "Found empty list") pure . fromNullable <=< parseJSON + instance NFData a => NFData (NonNull a) where rnf xs = xs `seq` toNullable xs `deepseq` () +-------------------------------------------------------------------------------- + instance forall t name. (NFData t, Monoid t, NFData name) => NFData (Editor t name) where rnf ed = getName @_ @name ed `deepseq` getEditContents ed `deepseq` () |