diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js index 3580072..c7f1b93 100644 --- a/src/game/lib/db_connect_manager.js +++ b/src/game/lib/db_connect_manager.js @@ -346,9 +346,9 @@ DBConnectManager.prototype.requestHowToPlay = function(appID, onSucceededListene xhr.send("AppID=" + appID); } -DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID, appID, record) { +DBConnectManager.prototype.updateResultRecord = function(maestroID, playerID, appID, record) { var xhr = new XMLHttpRequest(); - xhr.open("POST", this.phpPath + "server/record/update_app_highest_record.php", true); + xhr.open("POST", this.phpPath + "server/record/update_result_record.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send( "MaestroID=" + maestroID diff --git a/src/game/result/history_board.js b/src/game/result/history_board.js index 4ffa046..41667a6 100644 --- a/src/game/result/history_board.js +++ b/src/game/result/history_board.js @@ -15,25 +15,31 @@ function HistoryBoard(type) { this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); - var today = new Date(); - var date = DateUtil.getYYYYMMDD(today); - this.dbConnectManager.requestPlayerHistory( - sessionStorageManager.getMaestroID(), - date, - (function(historyRecordManager) { - if(historyRecordManager.getCount() == 0) { - console.log("history board - no data"); - return; - } + setTimeout( + (function() { + var today = new Date(); + var date = DateUtil.getYYYYMMDD(today); + this.dbConnectManager.requestPlayerHistory( + sessionStorageManager.getMaestroID(), + date, + (function(historyRecordManager) { + if(historyRecordManager.getCount() == 0) { + console.log("history board - no data"); + return; + } - for(var i = 0; i < historyRecordManager.getCount(); i++) { - var data = historyRecordManager.getAt(i); - this.printRecord(i, data.date, data.bestRecord); + for(var i = 0; i < historyRecordManager.getCount(); i++) { + var data = historyRecordManager.getAt(i); + this.printRecord(i, data.date, data.bestRecord); - if(date == data.date) - this.todayBestRecord = data.bestRecord; - } - }).bind(this) + if(date == data.date) + this.todayBestRecord = data.bestRecord; + } + }).bind(this) + ); + }).bind(this), + + RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS ); } diff --git a/src/game/result/ranking_board.js b/src/game/result/ranking_board.js index 7149ab0..6385795 100644 --- a/src/game/result/ranking_board.js +++ b/src/game/result/ranking_board.js @@ -7,9 +7,15 @@ function RankingBoard(type) { this.makeMedalSprites(); this.dbConnectManager = new DBConnectManager(); - this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR); - this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY); - this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH); + setTimeout( + (function() { + this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR); + this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY); + this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH); + }).bind(this), + + RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS + ); } diff --git a/src/game/result/record_board.js b/src/game/result/record_board.js index 0a1c846..89afe25 100644 --- a/src/game/result/record_board.js +++ b/src/game/result/record_board.js @@ -50,4 +50,6 @@ RecordBoard.prototype.printSeperator = function() { RecordBoard.HEADER_BAR_HEIGHT_PX = 60; RecordBoard.TYPE_SAMPLE = "sample"; -RecordBoard.TYPE_DB = "db"; \ No newline at end of file +RecordBoard.TYPE_DB = "db"; + +RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS = 500; \ No newline at end of file diff --git a/src/game/result/result.js b/src/game/result/result.js index cd3ff22..8351e86 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -39,17 +39,20 @@ var Result = { // contents this.printRecord(); - this.uploadRecord(); + if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account + this.updateResultRecord(); + } this.makeRestartButton(); + if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE); this.announceBox = new AnnounceBox(50, 648); this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다."); } else { - var recordBoard = new RecordBoard(RecordBoard.TYPE_DB); this.printTodayBestRecord(); + var recordBoard = new RecordBoard(RecordBoard.TYPE_DB); } @@ -148,12 +151,8 @@ var Result = { } }, - uploadRecord: function() { - if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account - return; - } - - this.dbConnectManager.updateAppHighestRecord( + updateResultRecord: function() { + this.dbConnectManager.updateResultRecord( sessionStorageManager.getMaestroID(), sessionStorageManager.getPlayerID(), sessionStorageManager.getPlayingAppID(), diff --git a/src/web/server/record/update_app_highest_record.php b/src/web/server/record/update_result_record.php similarity index 92% rename from src/web/server/record/update_app_highest_record.php rename to src/web/server/record/update_result_record.php index 0e04617..0bb0bbe 100644 --- a/src/web/server/record/update_app_highest_record.php +++ b/src/web/server/record/update_result_record.php @@ -16,15 +16,15 @@ $prev_best_record_id = -1; $prev_best_record = 0; $prev_best_record_id = get_best_record($maestro_id, $app_id, $player_id); -// echo "id : ".$prev_best_record_id." ".$prev_best_record; +echo "id : ".$prev_best_record_id." ".$prev_best_record; if($prev_best_record_id === null || $prev_best_record_id < 0) { - // echo "insert"; + echo "insert"; insert_best_record($maestro_id, $app_id, $player_id, $record); } else { - // echo $record." ".$prev_best_record; + echo $record." ".$prev_best_record; if($record > $prev_best_record) { - // echo "update"; + echo "update"; update_best_record($prev_best_record_id, $record); } } @@ -56,7 +56,7 @@ function get_best_record($maestro_id, $app_id, $player_id) { SELECT BestRecordID, BestRecord FROM best_record WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW()) - /*AND HOUR(RecordDateTime) = HOUR(NOW())*/ + AND HOUR(RecordDateTime) = HOUR(NOW()) "; $stmt = $db_conn->prepare($query); $stmt->bind_param("iii", $maestro_id, $app_id, $player_id); @@ -91,7 +91,7 @@ function update_best_record($prev_best_record_id, $record) { UPDATE best_record SET BestRecord = ?, RecordDateTime = NOW() WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW()) - /* AND HOUR(RecordDateTime) = HOUR(NOW()) */ + AND HOUR(RecordDateTime) = HOUR(NOW()) "; $stmt = $db_conn->prepare($query); $stmt->bind_param('di', $record, $prev_best_record_id);