From c7a5926b2159beea5f4812307ea2d690b4734a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 23 Oct 2018 23:41:20 +0900 Subject: [PATCH] Fix: remove old codes - best record --- src/game/global/global_variables.js | 13 -- src/game/lib/db_connect_manager.js | 54 ------- src/game/lib/screen_bottom_ui.js | 2 +- src/game/lib/session_storage_manager.js | 136 +----------------- src/game/menu/menu_typing_practice.js | 10 +- src/game/menu/menu_typing_test.js | 10 +- src/game/mouse/space_invaders/game.js | 10 +- src/game/result/result.js | 15 +- src/game/start/start.js | 19 +-- src/game/typing/practice/game.js | 4 +- src/game/typing/test/game.js | 6 +- src/game/typing/whac_a_mole/game.js | 8 +- .../menu_active_typing_practice_app_list.php | 8 +- .../app/menu_active_typing_test_app_list.php | 19 ++- src/web/server/record/request_best_record.php | 41 ------ src/web/server/record/update_best_record.php | 93 ------------ 16 files changed, 47 insertions(+), 401 deletions(-) delete mode 100644 src/web/server/record/request_best_record.php delete mode 100644 src/web/server/record/update_best_record.php diff --git a/src/game/global/global_variables.js b/src/game/global/global_variables.js index abe0397..a01f459 100644 --- a/src/game/global/global_variables.js +++ b/src/game/global/global_variables.js @@ -32,7 +32,6 @@ let sessionStorageManager = new SessionStorageManager(); console.log("playingAppName : " + sessionStorageManager.getPlayingAppName()); console.log("playingAppKoreanName : " + sessionStorageManager.getPlayingAppKoreanName()); console.log("record : " + sessionStorageManager.getRecord()); - // console.log("bestRecord : " + sessionStorageManager.getBestRecord()); console.log("appHighestRecord : " + sessionStorageManager.getAppHighestRecord()); } @@ -52,18 +51,6 @@ function goLogin() { location.href = "login.html"; } -/* -function isTypingGame() { - if(sessionStorageManager.getPlayingAppName() === null) - return false; - - if(sessionStorageManager.getPlayingAppName().indexOf("typing") < 0) - return false; - - return true; -} -*/ - function isTypingGameApp() { if(sessionStorageManager.getPlayingAppName() == null) return false; diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js index e66ef9d..3580072 100644 --- a/src/game/lib/db_connect_manager.js +++ b/src/game/lib/db_connect_manager.js @@ -205,27 +205,6 @@ DBConnectManager.prototype.parseJSONtoHistoryRecord = function(json) { } return historyRecordManager; - -/* - var startIndex = 0; - var endIndex = jsonRankingList.length; - - var recordArray = []; - for(var i = startIndex; i < endIndex; i++) { - var bestRecordRow = []; - var strDate = jsonRankingList[i]['Date']; - var dateArray = strDate.split("-"); - var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]); - bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일"; - bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']); - bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']); - // console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]); - - recordArray.push(bestRecordRow); - } - - return recordArray; -*/ } DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) { @@ -367,18 +346,6 @@ DBConnectManager.prototype.requestHowToPlay = function(appID, onSucceededListene xhr.send("AppID=" + appID); } -DBConnectManager.prototype.updateTodayBestRecord = function(maestroID, playerID, appID, record) { - var 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 - + "&PlayerID=" + playerID - + "&AppID=" + appID - + "&BestRecord=" + record - ); -} - DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID, appID, record) { var xhr = new XMLHttpRequest(); xhr.open("POST", this.phpPath + "server/record/update_app_highest_record.php", true); @@ -391,27 +358,6 @@ DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID ); } -DBConnectManager.prototype.requestTodayBestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) { - var 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) { - var replyJSON = JSON.parse(xhr.responseText); - - if(replyJSON != null && replyJSON["BestRecord"] != null) - onSucceededListener(replyJSON); - else - onFailedListener(replyJSON); - } - }; - xhr.send( - "MaestroID=" + maestroID - + "&PlayerID=" + playerID - + "&AppID=" + appID - ); -} - DBConnectManager.prototype.requestAppHighestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) { var xhr = new XMLHttpRequest(); xhr.open("POST", this.phpPath + "server/record/request_app_highest_record.php", true); diff --git a/src/game/lib/screen_bottom_ui.js b/src/game/lib/screen_bottom_ui.js index b8d9f48..dae1b6e 100644 --- a/src/game/lib/screen_bottom_ui.js +++ b/src/game/lib/screen_bottom_ui.js @@ -62,7 +62,7 @@ ScreenBottomUI.prototype.printText = function(textObject, text, align) { return textObject; } -ScreenBottomUI.prototype.printLeftTextWithBestRecord = function(bestRecord) { +ScreenBottomUI.prototype.printLeftTextWithAppHighestRecord = function(bestRecord) { var roundUpBestRecord = Math.round(bestRecord); var highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord); this.printLeftText("최고 기록 : " + highScoreWithCommas); diff --git a/src/game/lib/session_storage_manager.js b/src/game/lib/session_storage_manager.js index f7d7981..ebee888 100644 --- a/src/game/lib/session_storage_manager.js +++ b/src/game/lib/session_storage_manager.js @@ -83,15 +83,7 @@ SessionStorageManager.prototype.getRecord = function() { return Number(sessionStorage.getItem("record")); } -// best record -// SessionStorageManager.prototype.setBestRecord = function(value) { -// sessionStorage.setItem("bestRecord", value); -// } -// SessionStorageManager.prototype.getBestRecord = function() { -// return Number(sessionStorage.getItem("bestRecord")); -// } - -// best record +// app highest record SessionStorageManager.prototype.setAppHighestRecord = function(value) { sessionStorage.setItem("appHighestRecord", value); } @@ -100,11 +92,11 @@ SessionStorageManager.prototype.getAppHighestRecord = function() { } // best record -SessionStorageManager.prototype.setIsNewBestRecord = function(value) { - sessionStorage.setItem("isNewBestRecord", value); +SessionStorageManager.prototype.setIsNewAppHighestRecord = function(value) { + sessionStorage.setItem("isNewAppHighestRecord", value); } -SessionStorageManager.prototype.getIsNewBestRecord = function() { - return sessionStorage.getItem("isNewBestRecord"); +SessionStorageManager.prototype.getIsNewAppHighestRecord = function() { + return sessionStorage.getItem("isNewAppHighestRecord"); } SessionStorageManager.prototype.resetPlayingAppData = function() { @@ -112,121 +104,5 @@ SessionStorageManager.prototype.resetPlayingAppData = function() { this.removeItem("playingAppName"); this.removeItem("playingAppKoreanName"); this.removeItem("record"); - this.removeItem("bestRecord"); this.removeItem("appHighestRecord"); -} - - -/* -class SessionStorageManager { - - constructor() { - } - - clear() { - sessionStorage.clear(); - } - - removeItem(key) { - return sessionStorage.removeItem(key); - } - - // maestro ID - set maestroID(value) { - sessionStorage.setItem("maestroID", value); - } - get maestroID() { - return sessionStorage.getItem("maestroID"); - } - - // maestro account type - set maestroAccountType(value) { - sessionStorage.setItem("maestroAccountType", value); - } - get maestroAccountType() { - return sessionStorage.getItem("maestroAccountType"); - } - - // player name - set playerName(value) { - sessionStorage.setItem("playerName", value); - } - get playerName() { - return sessionStorage.getItem("playerName"); - } - - // player player ID - set playerID(value) { - sessionStorage.setItem("playerID", value); - } - get playerID() { - return sessionStorage.getItem("playerID"); - } - - // player account type - set playerAccountType(value) { - sessionStorage.setItem("playerAccountType", value); - } - get playerAccountType() { - return sessionStorage.getItem("playerAccountType"); - } - - // playing app id - set playingAppID(value) { - sessionStorage.setItem("playingAppID", value); - } - get playingAppID() { - return sessionStorage.getItem("playingAppID"); - } - - // playing app name - set playingAppName(value) { - sessionStorage.setItem("playingAppName", value); - } - get playingAppName() { - return sessionStorage.getItem("playingAppName"); - } - - // playing app korean name - set playingAppKoreanName(value) { - sessionStorage.setItem("playingAppKoreanName", value); - } - get playingAppKoreanName() { - return sessionStorage.getItem("playingAppKoreanName"); - } - - // record - set record(value) { - sessionStorage.setItem("record", value); - } - get record() { - return sessionStorage.getItem("record"); - } - - // best record - set bestRecord(value) { - sessionStorage.setItem("bestRecord", value); - } - get bestRecord() { - return sessionStorage.getItem("bestRecord"); - } - - // best record - set isNewBestRecord(value) { - sessionStorage.setItem("isNewBestRecord", value); - } - get isNewBestRecord() { - return sessionStorage.getItem("isNewBestRecord"); - } - - resetPlayingAppData() { - sessionStorage.playingAppID = null; - sessionStorage.playingAppName = null; - sessionStorage.playingAppKoreanName = null; - sessionStorage.record = null; - sessionStorage.bestRecord = null; - - } - -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/game/menu/menu_typing_practice.js b/src/game/menu/menu_typing_practice.js index 075546d..d61bab9 100644 --- a/src/game/menu/menu_typing_practice.js +++ b/src/game/menu/menu_typing_practice.js @@ -112,24 +112,24 @@ var MenuTypingPractice = { return false; }, - getBestRecord: function(jsonList, appID) { + getAppHighestRecord: function(jsonList, appID) { var count = jsonList.length; // Object.keys(jsonList).length; for(var i = 0; i < count; i++) { if(jsonList[i].AppID === appID) - return jsonList[i].BestRecord; + return jsonList[i].AppHighestRecord; } return 0; }, getIconImage: function(jsonList, appID) { - var bestRecord = this.getBestRecord(jsonList, appID); + var appHighestRecord = this.getAppHighestRecord(jsonList, appID); - if(bestRecord === 0) + if(appHighestRecord === 0) return "snail_shadow"; - var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_PRACTICE); + var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_PRACTICE); return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; }, diff --git a/src/game/menu/menu_typing_test.js b/src/game/menu/menu_typing_test.js index e72650d..ed5b7b6 100644 --- a/src/game/menu/menu_typing_test.js +++ b/src/game/menu/menu_typing_test.js @@ -114,24 +114,24 @@ var MenuTypingTest = { return false; }, - getBestRecord: function(jsonList, appID) { + getAppHighestRecord: function(jsonList, appID) { var count = jsonList.length; // Object.keys(jsonList).length; for(var i = 0; i < count; i++) { if(jsonList[i].AppID === appID) - return jsonList[i].BestRecord; + return jsonList[i].AppHighestRecord; } return 0; }, getIconImage: function(jsonList, appID) { - var bestRecord = this.getBestRecord(jsonList, appID); + var appHighestRecord = this.getAppHighestRecord(jsonList, appID); - if(bestRecord === 0) + if(appHighestRecord === 0) return "snail_shadow"; - var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_TEST); + var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_TEST); return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; }, diff --git a/src/game/mouse/space_invaders/game.js b/src/game/mouse/space_invaders/game.js index 3b1b2d9..3bd7b09 100644 --- a/src/game/mouse/space_invaders/game.js +++ b/src/game/mouse/space_invaders/game.js @@ -3,7 +3,7 @@ var Game = { create: function() { this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; - sessionStorageManager.setIsNewBestRecord(false); + sessionStorageManager.setIsNewAppHighestRecord(false); var experienceAppTimer = new ExperienceAppTimer(); experienceAppTimer.setTimeOverListener( @@ -30,10 +30,10 @@ var Game = { scoreBoard.printScore(NumberUtil.numberWithCommas(score)); }); scoreManager.addOnChangeHighScoreListener( function(highScore) { - console.log(highScore); - sessionStorageManager.setAppHighestRecord(highScore); + // console.log(highScore); + // sessionStorageManager.setAppHighestRecord(highScore); sessionStorageManager.setIsNewBestRecrd(true); - screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); + // screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); }); var heartGauge = new HeartGauge(heartManager); @@ -80,7 +80,7 @@ var Game = { // bottom ui var screenBottomUI = new ScreenBottomUI(); - screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); + screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); diff --git a/src/game/result/result.js b/src/game/result/result.js index 595431d..cd3ff22 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -55,7 +55,7 @@ var Result = { // bottom ui var screenBottomUI = new ScreenBottomUI(); - screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.getAppHighestRecord())); + screenBottomUI.printLeftTextWithAppHighestRecord(Math.floor(sessionStorageManager.getAppHighestRecord())); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); }, @@ -131,19 +131,13 @@ var Result = { bestRecordText.stroke = "#333"; bestRecordText.strokeThickness = 5; - // if(sessionStorageManager.getBestRecord() == 'undefined' || sessionStorageManager.getBestRecord() == null) - // sessionStorageManager.setBestRecord(0); - if(sessionStorageManager.getAppHighestRecord() == 'undefined' || sessionStorageManager.getAppHighestRecord() == null) sessionStorageManager.setAppHighestRecord(0); var todayBestRecord = 0; - // var flooredBestRecord = Math.floor(sessionStorageManager.getBestRecord()); var flooredBestRecord = Math.floor(sessionStorageManager.getAppHighestRecord()); var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord); - // if(sessionStorageManager.getRecord() >= sessionStorageManager.getBestRecord()) { - // sessionStorageManager.setBestRecord(sessionStorageManager.getRecord()); if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) { sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord()); @@ -159,13 +153,6 @@ var Result = { return; } - // this.dbConnectManager.updateTodayBestRecord( - // sessionStorageManager.getMaestroID(), - // sessionStorageManager.getPlayerID(), - // sessionStorageManager.getPlayingAppID(), - // sessionStorageManager.getRecord() - // ); - this.dbConnectManager.updateAppHighestRecord( sessionStorageManager.getMaestroID(), sessionStorageManager.getPlayerID(), diff --git a/src/game/start/start.js b/src/game/start/start.js index 6e87e64..dc8106c 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -54,20 +54,6 @@ var Start = { screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); - // this.dbConnectManager.requestTodayBestRecord( - // sessionStorageManager.getMaestroID(), - // sessionStorageManager.getPlayerID(), - // sessionStorageManager.getPlayingAppID(), - // (function(replyJSON) { - // sessionStorageManager.setBestRecord(Number(replyJSON["BestRecord"])); - // screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord()); - // }).bind(this), - // (function(replyJSON) { // no data - // sessionStorageManager.setBestRecord(0); - // screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord()); - // }).bind(this) - // ); - this.dbConnectManager.requestAppHighestRecord( sessionStorageManager.getMaestroID(), sessionStorageManager.getPlayerID(), @@ -75,15 +61,14 @@ var Start = { (function(replyJSON) { var appHighestRecord = replyJSON["AppHighestRecord"]; console.log("appHighestRecord : " + appHighestRecord); - // sessionStorageManager.setBestRecord(Number(appHighestRecord)); sessionStorageManager.setAppHighestRecord(Number(appHighestRecord)); - screenBottomUI.printLeftTextWithBestRecord(appHighestRecord); + screenBottomUI.printLeftTextWithAppHighestRecord(appHighestRecord); }).bind(this), (function(replyJSON) { // no data var appHighestRecord = replyJSON["AppHighestRecord"]; console.log("appHighestRecord : " + appHighestRecord); sessionStorageManager.setAppHighestRecord(0); - screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); + screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); }).bind(this) ); }, diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index 3dfffcc..b55fe9c 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -6,7 +6,7 @@ var TypingPractice = { this.isOnStage = false; this.initTypingData(); - sessionStorageManager.setIsNewBestRecord(false); + sessionStorageManager.setIsNewAppHighestRecord(false); var experienceAppTimer = new ExperienceAppTimer(); experienceAppTimer.setTimeOverListener( @@ -158,8 +158,6 @@ var TypingPractice = { goResult: function() { sessionStorageManager.setRecord(this.typingScore.score()); - // if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) - // sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord()); location.href = '../../web/client/result.html'; }, diff --git a/src/game/typing/test/game.js b/src/game/typing/test/game.js index b6c25fc..0b4f9c5 100644 --- a/src/game/typing/test/game.js +++ b/src/game/typing/test/game.js @@ -4,7 +4,7 @@ var TypingTest = { var self = this; this.initTypingData(); - sessionStorageManager.setIsNewBestRecord(false); + sessionStorageManager.setIsNewAppHighestRecord(false); var experienceAppTimer = new ExperienceAppTimer(); experienceAppTimer.setTimeOverListener( @@ -110,7 +110,7 @@ var TypingTest = { // bottom ui var screenBottomUI = new ScreenBottomUI(); - screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); + screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); @@ -173,8 +173,6 @@ var TypingTest = { goResult: function() { sessionStorageManager.setRecord(this.typingRecordTotal); - // if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) - // sessionStorageManager.setAppHighestRecord(sessionStorageManager.record); location.href = '../../web/client/result.html'; }, diff --git a/src/game/typing/whac_a_mole/game.js b/src/game/typing/whac_a_mole/game.js index 34ddb8d..be03d64 100644 --- a/src/game/typing/whac_a_mole/game.js +++ b/src/game/typing/whac_a_mole/game.js @@ -6,7 +6,7 @@ var WhacAMole = { this.isOnStage = false; this.initTypingData(); - sessionStorageManager.setIsNewBestRecord(false); + sessionStorageManager.setIsNewAppHighestRecord(false); var experienceAppTimer = new ExperienceAppTimer(); experienceAppTimer.setTimeOverListener( @@ -32,9 +32,9 @@ var WhacAMole = { this.scoreManager.addOnChangeHighScoreListener( (function(highScore) { console.log(highScore); - sessionStorageManager.setBestRecord(highScore); + // sessionStorageManager.setAppHighestRecord(highScore); sessionStorageManager.setIsNewBestRecrd(true); - this.screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); + // this.screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); }).bind(this) ); @@ -179,8 +179,6 @@ var WhacAMole = { goResult: function() { sessionStorageManager.setRecord(this.scoreManager.getScore()); - // if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) - // sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord()); location.href = '../../web/client/result.html'; }, diff --git a/src/web/server/app/menu_active_typing_practice_app_list.php b/src/web/server/app/menu_active_typing_practice_app_list.php index 8304df5..9e2e7eb 100644 --- a/src/web/server/app/menu_active_typing_practice_app_list.php +++ b/src/web/server/app/menu_active_typing_practice_app_list.php @@ -109,7 +109,7 @@ function get_high_score_list($maestro_id, $player_id, $appList) { $stmt = $db_conn->prepare($query); $stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id); $stmt->execute(); - $stmt->bind_result($best_record); + $stmt->bind_result($highest_record); $returnValue = $stmt->fetch(); $stmt->close(); @@ -120,10 +120,10 @@ function get_high_score_list($maestro_id, $player_id, $appList) { // $row_array['maestro_id'] = $maestro_id; // $row_array['player_id'] = $player_id; $row_array['AppID'] = $app_id_list; - if($best_record === NULL) - $row_array['BestRecord'] = 0; + if($highest_record === NULL) + $row_array['AppHighestRecord'] = 0; else - $row_array['BestRecord'] = $best_record; + $row_array['AppHighestRecord'] = $highest_record; array_push($return_array, $row_array); } diff --git a/src/web/server/app/menu_active_typing_test_app_list.php b/src/web/server/app/menu_active_typing_test_app_list.php index 905c061..84831b5 100644 --- a/src/web/server/app/menu_active_typing_test_app_list.php +++ b/src/web/server/app/menu_active_typing_test_app_list.php @@ -101,15 +101,20 @@ function get_high_score_list($maestro_id, $player_id, $appList) { $app_id_list = $appList[$i]['AppID']; $query = " - SELECT MAX(BR.BestRecord) + SELECT MAX(AHR.HighestRecord) FROM app AS A - INNER JOIN best_record AS BR - ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ? + INNER JOIN app_highest_record AS AHR + ON A.AppID = ? AND A.AppID = AHR.AppID AND AHR.MaestroID = ? AND AHR.PlayerID = ? ORDER BY A.AppID ASC"; + // SELECT MAX(BR.AppHighestRecord) + // FROM app AS A + // INNER JOIN best_record AS BR + // ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ? + // ORDER BY A.AppID ASC"; $stmt = $db_conn->prepare($query); $stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id); $stmt->execute(); - $stmt->bind_result($best_record); + $stmt->bind_result($highest_record); $returnValue = $stmt->fetch(); $stmt->close(); @@ -120,10 +125,10 @@ function get_high_score_list($maestro_id, $player_id, $appList) { // $row_array['maestro_id'] = $maestro_id; // $row_array['player_id'] = $player_id; $row_array['AppID'] = $app_id_list; - if($best_record === NULL) - $row_array['BestRecord'] = 0; + if($highest_record === NULL) + $row_array['AppHighestRecord'] = 0; else - $row_array['BestRecord'] = $best_record; + $row_array['AppHighestRecord'] = $highest_record; array_push($return_array, $row_array); } diff --git a/src/web/server/record/request_best_record.php b/src/web/server/record/request_best_record.php deleted file mode 100644 index 045f05d..0000000 --- a/src/web/server/record/request_best_record.php +++ /dev/null @@ -1,41 +0,0 @@ -close(); - exit; -} - -echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE); -$db_conn->close(); - - -function get_best_record($maestro_id, $app_id, $player_id) { - global $db_conn; - - $query = " - SELECT BestRecord - FROM best_record - WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW()) - "; - $stmt = $db_conn->prepare($query); - $stmt->bind_param("iii", $maestro_id, $app_id, $player_id); - $stmt->execute(); - $stmt->bind_result($best_record); - $stmt->fetch(); - $stmt->close(); - - return $best_record; -} - -?> \ No newline at end of file diff --git a/src/web/server/record/update_best_record.php b/src/web/server/record/update_best_record.php deleted file mode 100644 index 80e06f5..0000000 --- a/src/web/server/record/update_best_record.php +++ /dev/null @@ -1,93 +0,0 @@ - $prev_best_record) { - // echo "update"; - update_best_record($prev_best_record_id, $best_record); - } -} - -$app_highest_record = get_app_highest_record($maestro_id, $app_id, $player_id); -if($app_highest_record == null) { - insert_app_highest_record($maestro_id, $app_id, $player_id, $best_record); -} -else if($best_record > $app_highest_record) { - remove_app_highest_record($maestro_id, $app_id, $player_id); - insert_app_highest_record($maestro_id, $app_id, $player_id, $best_record); -} - -$db_conn->close(); - - -function get_best_record($maestro_id, $app_id, $player_id) { - global $db_conn; - global $prev_best_record_id, $prev_best_record; - - $query = " - SELECT BestRecordID, BestRecord - FROM best_record - WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW()) - /*AND HOUR(RecordDateTime) = HOUR(NOW())*/ - "; - $stmt = $db_conn->prepare($query); - $stmt->bind_param("iii", $maestro_id, $app_id, $player_id); - $stmt->execute(); - $stmt->bind_result($prev_best_record_id, $prev_best_record); - $stmt->fetch(); - $stmt->close(); - - $GLOBALS["prev_best_record_id"] = $prev_best_record_id; - $GLOBALS["prev_best_record"] = $prev_best_record; - - return $prev_best_record_id; -} - - -function insert_best_record($maestro_id, $app_id, $player_id, $best_record) { - global $db_conn; - - $query = " - INSERT INTO best_record (MaestroID, PlayerID, AppID, BestRecord, RecordDateTime) - VALUES (?, ?, ?, ?, NOW()); - "; - $stmt = $db_conn->prepare($query); - $stmt->bind_param('iiid', $maestro_id, $player_id, $app_id, $best_record); - $stmt->execute(); -} - -function update_best_record($prev_best_record_id, $best_record) { - global $db_conn; - - $query = " - UPDATE best_record - SET BestRecord = ?, RecordDateTime = NOW() - WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW()) - /* AND HOUR(RecordDateTime) = HOUR(NOW()) */ - "; - $stmt = $db_conn->prepare($query); - $stmt->bind_param('di', $best_record, $prev_best_record_id); - $stmt->execute(); -} - -?> \ No newline at end of file