Fix: show minus record for start

This commit is contained in:
2019-09-26 18:20:48 +09:00
parent 76481a4caa
commit 301a057099
3 changed files with 58 additions and 16 deletions
+32 -8
View File
@@ -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,
+17 -2
View File
@@ -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) ) )