2019-05-20 06:51:06 -04:00
|
|
|
module Players where
|
|
|
|
|
|
|
|
import Types
|
2019-05-20 19:37:03 -04:00
|
|
|
import Util
|
2019-05-20 06:51:06 -04:00
|
|
|
|
|
|
|
isInHand :: CardSym -> PlayerId -> BoardState -> Bool
|
2019-05-20 19:37:03 -04:00
|
|
|
isInHand c p bs = c `elem` (psHand player)
|
2019-05-20 06:51:06 -04:00
|
|
|
where
|
|
|
|
playerLib = (bsPlayerLib bs)
|
2019-05-20 19:37:03 -04:00
|
|
|
player = snd $ getFirstMatchNS playerLib (matchSnd p)
|
2019-05-20 06:51:06 -04:00
|
|
|
|
|
|
|
findPlayer :: PlayerId -> BoardState -> PlayerState
|
2019-05-20 19:37:03 -04:00
|
|
|
findPlayer p bs = snd $ getFirstMatchNS pl (matchSnd p)
|
2019-05-20 06:51:06 -04:00
|
|
|
where
|
|
|
|
pl = (bsPlayerLib bs)
|
|
|
|
|
|
|
|
getHand :: PlayerId -> BoardState -> Hand
|
2019-05-20 19:37:03 -04:00
|
|
|
getHand p bs = psHand (findPlayer p bs)
|
2019-05-20 06:51:06 -04:00
|
|
|
|
|
|
|
getDiscard :: PlayerId -> BoardState -> Discard
|
2019-05-20 19:37:03 -04:00
|
|
|
getDiscard p bs = psDiscard (findPlayer p bs)
|
2019-05-20 06:51:06 -04:00
|
|
|
|
|
|
|
playerName :: PlayerId -> BoardState -> String
|
2019-05-20 19:37:03 -04:00
|
|
|
playerName p bs = psPlayerName (findPlayer p bs)
|
2019-05-20 06:51:06 -04:00
|
|
|
|
|
|
|
removeFromHand :: PlayerId -> CardSym -> BoardState -> Hand
|
|
|
|
removeFromHand p c bs = rmFirstMatch (getHand p bs) (== c)
|
|
|
|
|
|
|
|
addToDiscard :: PlayerId -> CardSym -> BoardState -> Discard
|
|
|
|
addToDiscard p c bs = c : (getDiscard p bs)
|
|
|
|
|
|
|
|
handToDiscard :: PlayerId -> CardSym -> BoardState -> PlayerState
|
2019-05-20 19:37:03 -04:00
|
|
|
handToDiscard p c bs = ps
|
|
|
|
{ psHand = removeFromHand p c bs
|
|
|
|
, psDiscard = addToDiscard p c bs
|
|
|
|
}
|
|
|
|
where
|
|
|
|
ps = (findPlayer p bs)
|
|
|
|
|
|
|
|
adjustDP :: PlayerId -> Integer -> BoardState -> PlayerState
|
|
|
|
adjustDP p i bs = ps { psDP = (psDP ps) + i }
|
|
|
|
where
|
|
|
|
ps = (findPlayer p bs)
|