OK. We're currently at the head of the "moaning" narrative.
We need to play that.
--
-- do the "moaning" branch
--
rc = narrator:play(stage) -- run it
assert_true(rc) -- not done yet
assert_equal(2, stage:num_oq()) -- two items in output queue
assert_equal("text", stage:oq(1).type)
assert_equal( -- using [[]] to escape " chars
[["Moan! Moan, moan, moan! Moan!"]],
stage:oq(1).value
)
assert_equal("text", stage:oq(2).type)
assert_equal( -- second snippet
"The door remains unmoved",
stage:oq(2).value
)
assert_nil(narrator.userdata.moan) -- still not set
assert_equal("moaning", narrator.narrative.name)-- same narrative
And that all passes. Play again for the func and the jump. This may look
familiar
--
-- play it again - this will run the func and the jump
--
rc = narrator:play(stage)
assert_true(rc)
assert_true(narrator.userdata.moan) -- now it's set!
assert_equal( -- new narrative
"in_the_room", narrator.narrative.name
)
assert_equal(0, narrator.index) -- index rewound
and that passes. Now for the final loop
rc = narrator:play(stage)
assert_true(rc)
assert_equal(2, stage:num_oq())
assert_equal("text", stage:oq(1).type)
assert_equal(
"You don't like it in this room. What do you want to do?",
stage:oq(1).value
)
local options = stage:oq(2).options
assert_not_nil(options)
assert_equal(3, #options)
assert_equal("Sulk", options[1].text)
assert_equal("sulking", options[1].next)
assert_equal("Complain", options[2].text)
assert_equal("moaning", options[2].next)
assert_equal("Try The Door", options[3].text)
assert_equal("thinking", options[3].next)
And that works! So option three shows up! I suppose I'd better make sure it works as a choice should...
No comments:
Post a Comment