evac/Connect.hs

34 lines
1.3 KiB
Haskell
Raw Normal View History

2019-05-19 00:55:53 -04:00
module Connect where
import Types
import Util
-- Passes state for X to hurt Y
conHurt :: MainCharacter -> MainCharacter -> BoardState -> BoardState
conHurt charX charY oldBS
| isDowned charX oldDowned = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ $ Right GameError (charX ++ " is downed, could not hurt " ++ charY)
}
| (isAdjacent . not) charX charY oldGroups = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ $ Right GameError (charX ++ " is not adjacent to " ++ charY ++ ", could not hurt")
}
| isAlone charX oldGroups = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ $ Left GameLine (charX ++ " hurt " ++ charY ++ ", " ++ charY ++ " is downed")
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
{ ntPutCards = filter (\x -> filter ((snd x) /= Just charX)) oldPut
, ntDowned = (charY:oldDowned)
}
|otherwise = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ $ Left GameLine (charX ++ " hurt " ++ charY ++ ", " ++ charY ++ " left their group")
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
{ ntGroups = removeFromGroup charY oldGroups }
}
where
oldDowned = (ntDowned . bsNeoTokyo) oldBS
oldGroups = (ntGroups . bsNeoTokyo) oldBS
oldPut = (ntPutCards . bsNeoTokyo) oldBS