Take Gender out into a separate module to share it with Characters

This commit is contained in:
Tissevert 2018-12-08 18:15:12 +01:00
parent fec16c651a
commit 355c7d08be
4 changed files with 17 additions and 6 deletions

View file

@ -26,6 +26,7 @@ executable pokeNeige
, Character
, Config
, Game
, Gender
, Item
, Message
, Message.Client

View file

@ -10,12 +10,14 @@ module Character (
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
import Data.Vector (Vector)
import GHC.Generics (Generic)
import Gender (Gender(..))
import qualified Pokemon (T)
import Tool.Array (Array, malloc)
data Character = Character {
name :: String
, skin :: FilePath
, gender :: Gender
, pokemons :: Array Pokemon.T
} deriving (Generic)

13
src/Gender.hs Normal file
View file

@ -0,0 +1,13 @@
{-# LANGUAGE DeriveGeneric #-}
module Gender (
Gender(..)
) where
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, defaultOptions)
import GHC.Generics (Generic)
data Gender = M | F | NB deriving (Generic)
instance ToJSON Gender where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Gender

View file

@ -6,17 +6,12 @@ module Pokemon (
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
import GHC.Generics (Generic)
import Gender (Gender)
import qualified Pokemon.Species as Species (Key)
import Pokemon.Status (Status)
import qualified Pokemon.Move as Move (Key)
import Tool.Array (Array)
data Gender = M | F | NB deriving (Generic)
instance ToJSON Gender where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Gender
data T = T {
nick :: Maybe String
, species :: Species.Key