34 lines
1.3 KiB
Haskell
34 lines
1.3 KiB
Haskell
|
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
|