fixed hurt on ungrouped character

This commit is contained in:
Thorn Avery 2019-05-15 18:07:34 +12:00
parent 9f4d8b4343
commit f226c85a62

View File

@ -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))