diff --git a/Main.hs b/Main.hs index 5d01817..b55d058 100644 --- a/Main.hs +++ b/Main.hs @@ -1,5 +1,3 @@ -import Data.List - type Group = [MainCharacter] type NeoTokyo = [Group] @@ -29,7 +27,7 @@ uniq x = go x [] adjGroups :: MainCharacter -> NeoTokyo -> [Group] adjGroups x nt = filter (\g -> any (\x -> x `elem` adjFrens) g) (otherGroups x nt) where - adjFrens = uniq $ foldr (++) [] (map defFrens $ curFrens x nt) + adjFrens = uniq $ foldr (++) [] (map defFrens $ charsGroup x nt) otherGroups :: MainCharacter -> NeoTokyo -> [Group] otherGroups x nt = filter (\g -> not $ x `elem` g) nt @@ -38,7 +36,9 @@ getAdj :: MainCharacter -> NeoTokyo -> [MainCharacter] getAdj x nt = curFrens x nt ++ (foldr (++) [] (adjGroups x nt)) hurt :: MainCharacter -> NeoTokyo -> NeoTokyo -hurt x nt = [x] : (filter (/= x) $ charsGroup x nt) : (otherGroups x nt) +hurt x nt + | curFrens x nt == [] = nt + | otherwise = [x] : (filter (/= x) $ charsGroup x nt) : (otherGroups x nt) attract :: MainCharacter -> MainCharacter -> NeoTokyo -> NeoTokyo attract x y nt = (uniq (charsGroup x nt ++ charsGroup y nt)) : (otherGroups y (otherGroups x nt))