Initially, this worked great, but I found that I could trick the game into showing me that there were only 4 newspaper objects with a command like >GET 5 NEWSPAPERS.
This also reminded me of an older WIP where, in a room full of golf balls, a tester tried the command >GET 1000 GOLF BALLS. Now, I'm not going to go code a thousand golf ball objects, but ever since then, I was a little disappointed that I couldn't do more to give the illusion that the game could handle such a command.
Anyhow, now that I have roodylib and a better understanding of how things work, I thought I'd take a swing at the problem. I tracked down the code in ParsePluralObjects that interprets the number in the command line. It calls WordIsNumber, which matches the word with a simple select-case that handles numbers "1"/"one" through "10"/"ten". I added code so it also calls StringToNumber, so it can now also handle 11-32767 (it can't handle the word version of these numbers but I figured that was a lost cause).
My first hurdle was that this section of code checks the word array for numbers twice, supposedly so that Hugo can understand commands like >GET TWO OUT OF THE THREE CHICKENS. My StringToNumber-enhanced routine can't be called twice like that, so I had to throw the "<blank> out of <blank>" code out.
It was easy enough to find the code in plural_class object where it prints a "There are only X objects here."-type command when you refer to too many, and it was also easy enough to change it to disregard the number of actual-objects-there.
Still, I thought there was another important number in the equation. There's the number you want the player to think is there. In the above example, I *don't* want >GET 1000 PAPERS to have the same reply as >GET 5 PAPERS. To handle this, I added a couple new properties to the plural_class object. One is called imaginary_plurals. It holds the number the plural class is supposed to have*.
* The type of plural object that uses these properties are going to be largely scenery. They aren't actually going to be picked up or interacted with to any large degree. We're only doing this to make responses sound smarter.
The other one is called over_max. It just holds the response the player will see when he refers to more objects than the imaginary plurals number.
Let's take a look at my finished newspaper object:
identical_class newspapers "newspapers"Hopefully, that'll all make sense in the end. There's a good chance I'm breaking more than I realized, as plural class stuff seems to juggle a lot. Anyhow, I think this *will* call for a new Roodylib upload. People can expect it soon enough.
plural_of paper1, paper2, paper3, paper4
noun "newspapers" "papers"
single_noun "newspaper" "paper"
"Even with all of the apartments and homes on your street, you'd
be lucky to find more than a dozen papers in the near vicinity."