55 lines
1.6 KiB
Haskell
55 lines
1.6 KiB
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
--{-# LANGUAGE DeriveAnyClass #-}
|
|
{-# LANGUAGE StrictData #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE EmptyDataDeriving #-}
|
|
module Dodge.Data.Item.Location where
|
|
|
|
import NewInt
|
|
import ShortShow
|
|
import Dodge.Data.Equipment.Misc
|
|
import Control.Lens
|
|
import Data.Aeson
|
|
import Data.Aeson.TH
|
|
|
|
-- it would be nice to have these as empty types, but I'm not sure how to get
|
|
-- aeson to handle that
|
|
data InvInt = InvInt
|
|
deriving (Eq,Ord,Show,Read)
|
|
data TurretInt
|
|
deriving (Eq,Ord,Show,Read)
|
|
data CrInt = CrInt
|
|
deriving (Eq,Ord,Show,Read)
|
|
data ItmInt = ItmInt
|
|
deriving (Eq,Ord,Show,Read)
|
|
|
|
data ItemLocation
|
|
= InInv
|
|
{ _ilCrID :: Int
|
|
, _ilInvID :: NewInt InvInt
|
|
, _ilIsRoot :: Bool -- of any item
|
|
, _ilIsSelected :: Bool
|
|
, _ilIsAttached :: Bool -- to selected item
|
|
, _ilEquipSite :: Maybe EquipSite
|
|
}
|
|
| OnTurret {_ilTuID :: Int}
|
|
| OnFloor-- {_ilFlID :: NewInt FloorInt}
|
|
| InVoid
|
|
deriving (Eq, Show, Ord, Read) --Generic, Flat)
|
|
|
|
instance ShortShow ItemLocation where
|
|
shortShow (InInv cid invid rootb selb attb esite)
|
|
= "InInv:cid" <> shortShow cid <> "invid"<> shortShow (_unNInt invid)
|
|
<>"root"<>shortShow rootb<>"sel"<>shortShow selb<>"att"<>shortShow attb<>
|
|
shortShow (fmap (SString . show) esite)
|
|
shortShow x = show x
|
|
-- | OnTurret {_ilTuID :: Int}
|
|
-- | OnFloor-- {_ilFlID :: NewInt FloorInt}
|
|
-- | InVoid
|
|
|
|
makeLenses ''ItemLocation
|
|
deriveJSON defaultOptions ''InvInt
|
|
deriveJSON defaultOptions ''ItemLocation
|
|
deriveJSON defaultOptions ''ItmInt
|
|
deriveJSON defaultOptions ''CrInt
|