From db807844a62d6425bea2af3c35270b8377d1a987 Mon Sep 17 00:00:00 2001 From: avery Date: Sat, 21 Oct 2023 10:56:53 +0200 Subject: [PATCH] the second test passes if I fix the golden test-ness --- src/Yaifl/Actions/ActionProcessing.hs | 7 ++++++- src/Yaifl/Actions/Going.hs | 9 +++++---- src/Yaifl/Actions/Parser.hs | 2 +- test/Yaifl/Test/Common.hs | 3 ++- traceid.temp | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Yaifl/Actions/ActionProcessing.hs b/src/Yaifl/Actions/ActionProcessing.hs index b8d541c..5204018 100644 --- a/src/Yaifl/Actions/ActionProcessing.hs +++ b/src/Yaifl/Actions/ActionProcessing.hs @@ -41,6 +41,11 @@ actionProcessingRules = ActionProcessing $ \aSpan Action{..} u -> withoutMissing return (first Just $ fromMaybe (v, Nothing) r)) , notImplementedRule "after stage rule" , notImplementedRule "investigate player awareness after rule" - , notImplementedRule "report stage rule" + , Rule "report stage rule" + [] + ( \v -> do + ignoreSpan + r <- runRulebookAndReturnVariables (Just aSpan) reportRules v + return (first Just $ fromMaybe (v, Nothing) r)) , notImplementedRule "clean actions rule" ]) u) (handleMissingObject "" (Just False)) diff --git a/src/Yaifl/Actions/Going.hs b/src/Yaifl/Actions/Going.hs index 647a42f..199bf5f 100644 --- a/src/Yaifl/Actions/Going.hs +++ b/src/Yaifl/Actions/Going.hs @@ -56,8 +56,10 @@ goingAction = Action describeRoomGoneInto :: Rule wm (Args wm (GoingActionVariables wm)) Bool describeRoomGoneInto = makeRule "describe room gone into rule" [] $ \a -> ifM (isPlayer (source a)) - (when (silently . actionOptions $ a) (error "") >> error "") - (error "") + (unless (silently . actionOptions $ a) (void $ do + sayLn @Text "" + parseAction ((actionOptions a) { silently = True }) "look") >> rulePass) + (error "other actors cant report going yet") carryOutGoingRules :: WMHasProperty wm Enclosing => ActionRulebook wm (GoingActionVariables wm) @@ -80,7 +82,6 @@ movePlayerAndVehicle = makeRule "move player and vehicle rule" [] $ \a@Args{vari Just _x -> error "failed to move with a vehicle" pure $ if moveSuccessful then Nothing else Just False - goingActionSet :: forall wm es. (ParseArgumentEffects wm es, WMStdDirections wm, WMHasProperty wm DoorSpecifics) @@ -150,7 +151,7 @@ getMatchingThing matchElement = do Just e' -> getThingMaybe e' setDoorGoneThrough :: AnyObject wm -> Eff es (Maybe Entity) -setDoorGoneThrough = error "" +setDoorGoneThrough _ = pure Nothing getDoorMaybe :: Thing wm -> AnyObject wm getDoorMaybe = error "" diff --git a/src/Yaifl/Actions/Parser.hs b/src/Yaifl/Actions/Parser.hs index 1aef8b8..a8a39f4 100644 --- a/src/Yaifl/Actions/Parser.hs +++ b/src/Yaifl/Actions/Parser.hs @@ -47,7 +47,7 @@ runActionHandlerAsWorldActions :: runActionHandlerAsWorldActions = interpret $ \_ -> \case ParseAction actionOpts t -> withSpan' "action" t $ do -- print the prompt - unless (silently actionOpts || hidePrompt actionOpts) $ printLn $ "> " <> t + unless (silently actionOpts || hidePrompt actionOpts) $ printLn $ "\n>" <> t --we assume that the verb is the first thing in the command possVerbs <- findVerb t ac <- case possVerbs of diff --git a/test/Yaifl/Test/Common.hs b/test/Yaifl/Test/Common.hs index 22e26b8..ed3c521 100644 --- a/test/Yaifl/Test/Common.hs +++ b/test/Yaifl/Test/Common.hs @@ -19,6 +19,7 @@ import qualified Data.Text as T import Yaifl.Text.AdaptiveNarrative import Yaifl.Text.Print import Yaifl.Text.Verb +import Yaifl.Rules.Args expQQ :: (String -> Q Exp) -> QuasiQuoter expQQ quoteExp = QuasiQuoter quoteExp notSupported notSupported notSupported where @@ -89,7 +90,7 @@ testHarness allTenses fullTitle actionsToDo conOptions initWorld = do unless (suffix == "") $ printLn suffix --when I write a proper game loop, this is where it needs to go failHorriblyIfMissing (runRulebook Nothing (wa ^. #whenPlayBegins) ()) - mapM_ (parseAction (ActionOptions False Nothing)) actionsToDo + mapM_ (parseAction (ActionOptions False False)) actionsToDo (w2 :: World wm) <- get let (x, _) = runPureEff $ runStateShared w2 $ do -- take it down and flip it around diff --git a/traceid.temp b/traceid.temp index 6f73f55..3f393c9 100644 --- a/traceid.temp +++ b/traceid.temp @@ -1 +1 @@ -/¯“)<ýdÇÚlM \ No newline at end of file +ª>¼y¡£;:x£­—W%À \ No newline at end of file