implemented CreatePlayerState

This commit is contained in:
Jonathan Lamothe 2019-09-08 12:06:38 -04:00
parent be5d10b6fd
commit 6b73e367e4

View File

@ -29,6 +29,7 @@ module Mtlstats.Types (
ProgMode (..), ProgMode (..),
GameState (..), GameState (..),
GameType (..), GameType (..),
CreatePlayerState (..),
Database (..), Database (..),
Player (..), Player (..),
PlayerStats (..), PlayerStats (..),
@ -53,6 +54,11 @@ module Mtlstats.Types (
awayScore, awayScore,
overtimeFlag, overtimeFlag,
dataVerified, dataVerified,
-- ** CreatePlayerState Lenses
cpsNumber,
cpsName,
cpsPosition,
cpsConfirmed,
-- ** Database Lenses -- ** Database Lenses
dbPlayers, dbPlayers,
dbGoalies, dbGoalies,
@ -89,6 +95,7 @@ module Mtlstats.Types (
-- * Constructors -- * Constructors
newProgState, newProgState,
newGameState, newGameState,
newCreatePlayerState,
newDatabase, newDatabase,
newPlayer, newPlayer,
newPlayerStats, newPlayerStats,
@ -187,6 +194,18 @@ data GameType
| AwayGame | AwayGame
deriving (Eq, Show) deriving (Eq, Show)
-- | Player creation status
data CreatePlayerState = CreatePlayerState
{ _cpsNumber :: Maybe Int
-- ^ The player's number
, _cpsName :: String
-- ^ The player's name
, _cpsPosition :: String
-- ^ The player's position
, _cpsConfirmed :: Bool
-- ^ Set when the user confirms the input
} deriving (Eq, Show)
-- | Represents the database -- | Represents the database
data Database = Database data Database = Database
{ _dbPlayers :: [Player] { _dbPlayers :: [Player]
@ -408,6 +427,7 @@ data Prompt = Prompt
makeLenses ''ProgState makeLenses ''ProgState
makeLenses ''GameState makeLenses ''GameState
makeLenses ''CreatePlayerState
makeLenses ''Database makeLenses ''Database
makeLenses ''Player makeLenses ''Player
makeLenses ''PlayerStats makeLenses ''PlayerStats
@ -444,6 +464,15 @@ newGameState = GameState
, _dataVerified = False , _dataVerified = False
} }
-- | Constructor for a 'CreatePlayerState'
newCreatePlayerState :: CreatePlayerState
newCreatePlayerState = CreatePlayerState
{ _cpsNumber = Nothing
, _cpsName = ""
, _cpsPosition = ""
, _cpsConfirmed = False
}
-- | Constructor for a 'Database' -- | Constructor for a 'Database'
newDatabase :: Database newDatabase :: Database
newDatabase = Database newDatabase = Database