From 22bf2d1f48d6a6948a0c3c4017760e5ac637e3b6 Mon Sep 17 00:00:00 2001 From: techieAgnostic Date: Mon, 20 May 2019 07:37:05 +1200 Subject: [PATCH] cheeky non working commit to save my work --- Connect.hs | 4 ++-- Group.hs => Groups.hs | 5 +---- Init.hs | 23 +++++++++++++++++++++++ Print.hs | 31 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) rename Group.hs => Groups.hs (96%) create mode 100644 Init.hs create mode 100644 Print.hs diff --git a/Connect.hs b/Connect.hs index 06babc6..e40ab46 100644 --- a/Connect.hs +++ b/Connect.hs @@ -10,7 +10,7 @@ conHurt charX charY oldBoardState { bsGameLog = (bsGameLog oldBoardState) ++ [ Right (show charX ++ " is not adjacent to " ++ show charY ++ ", could not hurt") ] } - | isAlone charX oldGroups = oldBoardState + | isAlone charY oldGroups = oldBoardState { bsGameLog = (bsGameLog oldBoardState) ++ [ Left (show charX ++ " hurt " ++ show charY ++ ", " ++ show charY ++ " is downed") ] , bsNeoTokyo = (bsNeoTokyo oldBoardState) @@ -35,7 +35,7 @@ conAttract charX charY oldBoardState { bsGameLog = (bsGameLog oldBoardState) ++ [ Right (show charX ++ " is not adjacent to " ++ show charY ++ ", could not attract") ] } - | isAlone charX oldGroups = oldBoardState + | isDowned charX oldDowned = oldBoardState { bsGameLog = (bsGameLog oldBoardState) ++ [ Left (show charX ++ " attracted " ++ show charY ++ ", " ++ show charY ++ " is ready") ] , bsNeoTokyo = (bsNeoTokyo oldBoardState) diff --git a/Group.hs b/Groups.hs similarity index 96% rename from Group.hs rename to Groups.hs index 56efefb..e487c69 100644 --- a/Group.hs +++ b/Groups.hs @@ -1,10 +1,7 @@ module Groups where -import State import Util -import Cards import Types -import Data.Either -- Each characters default adjacents defFrens :: MainCharacter -> [MainCharacter] @@ -59,7 +56,7 @@ removeFromGroup c g = ( [c] : (groupMinusChar c) : (otherGroups c g) ) joinGroups :: MainCharacter -> MainCharacter -> Groups -> Groups joinGroups x y g | x `elem` curFrens y g = g - | otherwise = (groupX ++ groupY) : (otherGroups x g) + | otherwise = (groupX ++ groupY) : (otherGroups x . otherGroups y) g where groupX = charsGroup x g groupY = charsGroup y g diff --git a/Init.hs b/Init.hs new file mode 100644 index 0000000..e116709 --- /dev/null +++ b/Init.hs @@ -0,0 +1,23 @@ +module Init where + +import Types +import Cards + +initBS = BoardState + { bsNeoTokyo = NeoTokyo + { ntGroups = [ [Shinji], [Asuka], [Rei], [Misato], [Ritsuko], [Gendo] ] + , ntEvas = [ UnitZero, UnitOne, UnitTwo ] + , ntAngels = [] + , ntPutCards = [] + , ntDowned = [] + } + , bsPlayerLib = + [ (1, ("tA", [ S02_Asuka, S02_Asuka, S01_Shinji ], [], [])) + , (2, ("lunarised", [ S03_Rei, S03_Rei, S01_Shinji, S05_Ritsuko ], [], [])) + ] + , bsActivePlayers = [1,2] + , bsPriorityPlayer = 1 + , bsCardStack = [] + , bsCardLib = gCardLib + , bsGameLog = [] + } diff --git a/Print.hs b/Print.hs new file mode 100644 index 0000000..5be125c --- /dev/null +++ b/Print.hs @@ -0,0 +1,31 @@ +module Print where + +import Types +import Groups +import Data.List +import Data.Either + +printState :: BoardState -> IO () +printState bs = do + putStrLn "== BOARD STATE ==" + putStrLn " - Groups -" + mapM_ putStrLn $ let zipGroup = zip ['A' ... ] groups in map + (\(id, x) -> id ++ " ~ [ " ++ concatGroup x ++ " ] <-> " + concatGroup x $ map snd $ filter + (\(id,y) -> foldr (||) False (map (\z -> (any x) (getAdj z groups)) y) groups) + zipGroup +(\(id, x) -> foldr (||) False (map (== x `elem` $ zipGroup + putStrLn " - Downed -" + mapM_ putStrLn $ map + (\x -> "~ " ++ show x) $ groups + putStrLn " - GameLog -" + mapM_ putStrLn $ map + (\x -> + case x of + Left m -> m + Right e -> " : " ++ e) + (bsGameLog bs) + putStrLn " =================" + where + groups = (ntGroups . bsNeoTokyo) bs + concatGroup x = concat $ intersperse ", " (map show x)