diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-03 00:59:08 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-03 00:59:08 +0200 |
commit | ab903fff1d08e36092d25205e061fe42e5c62d4b (patch) | |
tree | 4184b825773fa41a45470e4b7d5daa7ff3469551 /src/Main.hs | |
parent | 1b7f21ba636e4034f76495deafd0ac6ca9758a4e (diff) | |
download | 2017-01-16_17:13:37-ab903fff1d08e36092d25205e061fe42e5c62d4b.tar 2017-01-16_17:13:37-ab903fff1d08e36092d25205e061fe42e5c62d4b.tar.gz 2017-01-16_17:13:37-ab903fff1d08e36092d25205e061fe42e5c62d4b.tar.bz2 2017-01-16_17:13:37-ab903fff1d08e36092d25205e061fe42e5c62d4b.tar.xz 2017-01-16_17:13:37-ab903fff1d08e36092d25205e061fe42e5c62d4b.zip |
align entities to factions
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 7 |
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 | ||
70 | listFaction :: Completable Faction -> Sh GameState () | 71 | listFaction :: Completable Faction -> Sh GameState () |
71 | listFaction (Completable (flip (set faction') def -> qFaction)) = use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) | 72 | listFaction = withArg $ \qFaction -> use gEntities >>= mapM_ (shellPutStrLn <=< toName) . Map.keys . Map.filter ((==) qFaction . view eFaction) |
72 | 73 | ||
73 | listFactions :: Sh GameState () | 74 | listFactions :: Sh GameState () |
74 | listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') | 75 | listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') |
75 | 76 | ||
76 | listEntities :: Sh GameState () | 77 | listEntities :: Sh GameState () |
77 | listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) | 78 | listEntities = use (gEntities . to Map.keys) >>= mapM_ (shellPutStrLn <=< toName) |
79 | |||
80 | alignEntity :: Completable EntityIdentifier -> Completable Faction -> Sh GameState () | ||
81 | alignEntity ident' nFaction' = flip withArg nFaction' $ \nFaction -> flip withArg ident' $ \ident -> do | ||
82 | gEntities %= Map.adjust (set eFaction nFaction) ident | ||