{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedLists #-} module Pokemon.Move ( Effect(..) , Key , Move(..) , dex ) where import Data.Aeson (ToJSON(..), FromJSON(..), genericToEncoding, genericParseJSON, defaultOptions) import Data.Vector (Vector) import GHC.Generics (Generic) import Area.Climate (Climate) import Pokemon.Status (Status) import Pokemon.Type (Type(..)) import Pokemon.Stats (Stats) import qualified Pokemon.Stats as Stats (modify, precision) data Effect = Blow { damage :: Int } | StatusChange { changeStatus :: Status -> Maybe Status } | StatsChange { changeStats :: Stats -> Maybe Stats } | Flee | Expell | Switch | Corner | Climatic Climate data Move = Move { name :: String , type_ :: Type , precision :: Int , effects :: [Effect] } newtype Key = Key Int deriving (Generic) instance ToJSON Key where toEncoding = genericToEncoding defaultOptions instance FromJSON Key where parseJSON = genericParseJSON defaultOptions dex :: Vector Move dex = [ Move { name = "charge" , type_ = Normal , precision = 100 , effects = [ Blow { damage = 30 } ] } , Move { name = "mimi-queue" , type_ = Normal , precision = 80 , effects = [ StatsChange { changeStats = Stats.modify Stats.precision (\x -> x-10) 30 } ] } ]