Skip to content

Commit

Permalink
Fix a PersonName
Browse files Browse the repository at this point in the history
  • Loading branch information
PPKFS committed Jan 31, 2024
1 parent 394fa0f commit a8f2ab4
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion run_no
Original file line number Diff line number Diff line change
@@ -1 +1 @@
476
487
4 changes: 2 additions & 2 deletions src/Yaifl/Game/Actions/Examining.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/Yaifl/Game/Actions/Going.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Yaifl/Game/Actions/Looking/Visibility.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/Yaifl/Game/Activities/PrintingLocaleParagraphAbout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Yaifl/Game/Activities/PrintingTheLocaleDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/Yaifl/Game/Create/Object.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/Yaifl/Game/ObjectSpecifics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Yaifl/Model/Kinds/Animal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Yaifl/Model/Kinds/Supporter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ::
Expand Down
19 changes: 18 additions & 1 deletion src/Yaifl/Model/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module Yaifl.Model.Metadata (
, getGlobalTime
, tickGlobalTime
, isKind

, kindIsUnderstoodAs
, kindPluralIsUnderstoodAs
) where

import Breadcrumbs
Expand Down Expand Up @@ -205,4 +208,18 @@ isKind o = isKindInternal (o ^. #objectType)
then
return True
else
anyM (`isKindInternal` e') iv
anyM (`isKindInternal` e') iv

kindIsUnderstoodAs ::
ObjectKind
-> [ObjectKind]
-> Eff es ()
kindIsUnderstoodAs kind otherKinds = do

Check warning on line 217 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘kind’

Check warning on line 217 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘otherKinds’

Check warning on line 217 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘kind’

Check warning on line 217 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘otherKinds’
pass

kindPluralIsUnderstoodAs ::
ObjectKind
-> [ObjectKind]
-> Eff es ()
kindPluralIsUnderstoodAs kind otherKinds = do

Check warning on line 224 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘kind’

Check warning on line 224 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘otherKinds’

Check warning on line 224 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘kind’

Check warning on line 224 in src/Yaifl/Model/Metadata.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘otherKinds’
pass
6 changes: 2 additions & 4 deletions src/Yaifl/Text/Say.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion test/Yaifl/Test/Chapter3/Bic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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" $
Expand Down
2 changes: 2 additions & 0 deletions test/Yaifl/Test/Chapter3/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
]
11 changes: 6 additions & 5 deletions test/Yaifl/Test/Chapter3/FirstNameBasis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit a8f2ab4

Please sign in to comment.