From 151b75d1d232b9b9cbc2565e2f69a25554684bd5 Mon Sep 17 00:00:00 2001 From: techieAgnostic Date: Wed, 15 May 2019 18:46:48 +1200 Subject: [PATCH] added downed suppert --- Groups.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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)