html/skins/standard/play.js in gamefic-sdk-1.5.0 vs html/skins/standard/play.js in gamefic-sdk-1.6.0
- old
+ new
@@ -1,11 +1,15 @@
$(function() {
+ console.log('starting play');
$('#gamefic_controls form').submit(function(event) {
+ $('#gamefic_controls').addClass('working');
event.preventDefault();
- Gamefic.update($('#gamefic_command').val());
+ Gamefic.receive($('#gamefic_command').val());
+ $('#gamefic_command').val('');
+ $('#gamefic_controls').removeClass('working');
});
- Gamefic.onStart(function(response) {
+ /*Gamefic.onStart(function(response) {
var prompt = response.prompt;
if (prompt == '>') {
prompt = 'What do you want to do?'
}
$('#gamefic_prompt').html(prompt);
@@ -16,11 +20,11 @@
$('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
}
$('#gamefic_controls').addClass('working');
});
Gamefic.onFinish(function(response) {
- if (!response.testing) {
+ if (!response.busy) {
$('#gamefic_controls').removeClass('working');
}
$('#gamefic_command').val('');
$('#gamefic_command').focus();
var outputElement = document.getElementById('gamefic_output');
@@ -60,9 +64,21 @@
$('#gamefic_output').on('click', 'a[rel="gamefic"]', function(event) {
event.preventDefault();
if (!$(this).hasClass('disabled')) {
Gamefic.update($(this).attr('data-command'));
}
+ });*/
+ Gamefic.onUpdate((state) => {
+ console.log('Doing the update with ' + state['output']);
+ console.log(JSON.stringify(state));
+ $('#gamefic_output').append(state['output']);
+ if (state.scene == 'Conclusion') {
+ $('#gamefic_console').addClass('concluded');
+ }
});
+ console.log('Starting Gamefic');
Gamefic.start();
- $('#gamefic_command').focus();
+ //console.log('Started!');
+ $('#gamefic_controls').removeClass('working');
+ //$('#gamefic_command').focus();
+ console.log('finished play');
});