diff --git a/src/game/lib/chart.js b/src/game/lib/chart.js index 639bfb7..57abcaa 100644 --- a/src/game/lib/chart.js +++ b/src/game/lib/chart.js @@ -21,20 +21,44 @@ Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) { if(bestRecord === "") return; - this.drawText( - posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y, - // StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID) - RecordUtil.getRecordValueWithUnit(bestRecord, sessionStorageManager.getPlayingAppID()) - ); + var recordTextPosY = posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y; + var absRecordValue = Math.abs(bestRecord); + var recordWithUnit = RecordUtil.getRecordValueWithUnit(absRecordValue, sessionStorageManager.getPlayingAppID()); + if(bestRecord >= 0) { + this.drawText(posX, recordTextPosY, recordWithUnit); + } else { + // recordWithUnit = recordWithUnit + "/실격"; + recordWithUnit = "실격/" + recordWithUnit; + this.drawDisqualificationText(posX, recordTextPosY, recordWithUnit); + } // chart - this.chartGraphics.lineStyle(50, 0xdddddd, 1); + var chartColor = 0xffffff; + if(bestRecord >= 0) + chartColor = 0xdddddd; + else + chartColor = 0xffaaaa; + this.chartGraphics.lineStyle(50, chartColor, 1); this.chartGraphics.moveTo(posX, posY); - this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) )); + this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (absRecordValue - min) / (max - min) )); } Chart.prototype.drawText = function(posX, posY, text) { - var style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; + var style = { font: "22px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; + + var textObject = game.add.text( + posX, posY, + text, style + ); + textObject.anchor.set(0.5); + textObject.stroke = "#333"; + textObject.strokeThickness = 3; + + return textObject; +} + +Chart.prototype.drawDisqualificationText = function(posX, posY, text) { + var style = { font: "22px Arial", fill: "#faa", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; var textObject = game.add.text( posX, posY, diff --git a/src/game/lib/history_record_manager.js b/src/game/lib/history_record_manager.js index 1ccf7af..b6f5722 100644 --- a/src/game/lib/history_record_manager.js +++ b/src/game/lib/history_record_manager.js @@ -45,16 +45,31 @@ HistoryRecordManager.prototype.getBestRecordAt = function(index) { } HistoryRecordManager.prototype.minValueOfArray = function() { + var absArray = []; var numberArray = this.getBestRecordArray(this.historyRecords); - return Math.min.apply(Math, numberArray); + for(var i = 0; i < numberArray.length; i++) { + var data = numberArray[i]; + absArray.push(Math.abs(data)); + } + + // console.log(numberArray); + // console.log(absArray); + return Math.min.apply(Math, absArray); } HistoryRecordManager.prototype.maxValueOfArray = function() { + var absArray = []; var numberArray = this.getBestRecordArray(this.historyRecords); - return Math.max.apply(Math, numberArray); + for(var i = 0; i < numberArray.length; i++) { + var data = numberArray[i]; + absArray.push(Math.abs(data)); + } + + return Math.max.apply(Math, absArray); } HistoryRecordManager.prototype.underValueForGraph = function() { + 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/start/start.js b/src/game/start/start.js index 97ff6df..4026736 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -168,6 +168,8 @@ var Start = { var underValue = historyRecordManager.underValueForGraph(); var upperValue = historyRecordManager.upperValueForGraph(); + console.log("underValue : " + underValue); + console.log("upperValue : " + upperValue); var minValue = underValue - (upperValue - underValue) / 10; var maxValue = upperValue;// + (upperValue - underValue) / 10; @@ -178,12 +180,13 @@ var Start = { // break; var historyRecord = historyRecordManager.getAt(i); - this.chart.drawRecordGraph( - i, - historyRecord === undefined ? "-" : historyRecord.date, - historyRecord === undefined ? "" : historyRecord.bestRecord, - minValue, maxValue - ); + + var dateText = historyRecord === undefined ? "-" : historyRecord.date; + var record = historyRecord === undefined ? "" : historyRecord.bestRecord; + // console.log("record : " + record); + // console.log("minValue : " + minValue); + // console.log("maxValue : " + maxValue); + this.chart.drawRecordGraph(i, dateText, record, minValue, maxValue); } this.chart.printChartBaseLine();