diff --git a/src/game/lib/chart.js b/src/game/lib/chart.js index 57abcaa..4a31b10 100644 --- a/src/game/lib/chart.js +++ b/src/game/lib/chart.js @@ -22,8 +22,11 @@ Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) { return; var recordTextPosY = posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y; - var absRecordValue = Math.abs(bestRecord); + // var absRecordValue = Math.abs(bestRecord); + var absRecordValue = bestRecord < 0 ? -1 * bestRecord : bestRecord; + // var absRecordValue = Math.abs(Math.floor(bestRecord)); var recordWithUnit = RecordUtil.getRecordValueWithUnit(absRecordValue, sessionStorageManager.getPlayingAppID()); + if(bestRecord >= 0) { this.drawText(posX, recordTextPosY, recordWithUnit); } else { @@ -38,9 +41,14 @@ Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) { chartColor = 0xdddddd; else chartColor = 0xffaaaa; + if(max < absRecordValue) + max = absRecordValue * 1.1; this.chartGraphics.lineStyle(50, chartColor, 1); this.chartGraphics.moveTo(posX, posY); this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (absRecordValue - min) / (max - min) )); + console.log("absRecordValue : " + absRecordValue); + console.log("min : " + min); + console.log("max : " + max); } Chart.prototype.drawText = function(posX, posY, text) { diff --git a/src/game/lib/db_service.js b/src/game/lib/db_service.js index b0cd394..132ae33 100644 --- a/src/game/lib/db_service.js +++ b/src/game/lib/db_service.js @@ -361,20 +361,24 @@ DBService.prototype.parseJSONtoRankingRecord = function(type, jsonData) { return rankingRecordManager; var replyJSON = null; + var rankingMinusJSON = null; switch(type) { case DBConnectManager.TYPE_MY_RANKING_HOUR: case DBConnectManager.TYPE_ALL_RANKING_HOUR: replyJSON = jsonData.rankingHour; + rankingMinusJSON = jsonData.rankingMinusHour; break; case DBConnectManager.TYPE_MY_RANKING_DAY: case DBConnectManager.TYPE_ALL_RANKING_DAY: replyJSON = jsonData.rankingDay; + rankingMinusJSON = jsonData.rankingMinusDay; break; case DBConnectManager.TYPE_MY_RANKING_MONTH: case DBConnectManager.TYPE_ALL_RANKING_MONTH: replyJSON = jsonData.rankingMonth; + rankingMinusJSON = jsonData.rankingMinusMonth; break; } @@ -392,6 +396,24 @@ DBService.prototype.parseJSONtoRankingRecord = function(type, jsonData) { rankingRecordManager.push(record); } + if(rankingMinusJSON === null) + return rankingRecordManager; + + var countMinus = rankingMinusJSON.length; + for(var i = 0; i < countMinus; i++) { + if(rankingRecordManager.hasPlayerID(rankingMinusJSON[i]["PlayerID"])) + continue; + + var record = new RankingRecord( + // i + 1, + -1, + rankingMinusJSON[i]["PlayerID"], + rankingMinusJSON[i]["Name"], + rankingMinusJSON[i]["HighScore"] + ); + rankingRecordManager.push(record); + } + return rankingRecordManager; } diff --git a/src/game/lib/history_record_manager.js b/src/game/lib/history_record_manager.js index b6f5722..8c9efc7 100644 --- a/src/game/lib/history_record_manager.js +++ b/src/game/lib/history_record_manager.js @@ -69,7 +69,7 @@ HistoryRecordManager.prototype.maxValueOfArray = function() { } HistoryRecordManager.prototype.underValueForGraph = function() { - console.log("this.minValueOfRecord : " + this.minValueOfRecord); + // console.log("this.minValueOfRecord : " + this.minValueOfRecord); var minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord); var underMinValue = Math.floor( (this.minValueOfRecord / Math.pow(10, minNumberOfDigits - 2) ) ) diff --git a/src/game/lib/ranking_record_manager.js b/src/game/lib/ranking_record_manager.js index e2c797f..2c985f3 100644 --- a/src/game/lib/ranking_record_manager.js +++ b/src/game/lib/ranking_record_manager.js @@ -55,4 +55,14 @@ RankingRecordManager.prototype.getBestRecordAt = function(index) { return -1; return this.rankingRecords[index].bestRecord; +} + +RankingRecordManager.prototype.hasPlayerID = function(playerID) { + var count = this.rankingRecords.length; + for(var i = 0; i < count; i++) { + if(this.getPlayerIDAt(i) == playerID) + return true; + } + + return false; } \ No newline at end of file diff --git a/src/game/lib/text/history_text.js b/src/game/lib/text/history_text.js index 3dfb878..133c3fb 100644 --- a/src/game/lib/text/history_text.js +++ b/src/game/lib/text/history_text.js @@ -42,7 +42,18 @@ HistoryText.prototype.setContents = function(date, record) { this.reset(); this.textDate.text = DateUtil.printMonthDay(date); - this.textRecord.text = RecordUtil.getRecordValueWithUnit(record, sessionStorageManager.getPlayingAppID()); + + var recordValue = record >= 0 ? record : -1 * record; + var absRecordValue = RecordUtil.getRecordValueWithUnit( + recordValue, + sessionStorageManager.getPlayingAppID() + ); + if(record >= 0) { + this.textRecord.text = absRecordValue; + } else { + this.textRecord.text = "실격/" + absRecordValue; + this.textRecord.style.fill = "#ffaaaa"; + } }; diff --git a/src/game/lib/text/ranking_text.js b/src/game/lib/text/ranking_text.js index 740a6bd..437467f 100644 --- a/src/game/lib/text/ranking_text.js +++ b/src/game/lib/text/ranking_text.js @@ -103,7 +103,8 @@ RankingText.prototype.setTextRankingColor = function(text, ranking) { } text.fill = fillColor; text.stroke = strokeColor; - text.strokeThickness = 2; + text.strokeThickness = 6; + text.setShadow(2, 2, "#333333", 2, false, true); }; RankingText.prototype.setTopRankingTextColor = function(ranking) { @@ -131,19 +132,48 @@ RankingText.prototype.setMyRankingTextColor = function() { this.textRecord.strokeThickness = 2; }; +RankingText.prototype.setRankingMinusTextColor = function(ranking) { + // console.log(ranking); + if(ranking >= 0) + return; + + var fillColor = "#ddaaaa"; // yellowgreen + // var strokeColor = "#2e8b57"; // seagreen + this.textRanking.fill = fillColor; + // this.textRanking.stroke = strokeColor; + // this.textRanking.strokeThickness = 2; + this.textPlayerName.fill = fillColor; + // this.textPlayerName.stroke = strokeColor; + // this.textPlayerName.strokeThickness = 2; + this.textRecord.fill = fillColor; + // this.textRecord.stroke = strokeColor; + // this.textRecord.strokeThickness = 2; +}; + RankingText.prototype.setContents = function(playerID, ranking, playerName, record) { this.reset(); this.playerID = playerID; - this.textRanking.text = ranking + "등"; + if(record >= 0) + this.textRanking.text = ranking + "등"; + else + this.textRanking.text = "실격"; this.textPlayerName.text = playerName; this.setRecord(record, this.appID); - this.setMyRankingTextColor(); this.setTopRankingTextColor(ranking); + this.setRankingMinusTextColor(ranking); + this.setMyRankingTextColor(); }; RankingText.prototype.setRecord = function(record, appID) { - this.textRecord.text = RecordUtil.getRecordValueWithUnit(record, appID); + // this.textRecord.text = RecordUtil.getRecordValueWithUnit(record, appID); + + var recordValue = record >= 0 ? record : -1 * record; + var absRecordValue = RecordUtil.getRecordValueWithUnit( + recordValue, + sessionStorageManager.getPlayingAppID() + ); + this.textRecord.text = absRecordValue; }; diff --git a/src/game/ranking/ranking.js b/src/game/ranking/ranking.js index d721bf1..1aee435 100644 --- a/src/game/ranking/ranking.js +++ b/src/game/ranking/ranking.js @@ -413,10 +413,11 @@ var Ranking = { var record = []; // record[0] = jsonRankingList[i]['UserID']; record[0] = rankingRecordManager.getPlayerIDAt(i); // playerID - record[1] = i + 1; // ranking + // record[1] = i + 1; // ranking + record[1] = rankingRecordManager.getRankAt(i);; // ranking record[2] = rankingRecordManager.getPlayerNameAt(i); record[3] = rankingRecordManager.getBestRecordAt(i); - // console.log("record : " + record[0] + ", " + record[1] + ", " + record[2]); + // console.log("record : " + record[0] + ", " + record[1] + ", " + record[2] + ", " + record[3]); this.recordArray.push(record); } diff --git a/src/game/result/ranking_board.js b/src/game/result/ranking_board.js index f27876c..e0c4df4 100644 --- a/src/game/result/ranking_board.js +++ b/src/game/result/ranking_board.js @@ -70,7 +70,7 @@ RankingBoard.prototype.requestRanking = function(type) { RankingBoard.prototype.onReceiveRankingData = function(type, rankingRecordManager) { if(rankingRecordManager.getCount() == 0) { - console.log("ranking board - no data"); + // console.log("ranking board - no data"); return; } diff --git a/src/game/result/result.js b/src/game/result/result.js index 13017c0..690477e 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -104,7 +104,7 @@ Result.prototype.printRecord = function() { scoreText.style.fill = MainColor.THISTLE_STRING; var timeoverText = this.makeDefaultText(game.world.width / 2, 225); - timeoverText.text = "== 제한 시간 초과 (기록 저장 안됨) =="; + timeoverText.text = "== 제한 시간 초과 =="; timeoverText.fontSize = 50; timeoverText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); timeoverText.anchor.set(0.5); diff --git a/src/game/start/start.js b/src/game/start/start.js index 4026736..989d03f 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -63,7 +63,7 @@ var Start = { sessionStorageManager.getWritingID(), (function(replyJSON) { - console.log(replyJSON); + // console.log(replyJSON); var highestRecordData = replyJSON["highestRecordData"]; var highestRecord = highestRecordData["highestRecord"]; this.onReceiveAppHighestRecord(highestRecord); @@ -168,8 +168,8 @@ var Start = { var underValue = historyRecordManager.underValueForGraph(); var upperValue = historyRecordManager.upperValueForGraph(); - console.log("underValue : " + underValue); - console.log("upperValue : " + upperValue); + // console.log("underValue : " + underValue); + // console.log("upperValue : " + upperValue); var minValue = underValue - (upperValue - underValue) / 10; var maxValue = upperValue;// + (upperValue - underValue) / 10; diff --git a/src/web/php/db/typing_exam_collection.php b/src/web/php/db/typing_exam_collection.php index e59acda..f240cce 100644 --- a/src/web/php/db/typing_exam_collection.php +++ b/src/web/php/db/typing_exam_collection.php @@ -190,7 +190,7 @@ class TypingExamCollection extends DBMethodContainer $query = " SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore FROM typing_exam_record TER, player U - WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND HOUR(TER.RecordDateTime) = HOUR(?) AND TER.WritingID = ? + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND HOUR(TER.RecordDateTime) = HOUR(?) AND TER.WritingID = ? AND TER.Record >= 0 GROUP BY TER.playerID ORDER BY MAX(TER.Record) DESC; "; @@ -215,7 +215,7 @@ class TypingExamCollection extends DBMethodContainer $query = " SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore FROM typing_exam_record TER, player U - WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND TER.WritingID = ? + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND TER.WritingID = ? AND TER.Record >= 0 GROUP BY TER.playerID ORDER BY MAX(TER.Record) DESC; "; @@ -240,7 +240,7 @@ class TypingExamCollection extends DBMethodContainer $query = " SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore FROM typing_exam_record TER, player U - WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND TER.WritingID = ? + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND TER.WritingID = ? AND TER.Record >= 0 GROUP BY TER.playerID ORDER BY MAX(TER.Record) DESC; "; @@ -260,5 +260,80 @@ class TypingExamCollection extends DBMethodContainer return $rankingRecordArray; } + + function getRankingMinusRecordHour($maestroID, $writingID, $date, $time) { + $query = " + SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore + FROM typing_exam_record TER, player U + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND HOUR(TER.RecordDateTime) = HOUR(?) AND TER.WritingID = ? AND TER.Record < 0 + GROUP BY TER.playerID + ORDER BY MAX(TER.Record) ASC; + "; + $stmt = $this->mysqli->prepare($query); + $stmt->bind_param('issssi', $maestroID, $date, $date, $date, $time, $writingID); + $stmt->execute(); + $stmt->bind_result($playerID, $name, $highScore); + + $rankingRecordArray = array(); + while($stmt->fetch()) { + $rankingRecord['PlayerID'] = $playerID; + $rankingRecord['Name'] = $name; + $rankingRecord['HighScore'] = $highScore; + array_push($rankingRecordArray, $rankingRecord); + } + $stmt->close(); + + return $rankingRecordArray; + } + + function getRankingMinusRecordDay($maestroID, $writingID, $date) { + $query = " + SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore + FROM typing_exam_record TER, player U + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND DAYOFMONTH(TER.RecordDateTime) = DAYOFMONTH(?) AND TER.WritingID = ? AND TER.Record < 0 + GROUP BY TER.playerID + ORDER BY MAX(TER.Record) ASC; + "; + $stmt = $this->mysqli->prepare($query); + $stmt->bind_param('isssi', $maestroID, $date, $date, $date, $writingID); + $stmt->execute(); + $stmt->bind_result($playerID, $name, $highScore); + + $rankingRecordArray = array(); + while($stmt->fetch()) { + $rankingRecord['PlayerID'] = $playerID; + $rankingRecord['Name'] = $name; + $rankingRecord['HighScore'] = $highScore; + array_push($rankingRecordArray, $rankingRecord); + } + $stmt->close(); + + return $rankingRecordArray; + } + + function getRankingMinusRecordMonth($maestroID, $writingID, $date) { + $query = " + SELECT TER.playerID As PlayerID, U.Name AS Name, MAX(TER.Record) AS HighScore + FROM typing_exam_record TER, player U + WHERE TER.MaestroID = ? AND TER.playerID = U.playerID AND YEAR(TER.RecordDateTime) = YEAR(?) AND MONTH(TER.RecordDateTime) = MONTH(?) AND TER.WritingID = ? AND TER.Record < 0 + GROUP BY TER.playerID + ORDER BY MAX(TER.Record) ASC; + "; + $stmt = $this->mysqli->prepare($query); + $stmt->bind_param('issi', $maestroID, $date, $date, $writingID); + $stmt->execute(); + $stmt->bind_result($playerID, $name, $highScore); + + $rankingRecordArray = array(); + while($stmt->fetch()) { + $rankingRecord['PlayerID'] = $playerID; + $rankingRecord['Name'] = $name; + $rankingRecord['HighScore'] = $highScore; + array_push($rankingRecordArray, $rankingRecord); + } + $stmt->close(); + + return $rankingRecordArray; + } } ?> \ No newline at end of file diff --git a/src/web/php/record/get_typing_exam_ranking_record_day.php b/src/web/php/record/get_typing_exam_ranking_record_day.php index 9880ef6..e25dae7 100644 --- a/src/web/php/record/get_typing_exam_ranking_record_day.php +++ b/src/web/php/record/get_typing_exam_ranking_record_day.php @@ -28,6 +28,8 @@ $typingExam = new TypingExamCollection($dbConnector->getMysqli()); $rankingRecordArray = $typingExam->getRankingRecordDay($maestroID, $writingID, $date); $jsonBuilder->setData("rankingDay", $rankingRecordArray); +$rankingMinusRecordArray = $typingExam->getRankingMinusRecordDay($maestroID, $writingID, $date); +$jsonBuilder->setData("rankingMinusDay", $rankingMinusRecordArray); if ($rankingRecordArray === null) { $jsonBuilder->sendResultFail(); diff --git a/src/web/php/record/get_typing_exam_ranking_record_hour.php b/src/web/php/record/get_typing_exam_ranking_record_hour.php index c156213..418222f 100644 --- a/src/web/php/record/get_typing_exam_ranking_record_hour.php +++ b/src/web/php/record/get_typing_exam_ranking_record_hour.php @@ -28,6 +28,8 @@ $typingExam = new TypingExamCollection($dbConnector->getMysqli()); $rankingRecordArray = $typingExam->getRankingRecordHour($maestroID, $writingID, $date, $time); $jsonBuilder->setData("rankingHour", $rankingRecordArray); +$rankingMinusRecordArray = $typingExam->getRankingMinusRecordHour($maestroID, $writingID, $date, $time); +$jsonBuilder->setData("rankingMinusHour", $rankingMinusRecordArray); if ($rankingRecordArray === null) { $jsonBuilder->sendResultFail(); diff --git a/src/web/php/record/get_typing_exam_ranking_record_month.php b/src/web/php/record/get_typing_exam_ranking_record_month.php index a8b209d..3dd113d 100644 --- a/src/web/php/record/get_typing_exam_ranking_record_month.php +++ b/src/web/php/record/get_typing_exam_ranking_record_month.php @@ -28,6 +28,8 @@ $typingExam = new TypingExamCollection($dbConnector->getMysqli()); $rankingRecordArray = $typingExam->getRankingRecordMonth($maestroID, $writingID, $date); $jsonBuilder->setData("rankingMonth", $rankingRecordArray); +$rankingMinusRecordArray = $typingExam->getRankingMinusRecordMonth($maestroID, $writingID, $date); +$jsonBuilder->setData("rankingMinusMonth", $rankingMinusRecordArray); if ($rankingRecordArray === null) { $jsonBuilder->sendResultFail();