AnssiR66 / AlanStdLib

The Standard Library for ALAN Interactive Fiction Language
Other
6 stars 2 forks source link

Extend Tests + Fix 'listen' #45

Closed tajmone closed 5 years ago

tajmone commented 5 years ago

New Tests

The first commit adds new props to the house and new test files. It also uncovers some problems with the listen verb.

Fix Listen

Before merging the second commit, you might want to check that this fix won't create potential problems (which I might have overlooked).

If you look at the house_sounds.a3log test, before and after the fix, you'll notice that room and site ojects were not in scope to listen before the fix:

before the fix:

> listen to ceiling

> listen to floor

> listen to wall

after the fix:

> listen to ceiling
You hear nothing unusual.

> listen to floor
You hear nothing unusual.

> listen to wall
You hear nothing unusual.

In verb listen's DOES, I've changed IF ogg AT hero into IF hero AT ogg in order for the verb to work when hero is in a nested location (eg. in a hole) and to work with room/site objects (which are not AT hero's location because they're in a wrapping location, but on the other hand the hero is AT their location).

Before this fix, trying to listen to the sky or ceiling would produce an empty string, as well as when trying to listen to something from a nested location.

So, basically I've just inverted the check criteria from checking if the object is at the hero's location to checking if the hero is at the object's location. The former was limited in scope to objects which were either at the current location or in locations nested therein, while the latter broadens the scope to include any locations that are nested within the object's location — effectively allowing any objects in wrapping locations to be withing scope, which I think is the whole purpose of putting them in such wrappers in the first place.

Please, let me know if you think this might create unexpected results. Personally, I think this fix is correct — since you can see the ceiling, you should also be able to listen to it, right?