Game Structure

Intro Screen
Required API Calls
Last updated

Last updated
export default class extends Phaser.State {
...
init() {
var data = { "envelop": null,
"page": "<YOUR GAME NAME>",
"time": null,
"eventType": "GameStarted",
"eventData": navigator.userAgent
};
fetch('https://dtml.org/Activity/Record/',
{ method: 'post',
credentials: 'same-origin',
body: JSON.stringify(data),
headers: {
'content-type': 'application/json'
}
}).catch(err => {
console.log('err', err)
});
}
...
}
recordUserProgress(word, isCorrect) {
var url = 'https://dtml.org/api/GameService/Reinforcement?value=';
var type = isCorrect ? "correct_word" : "wrong_word";
fetch(url + word+'&type='+type +'&source=<YOUR GAME NAME>',
{
credentials: 'same-origin',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(data => {
console.log(data);
})
.catch(err => {
console.log('err', err)
});
} callGameOverService(score, complexity) {
var url = ''https://dtml.org/Activity/RecordUserActivity?id=';
fetch(url + '<YOUR GAME NAME>'+'&score=' + score + '&complexity=' + complexity,
{
credentials: 'same-origin',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(data => {
console.log(data);
})
.catch(err => {
console.log('err', err)
});
}