Skip to content

Commit

Permalink
Add example 16
Browse files Browse the repository at this point in the history
  • Loading branch information
PPKFS committed Dec 24, 2024
1 parent c917fcc commit 26c8232
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yaifl/run_no
Original file line number Diff line number Diff line change
@@ -1 +1 @@
727
731
2 changes: 2 additions & 0 deletions yaifl/test/Yaifl/Test/Chapter3/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Yaifl (PlainWorldModel, Game)
import Yaifl.Test.Chapter3.FirstNameBasis
import Yaifl.Test.Chapter3.MidsummerDay
import Yaifl.Test.Chapter3.Tamed
import Yaifl.Test.Chapter3.Replanting

c3Harness :: (Text, [Text], Game PlainWorldModel ()) -> (String, IO Text)
c3Harness (n, ac, g) = (toString n, testHarness False n ac defaultOptions g)
Expand All @@ -39,4 +40,5 @@ spec _allTenses = M.fromList
, c3Harness ex13 -- Tamed
, c3Harness ex14 -- Disenchantment Bay
, c3Harness ex15 -- Disenchantment Bay 2
, c3Harness ex16 -- Replanting
]
38 changes: 38 additions & 0 deletions yaifl/test/Yaifl/Test/Chapter3/Replanting.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module Yaifl.Test.Chapter3.Replanting where

import Yaifl.Prelude

import Yaifl (PlainWorldModel)

import Yaifl.Game.Create.Object
import Yaifl.Game.EffectHandlers
import Yaifl.Game.ObjectSpecifics
import Yaifl.Model.Kinds.Container
import Yaifl.Model.Kinds.Openable
import Yaifl.Model.Kinds.Supporter
import Yaifl.Model.Metadata
import Yaifl.Test.Common
import Yaifl.Model.Kinds.Object
import Yaifl.Model.Query
import Yaifl.Game.Create
import Yaifl.Model.Rules (Precondition(..), variables, say)
import Yaifl.Model.Kinds.Thing ( thingIsScenery )

ex16 :: (Text, [Text], Game PlainWorldModel ())
ex16 = ("Replanting", replantingTestMeWith, replantingWorld)

replantingWorld :: Game PlainWorldModel ()
replantingWorld = do
setTitle "Replanting"
addRoom "The Orchard" ! #description
"Within this quadrille of pear trees, a single gnarled old oak remains as a memory of centuries past."

addThing "gnarled oak tree"
! #modify makeItScenery
! done
insteadOf (ActionRule #taking) [Precondition (pure "taking scenery") $
\t -> return (thingIsScenery (variables t))] (const $ say @Text "You lack the hulk-like strength.")
pass

replantingTestMeWith :: [Text]
replantingTestMeWith = ["take oak"]
10 changes: 10 additions & 0 deletions yaifl/test/testcases/Chapter3/Replanting
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------------
----- Replanting -----
----------------------

The Orchard
Within this quadrille of pear trees, a single gnarled old oak remains as a memory of centuries past.

>take oak

You lack the hulk-like strength.
1 change: 1 addition & 0 deletions yaifl/yaifl.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ test-suite yaifl-test
Yaifl.Test.Chapter3.DisenchantmentBay2
Yaifl.Test.Chapter3.FirstNameBasis
Yaifl.Test.Chapter3.MidsummerDay
Yaifl.Test.Chapter3.Replanting
Yaifl.Test.Chapter3.PortRoyal
Yaifl.Test.Chapter3.PortRoyal2
Yaifl.Test.Chapter3.PortRoyal3
Expand Down

0 comments on commit 26c8232

Please sign in to comment.