Fix: HistoryRecord, record -> score

This commit is contained in:
2018-05-17 09:01:50 +09:00
parent bdd8316fb5
commit 0f623e954c
4 changed files with 95 additions and 37 deletions
+58
View File
@@ -0,0 +1,58 @@
class DBConnectManager {
constructor() {
}
requestMyHistory(appName) {
}
requestRankingHour(appName) {
}
requestRankingDay(appName) {
}
requestRankingMonth(appName) {
}
requestTempMyHistory() {
this.historyRecordManager.clear();
this.historyRecordManager.push(new HistoryRecordData("05/10", 15460));
this.historyRecordManager.push(new HistoryRecordData("05/11", 3040));
this.historyRecordManager.push(new HistoryRecordData("05/12", 460));
this.historyRecordManager.push(new HistoryRecordData("05/13", 60));
this.historyRecordManager.push(new HistoryRecordData("05/14", 8));
this.printHistoryRecords();
}
requestTempRanking() {
let jsonRankingList = [
{ "UserID":"17", "Name":"강경모", "BestRecord":"4400" },
{ "UserID":"2", "Name":"강성태", "BestRecord":"3400" },
{ "UserID":"3", "Name":"김기덕", "BestRecord":"2400" },
{ "UserID":"4", "Name":"김남희", "BestRecord":"1400" },
{ "UserID":"5", "Name":"고봉순", "BestRecord":"900" },
{ "UserID":"6", "Name":"파르마", "BestRecord":"800" },
{ "UserID":"1", "Name":"박지상", "BestRecord":"700" },
{ "UserID":"8", "Name":"신현주", "BestRecord":"600" },
{ "UserID":"9", "Name":"꼬봉이", "BestRecord":"500" },
{ "UserID":"10", "Name":"거북이", "BestRecord":"400" },
{ "UserID":"11", "Name":"다람쥐", "BestRecord":"300" },
{ "UserID":"12", "Name":"사시미", "BestRecord":"200" },
{ "UserID":"13", "Name":"태권도", "BestRecord":"100" },
{ "UserID":"14", "Name":"합기도", "BestRecord":"40" },
{ "UserID":"15", "Name":"우습지", "BestRecord":"10" },
{ "UserID":"16", "Name":"하하하", "BestRecord":"4" },
];
return jsonRankingList;
}
}
+11 -11
View File
@@ -1,8 +1,8 @@
class HistoryRecordData { class HistoryRecord {
constructor(date, record) { constructor(date, score) {
this.date = date; this.date = date;
this.record = record; this.score = score;
} }
} }
@@ -14,8 +14,8 @@ class HistoryRecordManager {
this.clear(); this.clear();
} }
push(historyRecordData) { push(HistoryRecord) {
this.historyRecords.push(historyRecordData); this.historyRecords.push(HistoryRecord);
this.minValueOfRecord = this.minValueOfArray(); this.minValueOfRecord = this.minValueOfArray();
this.maxValueOfRecord = this.maxValueOfArray(); this.maxValueOfRecord = this.maxValueOfArray();
@@ -40,17 +40,17 @@ class HistoryRecordManager {
return this.historyRecords[index].date; return this.historyRecords[index].date;
} }
getRecordAt(index) { getScoreAt(index) {
return this.historyRecords[index].record; return this.historyRecords[index].score;
} }
minValueOfArray() { minValueOfArray() {
let numberArray = this.getRecordArray(this.historyRecords); let numberArray = this.getScoreArray(this.historyRecords);
return Math.min.apply(Math, numberArray); return Math.min.apply(Math, numberArray);
} }
maxValueOfArray() { maxValueOfArray() {
let numberArray = this.getRecordArray(this.historyRecords); let numberArray = this.getScoreArray(this.historyRecords);
return Math.max.apply(Math, numberArray); return Math.max.apply(Math, numberArray);
} }
@@ -70,10 +70,10 @@ class HistoryRecordManager {
return underMaxValue; return underMaxValue;
} }
getRecordArray() { getScoreArray() {
let numberArray = []; let numberArray = [];
for(let data of this.historyRecords) { for(let data of this.historyRecords) {
numberArray.push(data.record); numberArray.push(data.score);
} }
return numberArray; return numberArray;
} }
+13 -13
View File
@@ -20,11 +20,11 @@ class HistoryBoard {
loadHistoryRecords() { loadHistoryRecords() {
this.historyRecordManager.clear(); this.historyRecordManager.clear();
this.historyRecordManager.push(new HistoryRecordData("05/10", 15460)); this.historyRecordManager.push(new HistoryRecord("05/10", 15460));
this.historyRecordManager.push(new HistoryRecordData("05/11", 3040)); this.historyRecordManager.push(new HistoryRecord("05/11", 3040));
this.historyRecordManager.push(new HistoryRecordData("05/12", 460)); this.historyRecordManager.push(new HistoryRecord("05/12", 460));
this.historyRecordManager.push(new HistoryRecordData("05/13", 60)); this.historyRecordManager.push(new HistoryRecord("05/13", 60));
this.historyRecordManager.push(new HistoryRecordData("05/14", 8)); this.historyRecordManager.push(new HistoryRecord("05/14", 8));
this.printHistoryRecords(); this.printHistoryRecords();
} }
@@ -32,7 +32,7 @@ class HistoryBoard {
printHistoryRecords(historyRecords) { printHistoryRecords(historyRecords) {
for(let i = 0; i < this.historyRecordManager.count; i++) { for(let i = 0; i < this.historyRecordManager.count; i++) {
let data = this.historyRecordManager.getAt(i); let data = this.historyRecordManager.getAt(i);
this.printRecord(i, data.date, data.record); this.printRecord(i, data.date, data.score);
} }
// this.chartGraphics.lineStyle(3, 0xffd900, 1); // this.chartGraphics.lineStyle(3, 0xffd900, 1);
@@ -40,14 +40,14 @@ class HistoryBoard {
// this.chartGraphics.lineTo(game.world.width - 200, 0); // this.chartGraphics.lineTo(game.world.width - 200, 0);
} }
printRecord(index, date, record) { printRecord(index, date, score) {
if(sessionStorageManager.playingAppName.indexOf("typing") > -1) if(sessionStorageManager.playingAppName.indexOf("typing") > -1)
this.printMouseAppHistory(index, date, record); this.printMouseAppHistory(index, date, score);
else else
this.printMouseAppHistory(index, date, record); this.printMouseAppHistory(index, date, score);
} }
printTypingAppHistory(index, date, record) { printTypingAppHistory(index, date, score) {
let posX = 60; let posX = 60;
let posY = game.world.height / 2 + 90 + 30 * index; let posY = game.world.height / 2 + 90 + 30 * index;
@@ -62,14 +62,14 @@ class HistoryBoard {
.setTextBounds(0, 0, 60, 60) .setTextBounds(0, 0, 60, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let numberWithCommas = NumberUtil.numberWithCommas(record); let numberWithCommas = NumberUtil.numberWithCommas(score);
style.boundsAlignH = "right"; style.boundsAlignH = "right";
game.add.text(posX + 120, posY, numberWithCommas, style) game.add.text(posX + 120, posY, numberWithCommas, style)
.setTextBounds(0, 0, 80, 60) .setTextBounds(0, 0, 80, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
} }
printMouseAppHistory(index, date, record) { printMouseAppHistory(index, date, score) {
let posX = 60; let posX = 60;
let posY = game.world.height / 2 + 90 + 30 * index; let posY = game.world.height / 2 + 90 + 30 * index;
@@ -80,7 +80,7 @@ class HistoryBoard {
.setTextBounds(0, 0, 100, 60) .setTextBounds(0, 0, 100, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let numberWithCommas = NumberUtil.numberWithCommas(record); let numberWithCommas = NumberUtil.numberWithCommas(score);
style.boundsAlignH = "right"; style.boundsAlignH = "right";
game.add.text(posX + 80, posY, numberWithCommas, style) game.add.text(posX + 80, posY, numberWithCommas, style)
.setTextBounds(0, 0, 100, 60) .setTextBounds(0, 0, 100, 60)
+13 -13
View File
@@ -60,11 +60,11 @@ class Start {
loadHistoryRecords() { loadHistoryRecords() {
this.historyRecordManager.clear(); this.historyRecordManager.clear();
this.historyRecordManager.push(new HistoryRecordData("05/10", 15460)); this.historyRecordManager.push(new HistoryRecord("05/10", 15460));
this.historyRecordManager.push(new HistoryRecordData("05/11", 13040)); this.historyRecordManager.push(new HistoryRecord("05/11", 13040));
this.historyRecordManager.push(new HistoryRecordData("05/12", 16460)); this.historyRecordManager.push(new HistoryRecord("05/12", 16460));
this.historyRecordManager.push(new HistoryRecordData("05/13", 15060)); this.historyRecordManager.push(new HistoryRecord("05/13", 15060));
this.historyRecordManager.push(new HistoryRecordData("05/14", 19800)); this.historyRecordManager.push(new HistoryRecord("05/14", 19800));
} }
printHistoryRecords(historyRecords) { printHistoryRecords(historyRecords) {
@@ -73,7 +73,7 @@ class Start {
for(let i = 0; i < this.historyRecordManager.count; i++) { for(let i = 0; i < this.historyRecordManager.count; i++) {
let data = this.historyRecordManager.getAt(i); let data = this.historyRecordManager.getAt(i);
this.printRecord(i, data.date, data.record, underValue, upperValue); this.printRecord(i, data.date, data.score, underValue, upperValue);
} }
this.chartGraphics.lineStyle(3, 0xffd900, 1); this.chartGraphics.lineStyle(3, 0xffd900, 1);
@@ -81,7 +81,7 @@ class Start {
this.chartGraphics.lineTo(game.world.width - 200, 0); this.chartGraphics.lineTo(game.world.width - 200, 0);
} }
printRecord(index, date, record, min, max) { printRecord(index, date, score, min, max) {
const CHART_GAP_PX = 180; const CHART_GAP_PX = 180;
const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
@@ -90,15 +90,15 @@ class Start {
dateText.stroke = "#333"; dateText.stroke = "#333";
dateText.strokeThickness = 1; dateText.strokeThickness = 1;
let numberWithCommas = NumberUtil.numberWithCommas(record); let numberWithCommas = NumberUtil.numberWithCommas(score);
let recordText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 300, numberWithCommas, style); let scoreText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 300, numberWithCommas, style);
recordText.setTextBounds(0, 0, 100, 100); scoreText.setTextBounds(0, 0, 100, 100);
recordText.stroke = "#333"; scoreText.stroke = "#333";
recordText.strokeThickness = 1; scoreText.strokeThickness = 1;
this.chartGraphics.lineStyle(50, 0xdddddd, 1); this.chartGraphics.lineStyle(50, 0xdddddd, 1);
this.chartGraphics.moveTo(50 + index * CHART_GAP_PX, 0); this.chartGraphics.moveTo(50 + index * CHART_GAP_PX, 0);
this.chartGraphics.lineTo(50 + index * CHART_GAP_PX, -100 * ( (record - min) / (max - min) )); this.chartGraphics.lineTo(50 + index * CHART_GAP_PX, -100 * ( (score - min) / (max - min) ));
} }