Add: license maestro password, score list

This commit is contained in:
2018-12-13 10:59:37 +09:00
parent be09fca8b2
commit 5186f21421
8 changed files with 358 additions and 65 deletions
+136 -59
View File
@@ -1,13 +1,34 @@
function Chart() {
function Chart(licenseDataManager) {
this.dbConnectManager = new DBConnectManager();
this.licenseDataManager = licenseDataManager;
this.chartGraphics = game.add.graphics(0, 0);
this.printChartTitle();
this.printChartBaseLine();
this.records = [];
for(var i = 0; i < 7; i++)
this.records.push(new ChartRecord(i));
this.recordTexts = [];
for(var i = 0; i < Chart.PAGE_MAX_RECORD_COUNT; i++)
this.recordTexts.push(new ChartRecordText(i));
this.scoreList = null;
this.loadScoreFromServer();
}
Chart.prototype.updateScoreList = function(jsonData) {
// console.log(jsonData);
var jsonScoreList = jsonData.scoreList;
this.scoreList = [];
for(var i = 0; i < jsonScoreList.length; i++) {
this.scoreList.push(
new ChartRecordData(
jsonScoreList[i].SubjectName,
jsonScoreList[i].Score,
jsonScoreList[i].ScoreDateTime
)
);
}
}
Chart.prototype.printChartTitle = function() {
@@ -30,43 +51,16 @@ Chart.prototype.printChartBaseLine = function() {
this.chartGraphics.lineStyle(1, 0x888888, 1);
this.chartGraphics.moveTo(
Chart.CHART_LINE_START_X,
ChartRecord.getPosY(i) + ChartRecord.RECORD_HEIGHT
ChartRecordText.getPosY(i) + ChartRecordText.RECORD_HEIGHT
);
this.chartGraphics.lineTo(
game.world.width - Chart.CHART_LINE_START_X,
ChartRecord.getPosY(i) + ChartRecord.RECORD_HEIGHT
ChartRecordText.getPosY(i) + ChartRecordText.RECORD_HEIGHT
);
}
*/
}
/*
Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) {
var reverseIndex = (Chart.CHART_COUNT - 1) - index;
var posX = Chart.CHART_LINE_START_X + Chart.CHART_GRAPH_OFFSET_X + reverseIndex * Chart.CHART_GAP_PX;
var posY = Chart.CHART_LINE_Y;
this.drawText(
posX, posY + Chart.CHART_DATE_OFFSET_Y,
date === "-" ? "-" : StringUtil.printMonthDay(date)
);
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())
);
// chart
this.chartGraphics.lineStyle(50, 0xdddddd, 1);
this.chartGraphics.moveTo(posX, posY);
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
}
*/
Chart.drawText = function(posX, posY, text, fontStyle) {
var textObject = game.add.text(
posX, posY,
@@ -79,18 +73,88 @@ Chart.drawText = function(posX, posY, text, fontStyle) {
return textObject;
}
Chart.prototype.printPage = function(pageNo) {
var startScoreListIndex = 0;
var endScoreListIndex = Chart.PAGE_MAX_RECORD_COUNT - 1;
for(var i = 0; i < Chart.PAGE_MAX_RECORD_COUNT; i++) {
var scoreListIndex = startScoreListIndex + i;
if(startScoreListIndex + i < this.scoreList.length)
this.printChartRecord(i, scoreListIndex);
else
this.printChartRecord(i, null);
}
}
Chart.prototype.printChartRecord = function(chartRecordIndex, scoreListIndex) {
// console.log(chartRecordIndex);
// console.log(this.recordTexts.length);
// console.log(this.scoreList);
if(scoreListIndex == null) {
this.recordTexts[chartRecordIndex].printDate("-");
this.recordTexts[chartRecordIndex].printScore("-");
this.recordTexts[chartRecordIndex].printGrade("-");
this.recordTexts[chartRecordIndex].printSubject("-");
} else {
this.recordTexts[chartRecordIndex].printDate(StringUtil.printMonthDay(this.scoreList[scoreListIndex].date));
var scoreValue = RecordUtil.getRecordValueWithUnit(this.scoreList[scoreListIndex].score, 101);
this.recordTexts[chartRecordIndex].printScore(scoreValue);
var gradeValue = "-";
var subjectData = this.licenseDataManager.getSubjectDataByName(this.scoreList[scoreListIndex].subject);
if(subjectData != null)
gradeValue = subjectData.getGrade(this.scoreList[scoreListIndex].score);
this.recordTexts[chartRecordIndex].printGrade(gradeValue);
this.recordTexts[chartRecordIndex].printSubject(this.scoreList[scoreListIndex].subject);
}
}
Chart.prototype.printContents = function() {
if(this.scoreList == null || this.scoreList.length == 0) {
for(var i = 0; i < this.recordTexts.length; i++) {
this.recordTexts[i].printDate("-");
this.recordTexts[i].printScore("-");
this.recordTexts[i].printGrade("-");
this.recordTexts[i].printSubject("-");
}
return;
}
if(isDebugMode()) {
for(var i = 0; i < this.records.length; i++) {
this.records[i].printDate("12월 10일");
this.records[i].printScore(360);
this.records[i].printGrade("B");
this.records[i].printSubject("ITQ 파워포인트");
for(var i = 0; i < this.recordTexts.length; i++) {
this.recordTexts[i].printDate("12월 10일");
this.recordTexts[i].printScore(360);
this.recordTexts[i].printGrade("B");
this.recordTexts[i].printSubject("ITQ 파워포인트");
}
}
}
Chart.CHART_COUNT = 7;
Chart.prototype.loadScoreFromServer = function() {
this.dbConnectManager.requestLicenseScore(
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
(function(replyJson) {
// console.log(replyJson);
this.updateScoreList(replyJson);
this.printPage(0);
}).bind(this),
(function(replyJson) {
console.log(replyJson);
this.updateScoreList(null);
})
);
}
Chart.CHART_LINE_START_X = 230;
Chart.CHART_LINE_Y = 370;
@@ -107,8 +171,21 @@ Chart.SCORE_POS_X = Chart.DATE_POS_X + 120;
Chart.GRADE_POS_X = Chart.DATE_POS_X + 200;
Chart.SUBJECT_POS_X = Chart.DATE_POS_X + 360;
Chart.PAGE_MAX_RECORD_COUNT = 7;
function ChartRecord(indexRow) {
function ChartRecordData(subject, score, date) {
this.subject = subject;
this.score = score;
this.date = date;
return this;
}
function ChartRecordText(indexRow) {
this.date = new DateData(indexRow);
this.score = new ScoreData(indexRow);
this.grade = new GradeData(indexRow);
@@ -118,23 +195,23 @@ function ChartRecord(indexRow) {
}
ChartRecord.prototype.printDate = function(date) {
ChartRecordText.prototype.printDate = function(date) {
this.date.text = date;
}
ChartRecord.prototype.printScore = function(score) {
this.score.text = RecordUtil.getRecordValueWithUnit(score, 101); //sessionStorageManager.getPlayingAppID());
ChartRecordText.prototype.printScore = function(score) {
this.score.text = score; //RecordUtil.getRecordValueWithUnit(score, 101); //sessionStorageManager.getPlayingAppID());
}
ChartRecord.prototype.printGrade = function(grade) {
ChartRecordText.prototype.printGrade = function(grade) {
this.grade.text = grade;
}
ChartRecord.prototype.printSubject = function(subject) {
ChartRecordText.prototype.printSubject = function(subject) {
this.subject.text = subject;
}
ChartRecord.getPosX = function(columnName) {
ChartRecordText.getPosX = function(columnName) {
var posX = Chart.CHART_LINE_START_X;
switch(columnName) {
case "date":
@@ -157,23 +234,23 @@ ChartRecord.getPosX = function(columnName) {
return posX;
}
ChartRecord.getPosY = function(rowIndex) {
ChartRecordText.getPosY = function(rowIndex) {
var offsetY = 30;
return Chart.CHART_LINE_Y + offsetY + ChartRecord.GAP_RECORD_Y * rowIndex;
return Chart.CHART_LINE_Y + offsetY + ChartRecordText.GAP_RECORD_Y * rowIndex;
}
ChartRecord.getDefaultFontStyle = function() {
ChartRecordText.getDefaultFontStyle = function() {
return { font: "26px Arial", fill: "#ffc", align: "center" };
}
ChartRecord.GAP_RECORD_Y = 40;
ChartRecord.RECORD_HEIGHT = 16;
ChartRecordText.GAP_RECORD_Y = 40;
ChartRecordText.RECORD_HEIGHT = 16;
function DateData(index) {
this.dateText = Chart.drawText(
ChartRecord.getPosX("date"), ChartRecord.getPosY(index),
"-", ChartRecord.getDefaultFontStyle()
ChartRecordText.getPosX("date"), ChartRecordText.getPosY(index),
"-", ChartRecordText.getDefaultFontStyle()
);
return this.dateText;
@@ -181,8 +258,8 @@ function DateData(index) {
function ScoreData(index) {
this.scoreText = Chart.drawText(
ChartRecord.getPosX("score"), ChartRecord.getPosY(index),
"-", ChartRecord.getDefaultFontStyle()
ChartRecordText.getPosX("score"), ChartRecordText.getPosY(index),
"-", ChartRecordText.getDefaultFontStyle()
);
return this.scoreText;
@@ -190,8 +267,8 @@ function ScoreData(index) {
function GradeData(index) {
this.gradeText = Chart.drawText(
ChartRecord.getPosX("grade"), ChartRecord.getPosY(index),
"-", ChartRecord.getDefaultFontStyle()
ChartRecordText.getPosX("grade"), ChartRecordText.getPosY(index),
"-", ChartRecordText.getDefaultFontStyle()
);
return this.gradeText;
@@ -199,8 +276,8 @@ function GradeData(index) {
function SubjectData(index) {
this.subjectText = Chart.drawText(
ChartRecord.getPosX("subject"), ChartRecord.getPosY(index),
"-", ChartRecord.getDefaultFontStyle()
ChartRecordText.getPosX("subject"), ChartRecordText.getPosY(index),
"-", ChartRecordText.getDefaultFontStyle()
);
return this.subjectText;