Coding 2020-03-19

By Max Woerner Chase

After last night's post, I figured out what I was doing wrong: I had two arguments in the wrong order. When I swapped them, it worked fine.

Before I touch anything else, I want to figure out what is in the StoryState class that I care about. I'm going to do that in here. Fair warning: I don't really know .NET or C#, so I'm going to be playing fast and loose with some of the terminology.

All right, so the following attributes get touched inside the Copy method:

In the jsonToken property, we get...

Now, I came up with the idea to divide the StoryState behavior into three (now four) states: LineState, ChoiceState, ReadyState, and EndState. When the story is in LineState, it has produced zero or more lines of text since the last state it was in, and could produce zero or more lines before transitioning to ChoiceState or EndState. In EndState, the state is functionally inert, until it's brought back to LineState by setting the path. In ChoiceState, it has produced zero or more choices since the last LineState, and could produce zero or more choices before transitioning to ReadyState; I don't think it can go directly to EndState, but implementing that if I need it shouldn't be a problem. Actually, what should it do if it tries to transition without producing a Choice...? In ReadyState, it has (hopefully!) produced at least one Choice, and, given one of those choices, it will transition to either LineState or EndState; the latter transition might not be necessary, depending on how diverts to END are coded.

For serialization purposes, I don't think it poses any problems to deserialize no choices as a LineState, and some choices as a ChoiceState. The "real" state might be EndState or ReadyState, but it'll immediately enter them if needed. I could be wrong. We'll see.

Anyway, the conclusion I draw here is that all the states need most of these values, except for _currentChoices. So, I should probably define a helper that tracks all of that state and use that in the State classes, since I expect most data to need to persist through transitions.

Anyway, that's a good thing to work on the next few days. For now, I should get to bed.

Good night.