module Players where import Types import Util isInHand :: CardSym -> PlayerId -> BoardState -> Bool isInHand c p bs = c `elem` (psHand player) where playerLib = (bsPlayerLib bs) player = snd $ getFirstMatchNS playerLib (matchSnd p) findPlayer :: PlayerId -> BoardState -> PlayerState findPlayer p bs = snd $ getFirstMatchNS pl (matchSnd p) where pl = (bsPlayerLib bs) getHand :: PlayerId -> BoardState -> Hand getHand p bs = psHand (findPlayer p bs) getDiscard :: PlayerId -> BoardState -> Discard getDiscard p bs = psDiscard (findPlayer p bs) playerName :: PlayerId -> BoardState -> String playerName p bs = psPlayerName (findPlayer p bs) 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 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)