Add: requestTodayBestRecord, updateTodayBestRecord

This commit is contained in:
2018-06-05 16:32:57 +09:00
parent 5f53360871
commit feb95d461b
6 changed files with 219 additions and 35 deletions
+33
View File
@@ -352,6 +352,39 @@ class DBConnectManager {
xhr.send("AppID=" + appID);
}
updateTodayBestRecord(maestroID, userID, appID, record) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/record/update_best_record.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(
"MaestroID=" + maestroID
+ "&UserID=" + userID
+ "&AppID=" + appID
+ "&BestRecord=" + record
);
}
requestTodayBestRecord(maestroID, userID, appID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/record/request_best_record.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
let replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null && replyJSON["BestRecord"] != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
};
xhr.send(
"MaestroID=" + maestroID
+ "&UserID=" + userID
+ "&AppID=" + appID
);
}
loadTempPlayerHistory(historyRecordManager) {
+11 -1
View File
@@ -8,7 +8,7 @@ class Result {
}
create() {
this.historyRecordManager = new HistoryRecordManager();
this.dbConnectManager = new DBConnectManager();
this.game.stage.backgroundColor = '#4d4d4d';
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
@@ -24,6 +24,8 @@ class Result {
// contents
this.printRecord();
this.uploadRecord();
this.makeStartButton();
let recordBoard = new RecordBoard();
@@ -63,7 +65,15 @@ class Result {
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5;
}
uploadRecord() {
this.dbConnectManager.updateTodayBestRecord(
sessionStorageManager.maestroID,
sessionStorageManager.playerUserID,
sessionStorageManager.playingAppID,
sessionStorageManager.record
);
}
makeStartButton() {