Code:
case 1171: // LT&T Office
if ( ChoiceManager.lastDecision < 4 )
{
QuestDatabase.setQuestProgress( Quest.TELEGRAM, QuestDatabase.STARTED );
Preferences.setInteger( "lttQuestDifficulty", ChoiceManager.lastDecision );
Preferences.setInteger( "lttQuestStageCount", 0 );
Matcher matcher = TELEGRAM_PATTERN.matcher( ChoiceManager.lastResponseText );
for ( int i = 0; i < ChoiceManager.lastDecision ; i++ )
{
if ( !matcher.find() )
{
break;
}
}
Preferences.setString( "lttQuestName", matcher.group(1) );
}
break;
Yeah, well, that is obviously not robust, since matcher.group(1) can be called when matcher.find() just failed.
Here's a thought: where do we set ChoiceManager.lastResponseText?
In ChoiceManager.preChoice when we first visit a page, we set it to null
In ChoiceManager.visitChoice we set it to the responsetext of the request
In ChoiceManager.postChoice1, we set it to the responsetext of the request
Perhaps we should do those last two only if the URL of the request starts with choice.php?
If it does not, either the choice redirected, or you "walked away" from the choice.
Look again at GenericRequest:
Code:
if ( ChoiceManager.handlingChoice && !this.isChatRequest && !this.isDescRequest )
{
// Handle choices BEFORE registering Encounter
ChoiceManager.postChoice0( this );
}
and
Code:
if ( urlString.startsWith( "choice.php" ) && ChoiceManager.handlingChoice && !this.isChatRequest && !this.isDescRequest )
{
// Handle choices BEFORE result processing
ChoiceManager.postChoice1( this );
}
and
Code:
if ( ChoiceManager.handlingChoice && !this.isChatRequest && !this.isDescRequest )
{
// Handle choices AFTER result processing
ChoiceManager.postChoice2( this );
}
See all that stuff about isChatRequest and isDescRequest? We always ignore those, since you can do those in the middle of any choice.
Choices can legitimately lead to a fight - or to another choice - and neither is "walking away".
But going to main or adventure or inventory or whatever requires that you "walked away" from the choice.
Perhaps preChoice and postChoice1 and postChoice2 should make their own decision about whether the request actually continues the choice - or, perhaps, even constitutes "walking away" from the request. Putting it inline in GenericRequest saves the method call, but it really should be up to ChoiceManager.
Code:
this.isChatRequest =
this.formURLString.startsWith( "newchatmessages.php" ) ||
this.formURLString.startsWith( "submitnewchat.php" );
this.isDescRequest = this.formURLString.startsWith( "desc_" );
Bth of those are used in places other than choice handling.