Fix: change score -> record, bestRecord
This commit is contained in:
@@ -36,8 +36,8 @@ let sessionStorageManager = new SessionStorageManager();
|
||||
console.log("playerUserID : " + sessionStorageManager.playerUserID);
|
||||
console.log("playingAppID : " + sessionStorageManager.playingAppID);
|
||||
console.log("playingAppName : " + sessionStorageManager.playingAppName);
|
||||
console.log("score : " + sessionStorageManager.score);
|
||||
console.log("highscore : " + sessionStorageManager.highScore);
|
||||
console.log("record : " + sessionStorageManager.record);
|
||||
console.log("BestRecord : " + sessionStorageManager.bestRecord);
|
||||
}
|
||||
|
||||
function isTypingGame() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class HistoryRecord {
|
||||
|
||||
constructor(date, appName, score) {
|
||||
constructor(date, appName, bestRecord) {
|
||||
this.date = date;
|
||||
this.appName = appName;
|
||||
this.score = score;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ class HistoryRecordManager {
|
||||
return this.historyRecords[index].appName;
|
||||
}
|
||||
|
||||
getScoreAt(index) {
|
||||
return this.historyRecords[index].score;
|
||||
getBestRecordAt(index) {
|
||||
return this.historyRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
minValueOfArray() {
|
||||
let numberArray = this.getScoreArray(this.historyRecords);
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.min.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
maxValueOfArray() {
|
||||
let numberArray = this.getScoreArray(this.historyRecords);
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.max.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ class HistoryRecordManager {
|
||||
return underMaxValue;
|
||||
}
|
||||
|
||||
getScoreArray() {
|
||||
getBestRecordArray() {
|
||||
let numberArray = [];
|
||||
for(let data of this.historyRecords) {
|
||||
numberArray.push(data.score);
|
||||
numberArray.push(data.bestRecord);
|
||||
}
|
||||
return numberArray;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class NumberUtil {
|
||||
return Math.floor(Math.log(number) / Math.LN10 + 1); // bug : 1000 -> expected 4 but 3
|
||||
}
|
||||
|
||||
static getScoreText(value) {
|
||||
static getRecordText(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class RankingRecord {
|
||||
|
||||
constructor(rank, userID, userName, score) {
|
||||
constructor(rank, userID, userName, bestRecord) {
|
||||
this.rank = rank;
|
||||
this.userID = userID;
|
||||
this.userName = userName;
|
||||
this.score = score;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ class RankingRecordManager {
|
||||
return this.rankingRecords[index].userName;
|
||||
}
|
||||
|
||||
getScoreAt(index) {
|
||||
return this.rankingRecords[index].score;
|
||||
getBestRecordAt(index) {
|
||||
return this.rankingRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,20 +51,20 @@ class SessionStorageManager {
|
||||
return sessionStorage.getItem("playingAppName");
|
||||
}
|
||||
|
||||
// score
|
||||
set score(value) {
|
||||
sessionStorage.setItem("score", value);
|
||||
// record
|
||||
set record(value) {
|
||||
sessionStorage.setItem("record", value);
|
||||
}
|
||||
get score() {
|
||||
return sessionStorage.getItem("score");
|
||||
get record() {
|
||||
return sessionStorage.getItem("record");
|
||||
}
|
||||
|
||||
// score
|
||||
set highScore(value) {
|
||||
sessionStorage.setItem("highScore", value);
|
||||
// best record
|
||||
set bestRecord(value) {
|
||||
sessionStorage.setItem("bestRecord", value);
|
||||
}
|
||||
get highScore() {
|
||||
return sessionStorage.getItem("highScore");
|
||||
get bestRecord() {
|
||||
return sessionStorage.getItem("bestRecord");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,12 +5,12 @@ class StringUtil {
|
||||
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
|
||||
}
|
||||
|
||||
static getScoreTextWithoutUnit(value) {
|
||||
static getRecordTextWithoutUnit(value) {
|
||||
let number = Math.floor(value);
|
||||
return NumberUtil.numberWithCommas(number);
|
||||
}
|
||||
|
||||
static getScoreTextWithUnit(value) {
|
||||
static getRecordTextWithUnit(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class HistoryBoard {
|
||||
break;
|
||||
|
||||
let data = historyRecordManager.getAt(maxIndex);
|
||||
this.printRecord(i, data.date, data.score);
|
||||
this.printRecord(i, data.date, data.bestRecord);
|
||||
maxIndex--;
|
||||
}
|
||||
}
|
||||
@@ -40,14 +40,14 @@ class HistoryBoard {
|
||||
}
|
||||
|
||||
|
||||
printRecord(index, date, score) {
|
||||
printRecord(index, date, bestRecord) {
|
||||
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
||||
this.printMouseAppHistory(index, date, score);
|
||||
this.printMouseAppHistory(index, date, bestRecord);
|
||||
else
|
||||
this.printTypingAppHistory(index, date, appName, score);
|
||||
this.printTypingAppHistory(index, date, appName, bestRecord);
|
||||
}
|
||||
|
||||
printMouseAppHistory(index, date, score) {
|
||||
printMouseAppHistory(index, date, bestRecord) {
|
||||
let posX = 60;
|
||||
let posY = game.world.height / 2 + 90 + 30 * index;
|
||||
|
||||
@@ -59,12 +59,12 @@ class HistoryBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
style.boundsAlignH = "right";
|
||||
game.add.text(posX + 80, posY, StringUtil.getScoreTextWithoutUnit(score), style)
|
||||
game.add.text(posX + 80, posY, StringUtil.getRecordTextWithoutUnit(bestRecord), style)
|
||||
.setTextBounds(0, 0, 100, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printTypingAppHistory(index, date, appName, score) {
|
||||
printTypingAppHistory(index, date, appName, bestRecord) {
|
||||
let posX = 60;
|
||||
let posY = game.world.height / 2 + 90 + 30 * index;
|
||||
|
||||
@@ -80,7 +80,7 @@ class HistoryBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
style.boundsAlignH = "right";
|
||||
game.add.text(posX + 120, posY, StringUtil.getScoreTextWithoutUnit(score), style)
|
||||
game.add.text(posX + 120, posY, StringUtil.getRecordTextWithoutUnit(bestRecord), style)
|
||||
.setTextBounds(0, 0, 80, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ class RankingBoard {
|
||||
.setTextBounds(0, 0, 60, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
// score
|
||||
let score = StringUtil.getScoreTextWithoutUnit(data.score);
|
||||
// bestRecord
|
||||
let bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
|
||||
style.boundsAlignH = "right";
|
||||
game.add.text(this.getPosX(type) + 120, this.getPosY(index), score, style)
|
||||
game.add.text(this.getPosX(type) + 120, this.getPosY(index), bestRecord, style)
|
||||
.setTextBounds(0, 0, 80, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
+14
-10
@@ -23,7 +23,7 @@ class Result {
|
||||
|
||||
|
||||
// contents
|
||||
this.printScore();
|
||||
this.printRecord();
|
||||
this.makeStartButton();
|
||||
|
||||
let recordBoard = new RecordBoard();
|
||||
@@ -38,28 +38,32 @@ class Result {
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
}
|
||||
|
||||
printScore() {
|
||||
printRecord() {
|
||||
const style = { font: "64px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
game.add.text(0, 0, "결과", style)
|
||||
.setTextBounds(0, 0, game.world.width, 100)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
let posY = 120;
|
||||
let score = NumberUtil.numberWithCommas(sessionStorageManager.score);
|
||||
console.log(score);
|
||||
if(sessionStorageManager.record === null)
|
||||
sessionStorageManager.record = 0;
|
||||
let record = NumberUtil.numberWithCommas(sessionStorageManager.record);
|
||||
console.log(record);
|
||||
style.font = "bold 80px Arial";
|
||||
game.add.text(0, 0, score, style)
|
||||
game.add.text(0, 0, record, style)
|
||||
.setTextBounds(0, posY, game.world.width, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
let highScore = NumberUtil.numberWithCommas(sessionStorageManager.highScore);
|
||||
console.log(highScore);
|
||||
if(sessionStorageManager.bestRecord === null)
|
||||
sessionStorageManager.bestRecord = 0;
|
||||
let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.bestRecord);
|
||||
console.log(bestRecord);
|
||||
style.font = "32px Arial";
|
||||
let highScoreText = game.add.text(0, 0, "오늘 최고 기록 : " + highScore, style)
|
||||
let bestRecordText = game.add.text(0, 0, "오늘 최고 기록 : " + bestRecord, style)
|
||||
.setTextBounds(0, posY + 80, game.world.width, 40);
|
||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
highScoreText.stroke = "#333";
|
||||
highScoreText.strokeThickness = 5;
|
||||
bestRecordText.stroke = "#333";
|
||||
bestRecordText.strokeThickness = 5;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class Start {
|
||||
break;
|
||||
|
||||
let data = historyRecordManager.getAt(i);
|
||||
this.drawRecordGraph(i, data.date, data.score, minValue, maxValue);
|
||||
this.drawRecordGraph(i, data.date, data.bestRecord, minValue, maxValue);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -84,7 +84,7 @@ class Start {
|
||||
this.chartGraphics.lineTo(game.world.width - 200, 0);
|
||||
}
|
||||
|
||||
drawRecordGraph(index, date, score, min, max) {
|
||||
drawRecordGraph(index, date, bestRecord, min, max) {
|
||||
const CHART_GAP_PX = 120;
|
||||
const CHART_HEIGHT = 120;
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
@@ -97,17 +97,17 @@ class Start {
|
||||
dateText.stroke = "#333";
|
||||
dateText.strokeThickness = 1;
|
||||
|
||||
let scoreText = game.add.text(
|
||||
let bestRecordText = game.add.text(
|
||||
100 + index * CHART_GAP_PX, game.world.height - 300,
|
||||
StringUtil.getScoreTextWithUnit(score), style
|
||||
StringUtil.getRecordTextWithUnit(bestRecord), style
|
||||
);
|
||||
scoreText.setTextBounds(0, 0, 100, 100);
|
||||
scoreText.stroke = "#333";
|
||||
scoreText.strokeThickness = 1;
|
||||
bestRecordText.setTextBounds(0, 0, 100, 100);
|
||||
bestRecordText.stroke = "#333";
|
||||
bestRecordText.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, -1 * CHART_HEIGHT * ( (score - min) / (max - min) ));
|
||||
this.chartGraphics.lineTo(50 + index * CHART_GAP_PX, -1 * CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
||||
}
|
||||
|
||||
startStage() {
|
||||
|
||||
@@ -37,11 +37,11 @@ QUnit.test( "Player history", function( assert ) {
|
||||
|
||||
assert.equal(historyRecordManager.getAppNameAt(0), "korean_word");
|
||||
assert.equal(historyRecordManager.getDateAt(0), "2018-04-18");
|
||||
assert.equal(historyRecordManager.getScoreAt(0), 51.6102);
|
||||
assert.equal(historyRecordManager.getBestRecordAt(0), 51.6102);
|
||||
|
||||
assert.equal(historyRecordManager.getAppNameAt(4), "korean_word");
|
||||
assert.equal(historyRecordManager.getDateAt(4), "2018-05-14");
|
||||
assert.equal(historyRecordManager.getScoreAt(4), 101.78);
|
||||
assert.equal(historyRecordManager.getBestRecordAt(4), 101.78);
|
||||
|
||||
done();
|
||||
}
|
||||
@@ -64,12 +64,12 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
assert.equal(rankingRecordManager.getRankAt(0), 1, "hour");
|
||||
assert.equal(rankingRecordManager.getScoreAt(0), 302.921, "hour");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(0), 302.921, "hour");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(0), 5, "hour");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(0), "김지유", "hour");
|
||||
|
||||
assert.equal(rankingRecordManager.getRankAt(5), 6, "hour");
|
||||
assert.equal(rankingRecordManager.getScoreAt(5), 128.436, "hour");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(5), 128.436, "hour");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(5), 22, "hour");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(5), "모윤건", "hour");
|
||||
|
||||
@@ -85,12 +85,12 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
assert.equal(rankingRecordManager.getRankAt(0), 1, "day");
|
||||
assert.equal(rankingRecordManager.getScoreAt(0), 313.304, "day");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(0), 313.304, "day");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(0), 19, "day");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(0), "오지운", "day");
|
||||
|
||||
assert.equal(rankingRecordManager.getRankAt(17), 18, "day");
|
||||
assert.equal(rankingRecordManager.getScoreAt(17), 65.337, "day");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(17), 65.337, "day");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(17), 20, "day");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(17), "김민성", "day");
|
||||
|
||||
@@ -106,12 +106,12 @@ QUnit.test( "Player ranking", function( assert ) {
|
||||
time,
|
||||
(type, rankingRecordManager) => {
|
||||
assert.equal(rankingRecordManager.getRankAt(0), 1, "month");
|
||||
assert.equal(rankingRecordManager.getScoreAt(0), 617.231, "month");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(0), 617.231, "month");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(0), 50, "month");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(0), "강민준", "month");
|
||||
|
||||
assert.equal(rankingRecordManager.getRankAt(17), 18, "month");
|
||||
assert.equal(rankingRecordManager.getScoreAt(17), 216.279, "month");
|
||||
assert.equal(rankingRecordManager.getBestRecordAt(17), 216.279, "month");
|
||||
assert.equal(rankingRecordManager.getUserIDAt(17), 9, "month");
|
||||
assert.equal(rankingRecordManager.getUserNameAt(17), "신예성", "month");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user