diff options
-rw-r--r-- | src/Main.hs | 20 |
1 files changed, 10 insertions, 10 deletions
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 () | |||
103 | listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') | 103 | listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') |
104 | listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) | 104 | listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) |
105 | 105 | ||
106 | -- Manage faction | ||
107 | listFaction, alignEntity :: Completable Faction -> Sh GameState () | ||
108 | listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) | ||
109 | alignEntity = withArg $ \nFaction -> withFocus $ \ident -> gEntities %= Map.adjust (set eFaction nFaction) ident | ||
110 | |||
111 | -- Automatic focus | 106 | -- Automatic focus |
112 | focusTip, blur :: Sh GameState () | 107 | focusTip, blur :: Sh GameState () |
113 | focusTip = gFocus <~ preuse tip | 108 | focusTip = gFocus <~ preuse tip |
@@ -138,6 +133,16 @@ nameEntity :: String -> Sh GameState () | |||
138 | nameEntity ('#':_) = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#<n>’)" | 133 | nameEntity ('#':_) = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#<n>’)" |
139 | nameEntity name = withFocus $ \ident -> modifying gEntityNames $ Bimap.insert ident (name ^. entityName) | 134 | nameEntity name = withFocus $ \ident -> modifying gEntityNames $ Bimap.insert ident (name ^. entityName) |
140 | 135 | ||
136 | -- Manage faction | ||
137 | listFaction, alignEntity :: Completable Faction -> Sh GameState () | ||
138 | listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) | ||
139 | alignEntity = withArg $ \nFaction -> withFocus $ \ident -> gEntities %= Map.adjust (set eFaction nFaction) ident | ||
140 | |||
141 | renameFaction :: Completable Faction -> Completable Faction -> Sh GameState () | ||
142 | renameFaction f1' f2' = withArg (\f1 -> withArg (\f2 -> renameFaction' f1 f2) f2') f1' | ||
143 | where | ||
144 | renameFaction' f1 f2 = modifying (gEntities . each . eFaction) (\cF -> bool cF f2 $ cF == f1) | ||
145 | |||
141 | spawnFaction :: Completable Faction -> Integer -> Completable Entity -> String -> Sh GameState () | 146 | spawnFaction :: Completable Faction -> Integer -> Completable Entity -> String -> Sh GameState () |
142 | spawnFaction cFaction num cEntity nameTemplate | 147 | spawnFaction cFaction num cEntity nameTemplate |
143 | | ('#':_) <- nameTemplate = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#<n>’)" | 148 | | ('#':_) <- nameTemplate = shellPutErrLn "We do not allow names that might shadow explicit access to entities via their number (‘#<n>’)" |
@@ -197,8 +202,3 @@ entitySeqVal' ident = do | |||
197 | Just (entity, sVal) -> do | 202 | Just (entity, sVal) -> do |
198 | (newEntity, view (seqVal . re _Just) -> val) <- evalFormula entity sVal | 203 | (newEntity, view (seqVal . re _Just) -> val) <- evalFormula entity sVal |
199 | gEntities . at ident .= Just (newEntity & set eSeqVal val) | 204 | gEntities . at ident .= Just (newEntity & set eSeqVal val) |
200 | |||
201 | renameFaction :: Completable Faction -> Completable Faction -> Sh GameState () | ||
202 | renameFaction f1' f2' = withArg (\f1 -> withArg (\f2 -> renameFaction' f1 f2) f2') f1' | ||
203 | where | ||
204 | renameFaction' f1 f2 = modifying (gEntities . each . eFaction) (\cF -> bool cF f2 $ cF == f1) | ||