diff --git a/Groups.hs b/Groups.hs index 6a37778..ce04abc 100644 --- a/Groups.hs +++ b/Groups.hs @@ -2,6 +2,8 @@ module Groups where type Group = [MainCharacter] type NeoTokyo = [Group] +type Downed = [MainCharacter] +type BoardState = (NeoTokyo, Downed) data MainCharacter = Asuka | Shinji | Rei | Misato | Ritsuko | Gendo deriving (Show, Eq) @@ -44,11 +46,17 @@ getAdj :: MainCharacter -> NeoTokyo -> [MainCharacter] getAdj x nt = curFrens x nt ++ (foldr (++) [] (adjGroups x nt)) -- Hurt character x -hurt :: MainCharacter -> NeoTokyo -> NeoTokyo -hurt x nt - | curFrens x nt == [] = nt - | otherwise = [x] : (filter (/= x) $ charsGroup x nt) : (otherGroups x nt) +hurt :: MainCharacter -> BoardState -> BoardState +hurt x (nt,d) + | x `elem` d = if (curFrens x nt == []) + then (nt, d) + else ([x] : (groupMinusChar x) : (otherGroups x nt), d) + | otherwise = (nt, x:d) + where + groupMinusChar x = (filter (/= x) $ charsGroup x nt) -- Attract X and Y -attract :: MainCharacter -> MainCharacter -> NeoTokyo -> NeoTokyo -attract x y nt = (uniq (charsGroup x nt ++ charsGroup y nt)) : (otherGroups y (otherGroups x nt)) +attract :: MainCharacter -> MainCharacter -> BoardState -> BoardState +attract x y (nt,d) + | x `elem` d = (nt, (filter (/= x) d)) + | otherwise = ((uniq (charsGroup x nt ++ charsGroup y nt)) : (otherGroups y (otherGroups x nt)), d)