From 73c24db325e741ca9402152d934bd28c7ac89fed Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 6 Jun 2016 18:15:29 +0200 Subject: reorder --- src/Main.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index f608c01..145df7a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -103,11 +103,6 @@ listFactions, listEntities :: Sh GameState () listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) --- Manage faction -listFaction, alignEntity :: Completable Faction -> Sh GameState () -listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) -alignEntity = withArg $ \nFaction -> withFocus $ \ident -> gEntities %= Map.adjust (set eFaction nFaction) ident - -- Automatic focus focusTip, blur :: Sh GameState () focusTip = gFocus <~ preuse tip @@ -138,6 +133,16 @@ nameEntity :: String -> Sh GameState () nameEntity ('#':_) = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#’)" nameEntity name = withFocus $ \ident -> modifying gEntityNames $ Bimap.insert ident (name ^. entityName) +-- Manage faction +listFaction, alignEntity :: Completable Faction -> Sh GameState () +listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) +alignEntity = withArg $ \nFaction -> withFocus $ \ident -> gEntities %= Map.adjust (set eFaction nFaction) ident + +renameFaction :: Completable Faction -> Completable Faction -> Sh GameState () +renameFaction f1' f2' = withArg (\f1 -> withArg (\f2 -> renameFaction' f1 f2) f2') f1' + where + renameFaction' f1 f2 = modifying (gEntities . each . eFaction) (\cF -> bool cF f2 $ cF == f1) + spawnFaction :: Completable Faction -> Integer -> Completable Entity -> String -> Sh GameState () spawnFaction cFaction num cEntity nameTemplate | ('#':_) <- nameTemplate = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#’)" @@ -197,8 +202,3 @@ entitySeqVal' ident = do Just (entity, sVal) -> do (newEntity, view (seqVal . re _Just) -> val) <- evalFormula entity sVal gEntities . at ident .= Just (newEntity & set eSeqVal val) - -renameFaction :: Completable Faction -> Completable Faction -> Sh GameState () -renameFaction f1' f2' = withArg (\f1 -> withArg (\f2 -> renameFaction' f1 f2) f2') f1' - where - renameFaction' f1 f2 = modifying (gEntities . each . eFaction) (\cF -> bool cF f2 $ cF == f1) -- cgit v1.2.3