jonkiparsky / z-engine

Automatically exported from code.google.com/p/z-engine
0 stars 0 forks source link

Flashlight loses state #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Take flashlight
2. turn flashlight on
3. inventory

What is the expected output? What do you see instead?
Flashlight should be reported as "on", instead remains off.

(Dan - this is more of a note-to-self, I did say I'd have a look at this and I 
don't want to let it slip off my stack)

Original issue reported on code.google.com by jon.kipa...@gmail.com on 9 Aug 2011 at 5:36

GoogleCodeExporter commented 8 years ago
This has been fixed for a while. It was due to inventory using get() instead of 
remove() while taking an item, so said item wasn't removed from the inventory.

Original comment by i.Snowbl...@gmail.com on 9 Aug 2011 at 12:58

GoogleCodeExporter commented 8 years ago
This is still a live bug:

take flashlight
     [java] >> initiated Sentence with TAKE
     [java] Sentence.accept(FLASHLIGHT) complements = TAKE current = TAKE
     [java] accepted FLASHLIGHT
     [java] class zengine.grammar.Flashlight
     [java] Result = true. Complements = TAKE
     [java] Sentence.accept(END OF STRING) complements = TAKE current = FLASHLIGHT
     [java] accepted END OF STRING
     [java] class zengine.grammar.None
     [java] Result = true. Complements = TAKE
     [java] FLASHLIGHT, 
     [java] You have a FLASHLIGHT.
     [java] The FLASHLIGHT is OFF
turn flashlight on
     [java] >> initiated Sentence with TURN
     [java] Sentence.accept(FLASHLIGHT) complements = TURN current = TURN
     [java] accepted FLASHLIGHT
     [java] class zengine.grammar.Flashlight
     [java] Result = true. Complements = TURN
     [java] Sentence.accept(ON) complements = TURN current = FLASHLIGHT
     [java] accepted ON
     [java] class zengine.grammar.On
     [java] Result = true. Complements = TURN
     [java] Sentence.accept(END OF STRING) complements = TURN current = ON
     [java] accepted END OF STRING
     [java] class zengine.grammar.None
     [java] Result = true. Complements = TURN
     [java] FLASHLIGHT, ON, 
i    
     [java] >> initiated Sentence with INVENTORY
     [java] You have a FLASHLIGHT.
     [java] The FLASHLIGHT is OFF

Original comment by jon.kipa...@gmail.com on 13 Aug 2011 at 5:31

GoogleCodeExporter commented 8 years ago
Found the problem. It was fixed for "Turn on flashlight", but not for "Turn 
flashlight on"

Added a possibly cool fix for this: check the player's inventory for the 
object. If it's there, use that one. Seems to work, but needs testing. 

Original comment by jon.kipa...@gmail.com on 13 Aug 2011 at 6:11