diff --git a/src/game/lib/date_util.js b/src/game/lib/date_util.js index 39f571f..44bcece 100644 --- a/src/game/lib/date_util.js +++ b/src/game/lib/date_util.js @@ -1,7 +1,8 @@ class DateUtil { static getYYYYMMDD(date) { - return date.toISOString().slice(0,10); + // return date.toISOString().slice(0,10); + return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); } static getHHMMSS(date) { diff --git a/src/game/mouse/space_invaders/game.js b/src/game/mouse/space_invaders/game.js index 971ff7b..4148015 100644 --- a/src/game/mouse/space_invaders/game.js +++ b/src/game/mouse/space_invaders/game.js @@ -13,11 +13,11 @@ class Game { let scoreBoard = new ScoreBoard(); scoreManager.addOnChangeScoreListener( score => { - sessionStorageManager.score = score; + sessionStorageManager.record = score; scoreBoard.printScore(NumberUtil.numberWithCommas(score)); }); scoreManager.addOnChangeHighScoreListener( highScore => { - sessionStorageManager.highScore = highScore; + sessionStorageManager.bestRecord = highScore; screenBottom.printBottomLeftText("최고 기록 : " + NumberUtil.numberWithCommas(highScore)); }); diff --git a/src/game/result/history_board.js b/src/game/result/history_board.js index 4eb66fd..5e26087 100644 --- a/src/game/result/history_board.js +++ b/src/game/result/history_board.js @@ -23,17 +23,9 @@ class HistoryBoard { return; } - let maxIndex = historyRecordManager.count - 1; - if(maxIndex > 6) - maxIndex = 6; - for(let i = 0; i < historyRecordManager.count; i++) { - if(i > 6) - break; - - let data = historyRecordManager.getAt(maxIndex); + let data = historyRecordManager.getAt(i); this.printRecord(i, data.date, data.bestRecord); - maxIndex--; } } ); diff --git a/src/web/server/record/history_record.php b/src/web/server/record/history_record.php index a9dd41a..dbeb430 100644 --- a/src/web/server/record/history_record.php +++ b/src/web/server/record/history_record.php @@ -28,9 +28,9 @@ function get_history_record($app_id, $user_id, $date) { SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName FROM moty_best_record BR INNER JOIN moty_app AS AA - ON BR.UserID = ? AND DATE(BR.RecordDateTime) < DATE(?) AND BR.AppID = ? AND BR.AppID = AA.AppID + ON BR.UserID = ? AND DATE(BR.RecordDateTime) < ? AND BR.AppID = ? AND BR.AppID = AA.AppID GROUP BY DATE(BR.RecordDateTime) - ORDER BY BR.RecordDateTime ASC + ORDER BY BR.RecordDateTime DESC LIMIT 7 "; $stmt = $db_conn->prepare($query); diff --git a/src/web/server/record/ranking_record_day.php b/src/web/server/record/ranking_record_day.php index d2e00a4..230a6d9 100644 --- a/src/web/server/record/ranking_record_day.php +++ b/src/web/server/record/ranking_record_day.php @@ -5,14 +5,14 @@ include "./../lib/send_error_code.php"; $app_id = $_POST["AppID"]; $date = $_POST["Date"]; -// $time = $_POST["Time"]; +$time = $_POST["Time"]; include "./../setup/connect_db.php"; $replyJSON = get_ranking_record_day($date, $app_id); if($replyJSON.length === 0) { - send_error_message($replyJSON, "히스토리 기록 없음"); + send_error_message($replyJSON, "오늘의 랭킹 기록 없음"); $db_conn->close(); exit; } @@ -27,7 +27,7 @@ function get_ranking_record_day($date, $app_id) { $query = " SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore FROM moty_best_record BR, moty_user U - WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = DATE(?) AND AppID = ? + WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND AppID = ? GROUP BY BR.userID ORDER BY max(BR.BestRecord) DESC; "; diff --git a/src/web/server/record/ranking_record_hour.php b/src/web/server/record/ranking_record_hour.php index 62078b8..a33a378 100644 --- a/src/web/server/record/ranking_record_hour.php +++ b/src/web/server/record/ranking_record_hour.php @@ -12,7 +12,7 @@ include "./../setup/connect_db.php"; $replyJSON = get_ranking_record_hour($date, $time, $app_id); if($replyJSON.length === 0) { - send_error_message($replyJSON, "히스토리 기록 없음"); + send_error_message($replyJSON, "수업시간 랭킹 기록 없음"); $db_conn->close(); exit; } @@ -20,21 +20,19 @@ if($replyJSON.length === 0) { echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE); $db_conn->close(); - function get_ranking_record_hour($date, $time, $app_id) { global $db_conn; $query = " SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore FROM moty_best_record BR, moty_user U - WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = DATE(?) AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ? + WHERE BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ? GROUP BY BR.userID ORDER BY max(BR.BestRecord) DESC; "; $stmt = $db_conn->prepare($query); $stmt->bind_param('ssi', $date, $time, $app_id); $stmt->execute(); - $stmt->bind_result($userID, $name, $high_score); $ranking_record_array = array(); diff --git a/src/web/server/record/ranking_record_month.php b/src/web/server/record/ranking_record_month.php index db6c6a0..2a885be 100644 --- a/src/web/server/record/ranking_record_month.php +++ b/src/web/server/record/ranking_record_month.php @@ -12,7 +12,7 @@ include "./../setup/connect_db.php"; $replyJSON = get_ranking_record_month($date, $time, $app_id); if($replyJSON.length === 0) { - send_error_message($replyJSON, "히스토리 기록 없음"); + send_error_message($replyJSON, "이달의 랭킹 기록 없음"); $db_conn->close(); exit; } @@ -34,17 +34,16 @@ function get_ranking_record_month($date, $time, $app_id) { $stmt = $db_conn->prepare($query); $stmt->bind_param('si', $date, $app_id); $stmt->execute(); - $stmt->bind_result($userID, $name, $high_score); - $score_record_array = array(); + $ranking_record_array = array(); while($stmt->fetch()) { - $score_record['UserID'] = $userID; - $score_record['Name'] = $name; - $score_record['HighScore'] = $high_score; - array_push($score_record_array, $score_record); + $ranking_record['UserID'] = $userID; + $ranking_record['Name'] = $name; + $ranking_record['HighScore'] = $high_score; + array_push($ranking_record_array, $ranking_record); } - $return_array['rankingMonth'] = $score_record_array; + $return_array['rankingMonth'] = $ranking_record_array; return $return_array; } diff --git a/test/test_db_connect_manager.js b/test/test_db_connect_manager.js index b1b54ce..99bb427 100644 --- a/test/test_db_connect_manager.js +++ b/test/test_db_connect_manager.js @@ -36,12 +36,12 @@ QUnit.test( "Player history", function( assert ) { console.log(historyRecordManager); assert.equal(historyRecordManager.getAppNameAt(0), "korean_word"); - assert.equal(historyRecordManager.getDateAt(0), "2018-04-18"); - assert.equal(historyRecordManager.getBestRecordAt(0), 51.6102); + assert.equal(historyRecordManager.getDateAt(0), "2018-05-14"); + assert.equal(historyRecordManager.getBestRecordAt(0), 101.78); assert.equal(historyRecordManager.getAppNameAt(4), "korean_word"); - assert.equal(historyRecordManager.getDateAt(4), "2018-05-14"); - assert.equal(historyRecordManager.getBestRecordAt(4), 101.78); + assert.equal(historyRecordManager.getDateAt(4), "2018-04-18"); + assert.equal(historyRecordManager.getBestRecordAt(4), 51.6102); done(); } @@ -51,7 +51,6 @@ QUnit.test( "Player history", function( assert ) { QUnit.test( "Player ranking", function( assert ) { sessionStorageManager.playingAppID = 9; - // sessionStorageManager.playingAppName = "korean_word"; let date = "2018-05-16"; let time = "14:50:00";