From f226c85a62a89b36a637141ff5dc880958b88966 Mon Sep 17 00:00:00 2001 From: techieAgnostic Date: Wed, 15 May 2019 18:07:34 +1200 Subject: [PATCH] fixed hurt on ungrouped character --- Main.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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))