diff --git a/run_no b/run_no index d7b14a6..34c3a20 100644 --- a/run_no +++ b/run_no @@ -1 +1 @@ -476 \ No newline at end of file +487 \ No newline at end of file diff --git a/src/Yaifl/Game/Actions/Examining.hs b/src/Yaifl/Game/Actions/Examining.hs index d05ac9c..d4f719b 100644 --- a/src/Yaifl/Game/Actions/Examining.hs +++ b/src/Yaifl/Game/Actions/Examining.hs @@ -35,7 +35,7 @@ instance ArgsMightHaveMainObject (ExaminingActionVariables wm) (AnyObject wm) wh type ExaminingAction wm = Action wm ExaminingResponses ('TakesOneOf 'TakesDirectionParameter 'TakesObjectParameter) (ExaminingActionVariables wm) examiningAction :: ExaminingAction wm examiningAction = (makeAction "examining") - { understandAs = ["examine", "examining", "look closely at"] + { understandAs = ["examine", "examining", "look closely at", "x"] , parseArguments = ParseArguments (\(UnverifiedArgs Args{..}) -> do let examiningSubject = ET $ fst variables return $ Right $ EAV {examiningSubject, examiningTextPrinted = False}) @@ -82,7 +82,7 @@ standardExamining = Rule "standard examining rule" forPlayer' $ \Args{..} -> do -- now examine text printed is true. if desc /= "" then do - [saying|{desc}#{linebreak}]|] + [saying|{desc}#{linebreak}|] pure $ Just True else pure Nothing pure (Nothing, Nothing) diff --git a/src/Yaifl/Game/Actions/Going.hs b/src/Yaifl/Game/Actions/Going.hs index 8b7cf99..8bb9c7b 100644 --- a/src/Yaifl/Game/Actions/Going.hs +++ b/src/Yaifl/Game/Actions/Going.hs @@ -12,7 +12,7 @@ import Solitude import Yaifl.Model.Action import Yaifl.Model.Entity -import Yaifl.Model.Metadata ( isPlayer ) +import Yaifl.Model.Metadata import Yaifl.Model.Kinds.Object import Yaifl.Model.Query import Yaifl.Model.Actions.Args @@ -39,8 +39,6 @@ import Yaifl.Model.Kinds.Room import Yaifl.Model.Kinds.Thing import Yaifl.Model.Kinds.AnyObject import Yaifl.Model.Kinds.Door -import Yaifl.Model.ObjectKind - data GoingActionVariables wm = GoingActionVariables { --The going action has a room called the room gone from (matched as "from"). roomGoneFrom :: Room wm diff --git a/src/Yaifl/Game/Actions/Looking/Visibility.hs b/src/Yaifl/Game/Actions/Looking/Visibility.hs index 7047732..8f4b3ff 100644 --- a/src/Yaifl/Game/Actions/Looking/Visibility.hs +++ b/src/Yaifl/Game/Actions/Looking/Visibility.hs @@ -23,7 +23,7 @@ import Yaifl.Model.WorldModel import Yaifl.Model.Actions.Args import qualified Data.EnumSet as DES import Yaifl.Model.Kinds.AnyObject -import Yaifl.Model.ObjectKind +import Yaifl.Model.Metadata -- | An easier way to describe the requirements to look. type HasLookingProperties wm = diff --git a/src/Yaifl/Game/Activities/PrintingLocaleParagraphAbout.hs b/src/Yaifl/Game/Activities/PrintingLocaleParagraphAbout.hs index f7fa459..049ec64 100644 --- a/src/Yaifl/Game/Activities/PrintingLocaleParagraphAbout.hs +++ b/src/Yaifl/Game/Activities/PrintingLocaleParagraphAbout.hs @@ -19,7 +19,7 @@ import Yaifl.Text.Say import Yaifl.Text.AdaptiveNarrative import Yaifl.Text.Responses import Yaifl.Model.Kinds.AnyObject -import Yaifl.Model.ObjectKind +import Yaifl.Model.Metadata setLocalePriority :: AnyObject s diff --git a/src/Yaifl/Game/Activities/PrintingTheLocaleDescription.hs b/src/Yaifl/Game/Activities/PrintingTheLocaleDescription.hs index e2ff555..36db082 100644 --- a/src/Yaifl/Game/Activities/PrintingTheLocaleDescription.hs +++ b/src/Yaifl/Game/Activities/PrintingTheLocaleDescription.hs @@ -25,6 +25,7 @@ import Yaifl.Text.Say import qualified Data.EnumMap.Strict as DEM import Yaifl.Text.ListWriter import Yaifl.Model.ObjectKind +import Yaifl.Model.Metadata data YouCanAlsoSeeResponses = YouCanAlsoSeeA diff --git a/src/Yaifl/Game/Create/Object.hs b/src/Yaifl/Game/Create/Object.hs index fc26da5..8b00d4a 100644 --- a/src/Yaifl/Game/Create/Object.hs +++ b/src/Yaifl/Game/Create/Object.hs @@ -32,9 +32,12 @@ import Yaifl.Model.WorldModel import qualified Data.Set as S import Yaifl.Model.Kinds.Region (RegionEntity, Region (..)) +import Data.Char (isUpper) +import qualified Data.Text as T makeObject :: - Pointed s + Display (WMSayable wm) + => Pointed s => ObjectUpdate wm :> es => State Metadata :> es => WMSayable wm -- ^ Name. @@ -47,7 +50,9 @@ makeObject :: makeObject n d ty isT specifics details = do e <- generateEntity isT t <- getGlobalTime - return (e, Object n Nothing PubliclyNamed Nothing S.empty SingularNamed Improper d e ty t t (fromMaybe identityElement specifics) details) + let shownName = display n + return (e, Object n Nothing PubliclyNamed Nothing S.empty SingularNamed + (if not (T.null shownName) && isUpper (T.head shownName) then Proper else Improper) d e ty t t (fromMaybe identityElement specifics) details) addObject :: Pointed s diff --git a/src/Yaifl/Game/ObjectSpecifics.hs b/src/Yaifl/Game/ObjectSpecifics.hs index 2451ec8..ce5444f 100644 --- a/src/Yaifl/Game/ObjectSpecifics.hs +++ b/src/Yaifl/Game/ObjectSpecifics.hs @@ -57,7 +57,7 @@ instance WMHasObjSpecifics ('WorldModel ObjectSpecifics a b c ac r se) where inj _ = id instance MayHaveProperty ObjectSpecifics Enclosing where - propertyAT = _EnclosingSpecifics `thenATraverse` (_ContainerSpecifics % containerEnclosing) + propertyAT = _EnclosingSpecifics `thenATraverse` (_ContainerSpecifics % containerEnclosing) `thenATraverse` (_PersonSpecifics % #carrying) instance MayHaveProperty ObjectSpecifics MultiLocated where propertyAT = _DoorSpecifics % #multiLocated --`thenATraverse` (_ContainerSpecifics % containerEnclosing) @@ -76,6 +76,12 @@ instance MayHaveProperty ObjectSpecifics Openability where instance MayHaveProperty ObjectSpecifics Door where propertyAT = castOptic _DoorSpecifics +instance MayHaveProperty ObjectSpecifics Device where + propertyAT = castOptic _DeviceSpecifics + +instance MayHaveProperty ObjectSpecifics Person where + propertyAT = castOptic _PersonSpecifics + localST :: State st :> es => (st -> st) diff --git a/src/Yaifl/Model/Kinds/Animal.hs b/src/Yaifl/Model/Kinds/Animal.hs index 91cb093..8b2dadf 100644 --- a/src/Yaifl/Model/Kinds/Animal.hs +++ b/src/Yaifl/Model/Kinds/Animal.hs @@ -4,7 +4,7 @@ import Solitude import Yaifl.Model.Kinds.Object import Yaifl.Model.Effects import Yaifl.Model.Query -import Yaifl.Model.ObjectKind +import Yaifl.Model.Metadata isAnimal :: NoMissingObjects wm es diff --git a/src/Yaifl/Model/Kinds/Supporter.hs b/src/Yaifl/Model/Kinds/Supporter.hs index ba8d70a..ff96db3 100644 --- a/src/Yaifl/Model/Kinds/Supporter.hs +++ b/src/Yaifl/Model/Kinds/Supporter.hs @@ -17,7 +17,7 @@ import Solitude import Yaifl.Model.Kinds.Object import Yaifl.Model.Query import Yaifl.Model.Effects -import Yaifl.Model.ObjectKind +import Yaifl.Model.Metadata -- | Check if @o@ is of the @supporter@ type. isSupporter :: diff --git a/src/Yaifl/Model/Metadata.hs b/src/Yaifl/Model/Metadata.hs index eddae13..413a4c9 100644 --- a/src/Yaifl/Model/Metadata.hs +++ b/src/Yaifl/Model/Metadata.hs @@ -33,6 +33,9 @@ module Yaifl.Model.Metadata ( , getGlobalTime , tickGlobalTime , isKind + + , kindIsUnderstoodAs + , kindPluralIsUnderstoodAs ) where import Breadcrumbs @@ -205,4 +208,18 @@ isKind o = isKindInternal (o ^. #objectType) then return True else - anyM (`isKindInternal` e') iv \ No newline at end of file + anyM (`isKindInternal` e') iv + +kindIsUnderstoodAs :: + ObjectKind + -> [ObjectKind] + -> Eff es () +kindIsUnderstoodAs kind otherKinds = do + pass + +kindPluralIsUnderstoodAs :: + ObjectKind + -> [ObjectKind] + -> Eff es () +kindPluralIsUnderstoodAs kind otherKinds = do + pass \ No newline at end of file diff --git a/src/Yaifl/Text/Say.hs b/src/Yaifl/Text/Say.hs index be679c5..bac8043 100644 --- a/src/Yaifl/Text/Say.hs +++ b/src/Yaifl/Text/Say.hs @@ -204,10 +204,8 @@ instance (ObjectLike wm o, WithPrintingNameOfSomething wm) => SayableValue (Sayi (o :: AnyObject wm) <- getObject objLike oName <- sayText $ o ^. #name let articleEff - | isDef = (if o ^. #nameProperness == Proper - then pure "" - else pure "the" - ) + | o ^. #nameProperness == Proper = pure "" + | isDef = pure "the" | o ^. #namePlurality == PluralNamed = pure "some" | Just x <- o ^. #indefiniteArticle = sayText x | (oName ^? _head) `elem` map Just ['a', 'i', 'e', 'o', 'u'] = pure "an" diff --git a/test/Yaifl/Test/Chapter3/Bic.hs b/test/Yaifl/Test/Chapter3/Bic.hs index dad94dc..31a096e 100644 --- a/test/Yaifl/Test/Chapter3/Bic.hs +++ b/test/Yaifl/Test/Chapter3/Bic.hs @@ -15,6 +15,7 @@ import Yaifl.Model.WorldModel import Named import Yaifl.Text.SayQQ import Yaifl.Model.Kinds.Thing +import Yaifl.Model.Query ex2 :: (Text, [a], Game PlainWorldModel ()) ex2 = ("Bic", [], ex2World) @@ -26,7 +27,8 @@ ex2World :: Game PlainWorldModel () ex2World = do setTitle "Bic" addRoom "The Staff Break Room" "" - addThing "Bic pen" ! defaults + bp <- addThing "Bic pen" ! defaults + modifyThing bp (#nameProperness .~ Improper) addThing "orange" ! #description "It's a small hard pinch-skinned thing from the lunch room, probably with lots of pips and no juice." ! defaults addThing "napkin" ! #description "Slightly crumpled." ! defaults addWhenPlayBegins $ makeRule' "run property checks at the start of play rule" $ diff --git a/test/Yaifl/Test/Chapter3/Common.hs b/test/Yaifl/Test/Chapter3/Common.hs index 8acf79d..e098ae4 100644 --- a/test/Yaifl/Test/Chapter3/Common.hs +++ b/test/Yaifl/Test/Chapter3/Common.hs @@ -14,6 +14,7 @@ import Yaifl.Test.Chapter3.Verbosity import Yaifl.Test.Chapter3.TheUnbuttonedElevatorAffair import qualified Data.Map as M import Yaifl (PlainWorldModel, Game) +import Yaifl.Test.Chapter3.FirstNameBasis c3Harness :: (Text, [Text], Game PlainWorldModel ()) -> (String, IO Text) c3Harness (n, ac, g) = (toString n, testHarness False n ac defaultOptions g) @@ -29,4 +30,5 @@ spec _allTenses = M.fromList , c3Harness ex8 -- Port Royal 2 , c3Harness ex9 -- unbuttoned elevator affair , c3Harness ex10 -- Port Royal 3 + , c3Harness ex11 ] diff --git a/test/Yaifl/Test/Chapter3/FirstNameBasis.hs b/test/Yaifl/Test/Chapter3/FirstNameBasis.hs index 9ee6d56..0cdb895 100644 --- a/test/Yaifl/Test/Chapter3/FirstNameBasis.hs +++ b/test/Yaifl/Test/Chapter3/FirstNameBasis.hs @@ -24,11 +24,12 @@ firstNameBasisWorld = do setTitle "First Name Basis" tcl <- addRoom "The Crew Lounge" [wrappedText|Deliberately spartan: the crew feels weight restrictions here first, so there aren't any chairs, just a few thin pads on the ground.|] - thp <- addDevice "holographic projector" "The one major source of entertainment is the holographic projector, a top of the line Misthon 9000, on which you view every beam you can get." ! - #description (text "projector description" $ withThing $ \t -> do - let ds = getDeviceMaybe t - let isOn = fromMaybe False $ ds ^? _Just % #switchedOn - [sayingTell|{?if isOn}The projector is now playing a documentary about the early politics of the Mars colony.{?else} + thp <- addDevice "holographic projector" + ! #initialAppearance "The one major source of entertainment is the holographic projector, a top of the line Misthon 9000, on which you view every beam you can get." + ! #description (text "projector description" $ withThing $ \t -> do + let ds = getDeviceMaybe t + let isOn = fromMaybe False $ ds ^? _Just % #switchedOn + [sayingTell|{?if isOn}The projector is now playing a documentary about the early politics of the Mars colony.{?else} The air above the projector is disappointingly clear.{?end if}|]) ! defaults thp `isUnderstoodAs` ["holo", "holograph", "Misthon", "9000"]