2018-11-17 19:11:36 +01:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
module Pokemon (
|
2018-12-17 12:40:46 +01:00
|
|
|
Pokemon(..)
|
2018-11-17 19:11:36 +01:00
|
|
|
) where
|
|
|
|
|
|
|
|
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
|
|
|
|
import GHC.Generics (Generic)
|
|
|
|
|
2018-12-08 18:15:12 +01:00
|
|
|
import Gender (Gender)
|
2018-11-17 19:11:36 +01:00
|
|
|
import qualified Pokemon.Species as Species (Key)
|
|
|
|
import Pokemon.Status (Status)
|
|
|
|
import qualified Pokemon.Move as Move (Key)
|
|
|
|
import Tool.Array (Array)
|
|
|
|
|
2018-12-17 12:40:46 +01:00
|
|
|
data Pokemon = Pokemon {
|
2018-11-17 19:11:36 +01:00
|
|
|
nick :: Maybe String
|
|
|
|
, species :: Species.Key
|
|
|
|
, gender :: Gender
|
|
|
|
, level :: Int
|
|
|
|
, status :: Status
|
|
|
|
, moves :: Array Move.Key
|
|
|
|
} deriving (Generic)
|
|
|
|
|
2018-12-17 12:40:46 +01:00
|
|
|
instance ToJSON Pokemon where
|
2018-11-17 19:11:36 +01:00
|
|
|
toEncoding = genericToEncoding defaultOptions
|
2018-12-17 12:40:46 +01:00
|
|
|
instance FromJSON Pokemon where
|
2018-11-17 19:11:36 +01:00
|
|
|
parseJSON = genericParseJSON defaultOptions
|