43 lines
982 B
Haskell
43 lines
982 B
Haskell
|
{-# LANGUAGE DeriveGeneric #-}
|
||
|
{-# LANGUAGE OverloadedLists #-}
|
||
|
module Character (
|
||
|
Character(..)
|
||
|
, Key
|
||
|
, dex
|
||
|
, stub
|
||
|
) where
|
||
|
|
||
|
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
|
||
|
import Data.Vector (Vector)
|
||
|
import GHC.Generics (Generic)
|
||
|
import qualified Pokemon (T)
|
||
|
import Tool.Array (Array, malloc)
|
||
|
|
||
|
data Character = Character {
|
||
|
name :: String
|
||
|
, skin :: FilePath
|
||
|
, pokemons :: Array Pokemon.T
|
||
|
} deriving (Generic)
|
||
|
|
||
|
instance ToJSON Character where
|
||
|
toEncoding = genericToEncoding defaultOptions
|
||
|
instance FromJSON Character where
|
||
|
parseJSON = genericParseJSON defaultOptions
|
||
|
|
||
|
newtype Key = Key Int deriving (Generic)
|
||
|
|
||
|
instance ToJSON Key where
|
||
|
toEncoding = genericToEncoding defaultOptions
|
||
|
instance FromJSON Key where
|
||
|
parseJSON = genericParseJSON defaultOptions
|
||
|
|
||
|
dex :: Vector Character
|
||
|
dex = []
|
||
|
|
||
|
stub :: Character
|
||
|
stub = Character {
|
||
|
name = ""
|
||
|
, skin = ""
|
||
|
, pokemons = malloc 6
|
||
|
}
|