summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 639673c..903da05 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -46,6 +46,7 @@ main = do
46 , cmd "factions" listFactions "List all inhabited factions" 46 , cmd "factions" listFactions "List all inhabited factions"
47 , cmd "members" listFaction "List all members of a faction" 47 , cmd "members" listFaction "List all members of a faction"
48 , cmd "entities" listEntities "List all entities" 48 , cmd "entities" listEntities "List all entities"
49 , cmd "align" alignEntity "Align an entity to a faction creating it, if necessary"
49 ] 50 ]
50 } 51 }
51 void $ runShell description haskelineBackend (def :: GameState) 52 void $ runShell description haskelineBackend (def :: GameState)
@@ -68,10 +69,14 @@ stateOutline st
68 return . colsAllG top $ [show (seqVal' ^. seqVal)] : map factionColumn [0..(length factions - 1)] 69 return . colsAllG top $ [show (seqVal' ^. seqVal)] : map factionColumn [0..(length factions - 1)]
69 70
70listFaction :: Completable Faction -> Sh GameState () 71listFaction :: Completable Faction -> Sh GameState ()
71listFaction (Completable (flip (set faction') def -> qFaction)) = use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) 72listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction)
72 73
73listFactions :: Sh GameState () 74listFactions :: Sh GameState ()
74listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') 75listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction')
75 76
76listEntities :: Sh GameState () 77listEntities :: Sh GameState ()
77listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) 78listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName)
79
80alignEntity :: Completable EntityIdentifier -> Completable Faction -> Sh GameState ()
81alignEntity ident' nFaction' = flip withArg nFaction' $ \nFaction -> flip withArg ident' $ \ident -> do
82 gEntities %= Map.adjust (set eFaction nFaction) ident