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 , Character
, Config , Config
, Game , Game
, Gender
, Item , Item
, Message , Message
, Message.Client , Message.Client

View file

@ -10,12 +10,14 @@ module Character (
import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions) import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
import Data.Vector (Vector) import Data.Vector (Vector)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gender (Gender(..))
import qualified Pokemon (T) import qualified Pokemon (T)
import Tool.Array (Array, malloc) import Tool.Array (Array, malloc)
data Character = Character { data Character = Character {
name :: String name :: String
, skin :: FilePath , skin :: FilePath
, gender :: Gender
, pokemons :: Array Pokemon.T , pokemons :: Array Pokemon.T
} deriving (Generic) } 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 Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gender (Gender)
import qualified Pokemon.Species as Species (Key) import qualified Pokemon.Species as Species (Key)
import Pokemon.Status (Status) import Pokemon.Status (Status)
import qualified Pokemon.Move as Move (Key) import qualified Pokemon.Move as Move (Key)
import Tool.Array (Array) import Tool.Array (Array)
data Gender = M | F | NB deriving (Generic)
instance ToJSON Gender where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Gender
data T = T { data T = T {
nick :: Maybe String nick :: Maybe String
, species :: Species.Key , species :: Species.Key