Implement card capture (さくら!)

This commit is contained in:
Sasha 2018-02-03 18:25:11 +01:00
parent c95d611024
commit b03e97bb81

View file

@ -92,3 +92,9 @@ yakus = foldl (\map -> unionWith (++) map . index) empty [
, ([SakeCup, FullMoon], fixed (TsukimiZake, 5)) , ([SakeCup, FullMoon], fixed (TsukimiZake, 5))
, ([SakeCup, CampCurtain], fixed (HanamiZake, 5)) , ([SakeCup, CampCurtain], fixed (HanamiZake, 5))
] ]
capture :: State -> Card -> Pack -> (Pack, Score)
capture (State {month}) card pack =
let newPack = add pack card in
let yakuFinders = (unionWith (++) yakus . index $ tsukiFuda month) ! card in
(newPack, foldl (\score -> foldr (uncurry insert) score . ($newPack)) empty yakuFinders)