我遇到这样的情况:
"Cream Corner" by Lynn
An ice cream cone is a kind of edible thing.
An ice cream cone has a number called scoop count.
Rule for printing the name of an ice cream cone:
say "[the scoop count in words]-scoop ice cream cone".
The Cream Corner is a room.
The player holds an ice cream cone with scoop count 3.
现在我希望> eat three-scoop
能够正常工作。我可以这样做:
Understand "one-scoop" as an ice cream cone
when the scoop count of the item described is 1.
Understand "two-scoop" as an ice cream cone
when the scoop count of the item described is 2.
Understand "three-scoop" as an ice cream cone
when the scoop count of the item described is 3.
[ ... ]
但当然,理想情况下,我想写一个这样的规则:
Understand "[number]-scoop" as an ice cream cone
when the scoop count of the item described is the number understood.
但是,通知文档specifies that this is impossible:
因此,我们不能安全地说“当名词是冷杉锥”时,或者参考诸如“被理解的数字”之类的东西。 (我们还没有完成理解。)如果我们想要更复杂地处理这种情况,我们需要以通常的方式编写检查规则等。
同样,我不清楚如何以“通常的方式”用检查规则替换这样的规则。如何使用检查规则将播放器命令中的[number]-scoop
解释为“带有许多勺子的冰淇淋”?
答案 0 :(得分:2)
我不太确定文档暗示我们在那里做什么,但我可以帮助解决基本问题。部分解决方案是这两行:
Understand the scoop count property as referring to an ice cream cone.
Understand "scoop" as an ice cream cone.
这允许玩家输入three scoop cone
或three ice cream cone
之类的内容,并且可以理解三勺锥。
这只是一个部分解决方案,因为我们不包含短划线*,因此take three-scoop cone
之类的内容无法正确理解。解决此问题的显而易见的方法是在读取命令之前完全替换破折号,如下所示:
[Nonfunctional solution!]
After reading a command:
If the player's command includes "-scoop":
replace the matched text with " scoop";
然而,这似乎不起作用,因为上述规则只匹配整个单词 - 即{,three -scoop
,而不是three-scoop
。仅尝试替换-
尝试执行此操作同样失败。
*你也可以说three ice cream cone
不应该是有效的匹配。