Pages

On the other hand, I was tempted to add the darkness code to the predefined Location class, but reconsidered for two reasons. First, few or no rooms in any game will ever need to be darkened, so the respective checks will be a useless overhead most of the time. Second, having a distinct DarkRoom class means you can bypass it entirely and roll your own mechanism if you want. Especially as I went with a primitive implementation which doesn't consider portable light sources. (Nor is such a thing defined in the library.)

 

every darkroom isa location
 is dark.
 description
 check this is not dark
     else "It's too dark to see much."
   verb examine
     check this is not dark
       else "It's too dark to get a good look."
   end verb.
end every.

What They Say

"All those weirdly arranged parentheses, and semi-colons and strange curlicues hanging out in the middle of blank lines. Impossible. But when I looked at Alan I saw the light or, at least, English."

Eric Mayer