From 8e1232fc24c67e80c14d6b56904876550342b6b2 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 6 Jun 2016 18:08:17 +0200 Subject: rename factions --- src/Main.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index 8d74def..f608c01 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -27,6 +27,7 @@ import Data.List import Data.List import Data.Maybe +import Data.Bool import Data.Function @@ -67,6 +68,7 @@ main = do , cmd "blur" blur "Focus no entity" , cmd "remove" remove "Remove the focused entity from the queue" , cmd "factions" listFactions "List all inhabited factions" + , cmd "name'" renameFaction "Rename a faction – merge if new name is taken" , cmd "members" listFaction "List all members of a faction" , cmd "align" alignEntity "Align the focused entity to a faction – creating it, if necessary" , cmd "name" nameEntity "Name the current entity overriding previous name assignments" @@ -195,3 +197,8 @@ 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