evac/Connect.hs

80 lines
3.4 KiB
Haskell
Raw Normal View History

2019-05-19 00:55:53 -04:00
module Connect where
import Types
2019-05-19 02:11:40 -04:00
import Groups
import Players
-- IDEAS
-- * Bank of bool function, boardstate affection pairs
-- One global, one per player
-- used as a list of restrictions for whether you can play a card.
-- * Further, make it a list of restrictions, for going in timing order.
-- makes for better log messages.
--conAnnounceLine :: PlayerId -> CardSym -> MainCharacter -> BoardState -> BoardState
--conAnnounceLine p l t oldBoardState
-- | not $ PlayerId `elem` (bsPlayerLib oldBoardState) = oldBoardState
-- { bsGameLog = (bsGameLog oldBoardState)
-- ++ [ Right ("Player " ++ show PlayerId ++ " is not in the game") ]
-- }
-- | not $ isInHand l p oldBoardState = oldBoardState
-- { bsGameLog = (bsGameLog oldBoardState)
-- ++ [ Right (show CardSym ++ " is not in " ++ (playerName p) ++ "'s hand" ]
-- }
-- | otherwise = oldBoardState
-- { bsGameLog = (bsGameLog oldBoardState)
-- ++ [ Left (playerName p oldBoardState) ++ " announced " ++ (getCardLine l) ++ ", moved to active" ]
-- ,
-- TODO
-- * manipulate the card stack after writing it
2019-05-19 00:55:53 -04:00
-- Passes state for X to hurt Y
conHurt :: MainCharacter -> MainCharacter -> BoardState -> BoardState
2019-05-19 02:11:40 -04:00
conHurt charX charY oldBoardState
| not $ isAdjacent charX charY oldGroups = oldBoardState
2019-05-19 00:55:53 -04:00
{ bsGameLog = (bsGameLog oldBoardState)
2019-05-19 02:11:40 -04:00
++ [ Right (show charX ++ " is not adjacent to " ++ show charY ++ ", could not hurt") ]
2019-05-19 00:55:53 -04:00
}
| isAlone charY oldGroups = oldBoardState
2019-05-19 00:55:53 -04:00
{ bsGameLog = (bsGameLog oldBoardState)
2019-05-19 02:11:40 -04:00
++ [ Left (show charX ++ " hurt " ++ show charY ++ ", " ++ show charY ++ " is downed") ]
2019-05-19 00:55:53 -04:00
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
2019-05-19 02:11:40 -04:00
{ ntPutCards = filter (\x -> ((fst x) /= Left charX)) oldPut
, ntDowned = downChar charY oldDowned
2019-05-19 00:55:53 -04:00
}
2019-05-19 02:11:40 -04:00
}
| otherwise = oldBoardState
2019-05-19 00:55:53 -04:00
{ bsGameLog = (bsGameLog oldBoardState)
2019-05-19 02:11:40 -04:00
++ [ Left (show charX ++ " hurt " ++ show charY ++ ", " ++ show charY ++ " left their group") ]
2019-05-19 00:55:53 -04:00
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
{ ntGroups = removeFromGroup charY oldGroups }
}
where
2019-05-19 02:11:40 -04:00
oldDowned = (ntDowned . bsNeoTokyo) oldBoardState
oldGroups = (ntGroups . bsNeoTokyo) oldBoardState
oldPut = (ntPutCards . bsNeoTokyo) oldBoardState
2019-05-20 00:43:29 -04:00
-- Passes state for X to attract Y
2019-05-19 02:11:40 -04:00
conAttract :: MainCharacter -> MainCharacter -> BoardState -> BoardState
conAttract charX charY oldBoardState
| not $ isAdjacent charX charY oldGroups = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ [ Right (show charX ++ " is not adjacent to " ++ show charY ++ ", could not attract") ]
}
| isDowned charX oldDowned = oldBoardState
2019-05-19 02:11:40 -04:00
{ bsGameLog = (bsGameLog oldBoardState)
++ [ Left (show charX ++ " attracted " ++ show charY ++ ", " ++ show charY ++ " is ready") ]
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
{ ntDowned = readyChar charY oldDowned }
}
| otherwise = oldBoardState
{ bsGameLog = (bsGameLog oldBoardState)
++ [ Left (show charX ++ " attracted " ++ show charY ++ ", " ++ show charY ++ "'s group joined " ++ show charX ++ "'s group") ]
, bsNeoTokyo = (bsNeoTokyo oldBoardState)
{ ntGroups = joinGroups charX charY oldGroups }
}
where
oldDowned = (ntDowned . bsNeoTokyo) oldBoardState
oldGroups = (ntGroups . bsNeoTokyo) oldBoardState