switch(event.request.type) {
case'System.ExceptionEncountered':
speechOutput='You took too long to respond. Please say change my color to start the button color change.';
textOutput=speechOutput;
sit=talk;
break;
case 'GameEngine.InputHandlerEvent':
//Launch Request
console.log('Game input handler');
sesh=event.session.attributes;
bstatus=event.request.events[0].name;
switch(bstatus){
case'complete':
sit=start;
p1=event.request.events[0].inputEvents[0].gadgetId;
console.log('p1 value is'+p1);
color=event.request.events[0].inputEvents[0].color;
nbcount=0;
console.log('the color before button push is '+color);
switch(color){
case'000000':
color='FFFF00';
cd='yellow';
break;
case'FFFF00':
color='FF0000';
cd='red';
break;
case'FF0000':
color='00FF00';
cd='green';
break;
case '00FF00':
color='0000FF';
cd='blue';
break;
case '0000FF':
color='00FFFF';
cd = 'turquois';
break;
case '00FFFF':
color='FFFF00';
cd='yellow';
break;
}
console.log('the color after button push is '+color);
speechOutput="<audio src='soundbank://soundlibrary/cartoon/amzn_sfx_boing_short_1x_01'/>Button has been pressed! The new color is " + cd;
textOutput=speechOutput;
break;
case'failed':
sit=start;
nbcount=sesh.nbcount;
nbcount=nbcount+1;
speechOutput='No button pressed. Warning '+ nbcount + '. You have 60 seconds to press a button.';
if(nbcount>1){
sit=talk;
ending=true;
speechOutput= 'No button pressed. Warning '+ nbcount+'The skill will now end. Thanks';
}
break;
}
sesh={'p1':p1,'color':color,'nbcount':nbcount};
console.log(sesh);
textOutput=speechOutput;
context.succeed(
generateResponse(
buildSpeechletResponse(textOutput, speechOutput, false,'Welcome',ism,ilg,bgimg,sit,sesh),
sesh
)
);
break;
case 'LaunchRequest':
//Launch Request
console.log('Actual LAUNCH REQUEST');
color="FFFF00";
sesh={'p1':null,'color':color,'nbcount':nbcount};
sit=start;
speechOutput = welcome;
textOutput=welcome;
context.succeed(
generateResponse(
buildSpeechletResponse(textOutput, speechOutput, false,'Welcome',ism,ilg,bgimg,sit,sesh),
sesh
)
);
break;
//*************************
};
Comments