module Players where import Types isInHand :: CardSym -> PlayerId -> BoardState -> Bool isInHand c p bs = c `elem` hand where playerLib = (bsPlayerLib bs) hand = snd $ getFirstMatchNS playerLib (matchSnd p) playerName :: PlayerId -> BoardState -> BoardState playerName p bs = getFirstMatchNS (bsPlayerLib bs) (matchSnd p) findPlayer :: PlayerId -> BoardState -> PlayerState findPlayer p bs | elemSnd p pl = getFirstMatchNS pl (matchSnd p) where pl = (bsPlayerLib bs) getHand :: PlayerId -> BoardState -> Hand getHand p bs = (\(_,h,_,_) -> h) (snd $ findPlayer p bs) getDiscard :: PlayerId -> BoardState -> Discard getDiscard p bs = (\(_,_,_,d) -> d) (snd $ findPlayer p bs) playerName :: PlayerId -> BoardState -> String playerName p bs = (\(n,_,_,_) -> n) (snd $ 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 = (\(n,h,d,dis) -> (n,(addToHand c),d,(addToDiscard d))) (findPlayer p bs)