UNPKG

qnce-engine

Version:

Core QNCE (Quantum Narrative Convergence Engine) - Framework agnostic narrative engine with performance optimization

83 lines (71 loc) • 2.54 kB
// QNCE Branching Demo - JavaScript Quick Start // Demonstrates v1.2.0 Advanced Branching API integration const { createQNCEEngine } = require('../dist/engine/core'); console.log('šŸš€ QNCE Engine v1.2.0 - Advanced Branching Demo'); console.log('=================================================\n'); // Create a simple story for demonstration const simpleStory = { nodes: [ { id: 'start', text: 'You discover a mysterious quantum portal. What do you do?', choices: [ { text: 'Step through the portal', nextNodeId: 'portal-world', flagEffects: { courage: 5, portal_used: true } }, { text: 'Study the portal carefully', nextNodeId: 'study-portal', flagEffects: { wisdom: 5, careful: true } } ] }, { id: 'portal-world', text: 'You emerge in a strange quantum realm where multiple realities overlap.', choices: [] }, { id: 'study-portal', text: 'Your careful study reveals ancient quantum equations etched around the portal\'s edge.', choices: [] } ], initialNodeId: 'start' }; // Create the QNCE engine console.log('āœ… Creating QNCE Engine...'); const engine = createQNCEEngine(simpleStory); // Display current state console.log('šŸ“– Current Story Node:'); console.log(' ' + engine.getCurrentNode().text); console.log('\nšŸŽÆ Available Choices:'); const choices = engine.getAvailableChoices(); choices.forEach((choice, i) => { console.log(` ${i + 1}. ${choice.text}`); }); // Make a choice automatically for demo if (choices.length > 0) { console.log('\nšŸš€ Making choice: "' + choices[0].text + '"'); engine.selectChoice(choices[0]); console.log('\nšŸ“– New Story Node:'); console.log(' ' + engine.getCurrentNode().text); console.log('\nšŸ“ Updated Flags:'); const flags = engine.getFlags(); Object.entries(flags).forEach(([key, value]) => { console.log(` ${key}: ${value}`); }); console.log('\nšŸ“š Choice History:'); const history = engine.getHistory(); history.forEach((nodeId, i) => { console.log(` ${i + 1}. ${nodeId}`); }); } console.log('\nšŸŽ‰ Demo Complete!'); console.log('================='); console.log('āœ… QNCE Engine v1.2.0 basic functionality working'); console.log('šŸ“š For advanced branching features, see TypeScript examples'); console.log('šŸ”— Advanced features: AI generation, dynamic branches, analytics'); console.log('\nšŸš€ Ready for your interactive narratives!');