From 0f623e954cb4fd86481cd73fb271667aa155198c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 17 May 2018 09:01:50 +0900 Subject: [PATCH] Fix: HistoryRecord, record -> score --- src/game/lib/db_connect_manager.js | 58 ++++++++++++++++++++++++++ src/game/lib/history_record_manager.js | 22 +++++----- src/game/result/history_board.js | 26 ++++++------ src/game/start/start.js | 26 ++++++------ 4 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 src/game/lib/db_connect_manager.js diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js new file mode 100644 index 0000000..5498906 --- /dev/null +++ b/src/game/lib/db_connect_manager.js @@ -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; + } + +} \ No newline at end of file diff --git a/src/game/lib/history_record_manager.js b/src/game/lib/history_record_manager.js index 371f383..19125cf 100644 --- a/src/game/lib/history_record_manager.js +++ b/src/game/lib/history_record_manager.js @@ -1,8 +1,8 @@ -class HistoryRecordData { +class HistoryRecord { - constructor(date, record) { + constructor(date, score) { this.date = date; - this.record = record; + this.score = score; } } @@ -14,8 +14,8 @@ class HistoryRecordManager { this.clear(); } - push(historyRecordData) { - this.historyRecords.push(historyRecordData); + push(HistoryRecord) { + this.historyRecords.push(HistoryRecord); this.minValueOfRecord = this.minValueOfArray(); this.maxValueOfRecord = this.maxValueOfArray(); @@ -40,17 +40,17 @@ class HistoryRecordManager { return this.historyRecords[index].date; } - getRecordAt(index) { - return this.historyRecords[index].record; + getScoreAt(index) { + return this.historyRecords[index].score; } minValueOfArray() { - let numberArray = this.getRecordArray(this.historyRecords); + let numberArray = this.getScoreArray(this.historyRecords); return Math.min.apply(Math, numberArray); } maxValueOfArray() { - let numberArray = this.getRecordArray(this.historyRecords); + let numberArray = this.getScoreArray(this.historyRecords); return Math.max.apply(Math, numberArray); } @@ -70,10 +70,10 @@ class HistoryRecordManager { return underMaxValue; } - getRecordArray() { + getScoreArray() { let numberArray = []; for(let data of this.historyRecords) { - numberArray.push(data.record); + numberArray.push(data.score); } return numberArray; } diff --git a/src/game/result/history_board.js b/src/game/result/history_board.js index 0fdbfe6..ff80e1a 100644 --- a/src/game/result/history_board.js +++ b/src/game/result/history_board.js @@ -20,11 +20,11 @@ class HistoryBoard { loadHistoryRecords() { 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.historyRecordManager.push(new HistoryRecord("05/10", 15460)); + this.historyRecordManager.push(new HistoryRecord("05/11", 3040)); + this.historyRecordManager.push(new HistoryRecord("05/12", 460)); + this.historyRecordManager.push(new HistoryRecord("05/13", 60)); + this.historyRecordManager.push(new HistoryRecord("05/14", 8)); this.printHistoryRecords(); } @@ -32,7 +32,7 @@ class HistoryBoard { printHistoryRecords(historyRecords) { for(let i = 0; i < this.historyRecordManager.count; 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); @@ -40,14 +40,14 @@ class HistoryBoard { // this.chartGraphics.lineTo(game.world.width - 200, 0); } - printRecord(index, date, record) { + printRecord(index, date, score) { if(sessionStorageManager.playingAppName.indexOf("typing") > -1) - this.printMouseAppHistory(index, date, record); + this.printMouseAppHistory(index, date, score); else - this.printMouseAppHistory(index, date, record); + this.printMouseAppHistory(index, date, score); } - printTypingAppHistory(index, date, record) { + printTypingAppHistory(index, date, score) { let posX = 60; let posY = game.world.height / 2 + 90 + 30 * index; @@ -62,14 +62,14 @@ class HistoryBoard { .setTextBounds(0, 0, 60, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); - let numberWithCommas = NumberUtil.numberWithCommas(record); + let numberWithCommas = NumberUtil.numberWithCommas(score); style.boundsAlignH = "right"; game.add.text(posX + 120, posY, numberWithCommas, style) .setTextBounds(0, 0, 80, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); } - printMouseAppHistory(index, date, record) { + printMouseAppHistory(index, date, score) { let posX = 60; let posY = game.world.height / 2 + 90 + 30 * index; @@ -80,7 +80,7 @@ class HistoryBoard { .setTextBounds(0, 0, 100, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); - let numberWithCommas = NumberUtil.numberWithCommas(record); + let numberWithCommas = NumberUtil.numberWithCommas(score); style.boundsAlignH = "right"; game.add.text(posX + 80, posY, numberWithCommas, style) .setTextBounds(0, 0, 100, 60) diff --git a/src/game/start/start.js b/src/game/start/start.js index eeb0230..ad3bc64 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -60,11 +60,11 @@ class Start { loadHistoryRecords() { this.historyRecordManager.clear(); - this.historyRecordManager.push(new HistoryRecordData("05/10", 15460)); - this.historyRecordManager.push(new HistoryRecordData("05/11", 13040)); - this.historyRecordManager.push(new HistoryRecordData("05/12", 16460)); - this.historyRecordManager.push(new HistoryRecordData("05/13", 15060)); - this.historyRecordManager.push(new HistoryRecordData("05/14", 19800)); + this.historyRecordManager.push(new HistoryRecord("05/10", 15460)); + this.historyRecordManager.push(new HistoryRecord("05/11", 13040)); + this.historyRecordManager.push(new HistoryRecord("05/12", 16460)); + this.historyRecordManager.push(new HistoryRecord("05/13", 15060)); + this.historyRecordManager.push(new HistoryRecord("05/14", 19800)); } printHistoryRecords(historyRecords) { @@ -73,7 +73,7 @@ class Start { for(let i = 0; i < this.historyRecordManager.count; 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); @@ -81,7 +81,7 @@ class Start { 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 style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; @@ -90,15 +90,15 @@ class Start { dateText.stroke = "#333"; dateText.strokeThickness = 1; - let numberWithCommas = NumberUtil.numberWithCommas(record); - let recordText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 300, numberWithCommas, style); - recordText.setTextBounds(0, 0, 100, 100); - recordText.stroke = "#333"; - recordText.strokeThickness = 1; + let numberWithCommas = NumberUtil.numberWithCommas(score); + let scoreText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 300, numberWithCommas, style); + scoreText.setTextBounds(0, 0, 100, 100); + scoreText.stroke = "#333"; + scoreText.strokeThickness = 1; this.chartGraphics.lineStyle(50, 0xdddddd, 1); 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) )); }