fixed hurt on ungrouped character
This commit is contained in:
parent
9f4d8b4343
commit
f226c85a62
8
Main.hs
8
Main.hs
@ -1,5 +1,3 @@
|
|||||||
import Data.List
|
|
||||||
|
|
||||||
type Group = [MainCharacter]
|
type Group = [MainCharacter]
|
||||||
type NeoTokyo = [Group]
|
type NeoTokyo = [Group]
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ uniq x = go x []
|
|||||||
adjGroups :: MainCharacter -> NeoTokyo -> [Group]
|
adjGroups :: MainCharacter -> NeoTokyo -> [Group]
|
||||||
adjGroups x nt = filter (\g -> any (\x -> x `elem` adjFrens) g) (otherGroups x nt)
|
adjGroups x nt = filter (\g -> any (\x -> x `elem` adjFrens) g) (otherGroups x nt)
|
||||||
where
|
where
|
||||||
adjFrens = uniq $ foldr (++) [] (map defFrens $ curFrens x nt)
|
adjFrens = uniq $ foldr (++) [] (map defFrens $ charsGroup x nt)
|
||||||
|
|
||||||
otherGroups :: MainCharacter -> NeoTokyo -> [Group]
|
otherGroups :: MainCharacter -> NeoTokyo -> [Group]
|
||||||
otherGroups x nt = filter (\g -> not $ x `elem` g) nt
|
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))
|
getAdj x nt = curFrens x nt ++ (foldr (++) [] (adjGroups x nt))
|
||||||
|
|
||||||
hurt :: MainCharacter -> NeoTokyo -> NeoTokyo
|
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 :: MainCharacter -> MainCharacter -> NeoTokyo -> NeoTokyo
|
||||||
attract x y nt = (uniq (charsGroup x nt ++ charsGroup y nt)) : (otherGroups y (otherGroups x nt))
|
attract x y nt = (uniq (charsGroup x nt ++ charsGroup y nt)) : (otherGroups y (otherGroups x nt))
|
||||||
|
Loading…
Reference in New Issue
Block a user