Document markup and improve choice tags
This commit is contained in:
@@ -214,10 +214,20 @@ class SocketClientModule extends BaseModule {
|
||||
this.receivedParagraphCounter = 0;
|
||||
}
|
||||
|
||||
if (Array.isArray(data.globalTags) && data.globalTags.length > 0) {
|
||||
const globalTags = Array.isArray(data.globalTags) ? data.globalTags : [];
|
||||
const endState = data.gameState?.endState || null;
|
||||
if (endState && !globalTags.some((tag) => tag?.key === 'score' || tag?.key === 'error')) {
|
||||
globalTags.push({
|
||||
key: endState.type === 'error' ? 'error' : 'score',
|
||||
value: endState.message || ''
|
||||
});
|
||||
}
|
||||
|
||||
if (globalTags.length > 0) {
|
||||
document.dispatchEvent(new CustomEvent('story:global-tags', {
|
||||
detail: data.globalTags
|
||||
detail: globalTags
|
||||
}));
|
||||
this.dispatchTurnTags(globalTags, null);
|
||||
}
|
||||
|
||||
document.dispatchEvent(new CustomEvent('story:turn-start', {
|
||||
@@ -245,6 +255,10 @@ class SocketClientModule extends BaseModule {
|
||||
document.dispatchEvent(new CustomEvent('story:process-state', {
|
||||
detail: { state: 'ready', reason: 'choice-only-turn', turnId }
|
||||
}));
|
||||
} else if (turnBlocks.length === 0 && inputMode === 'end') {
|
||||
document.dispatchEvent(new CustomEvent('story:process-state', {
|
||||
detail: { state: 'ready', reason: 'empty-end-turn', turnId }
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user