Add: LicenseDataManager

This commit is contained in:
2018-12-12 00:01:40 +09:00
parent 0733a79630
commit 750887d5d1
4 changed files with 152 additions and 34 deletions
+30 -19
View File
@@ -1,5 +1,6 @@
function InputScore(chart) {
this.chart = chart;
this.licenseDataManager = new LicenseDataManager();
this.initVariables();
@@ -31,8 +32,8 @@ function InputScore(chart) {
var subjectTextSetting = this.makeInputTextSetting(280, "과목 입력");
this.subjectText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting);
this.subjectText.setText(this.subject);
this.subjectFullnameText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting);
this.setSubjectFullname(this.subjectFullname);
var titleTextStyle = { font: "36px Arial", fill: "#fff", align: "center"};
this.titleText = game.add.text(440, this.inputScorePosY + 40, "점수", titleTextStyle);
@@ -60,7 +61,7 @@ function InputScore(chart) {
(function() { this.onClickSendToServerButton(); }).bind(this)
);
this.loadLicenseCompanySubjectData();
// this.loadLicenseCompanySubjectData();
this.makeLicenseCompanySubjectPanel();
this.setVisibleLicenseCompanyPanel(false);
this.setVisibleLicenseSubjectPanel(false, "");
@@ -69,8 +70,8 @@ function InputScore(chart) {
InputScore.prototype.initVariables = function() {
this.inputScorePosY = GAME_SCREEN_SIZE.y - InputScore.INPUT_SCORE_GROUP_OFFSET_Y;
this.subject = "ITQ 파워포인트";
this.recentSubject = this.subject;
this.subjectFullname = "ITQ 파워포인트";
this.recentSubject = this.subjectFullname;
this.licenseCompanyButtonList = [];
this.licenseSubjectButtonList = [];
@@ -103,7 +104,11 @@ InputScore.prototype.makeInputText = function(x, y, setting) {
return inputText;
}
InputScore.prototype.setSubjectFullname = function(fullname) {
this.subjectFullname = fullname;
// this.subjectFullnameText.text = fullname;
this.subjectFullnameText.setText(this.subjectFullname);
}
InputScore.prototype.onClickSubjectButton = function() {
if(!this.licenseCompanyPanel.visible)
@@ -116,9 +121,10 @@ InputScore.prototype.onClickSubjectButton = function() {
/*
InputScore.prototype.loadLicenseCompanySubjectData = function() {
this.licenseCompanies = [];
this.licenseCompanySubjects = [];
this.licenseSubjects = [];
// console.log(licenseCompanySubjectList);
this.maxSubjectCount = 0;
@@ -143,7 +149,7 @@ InputScore.prototype.loadLicenseCompanySubjectData = function() {
companyData.subjectData[j].gradeList
);
this.licenseCompanySubjects.push(licenseCompnaySubjectItem);
this.licenseSubjects.push(licenseCompnaySubjectItem);
}
}
@@ -153,12 +159,14 @@ InputScore.prototype.loadLicenseCompanySubjectData = function() {
}
// console.log(this.licenseCompanies);
// console.log(this.licenseCompanySubjects);
// console.log(this.licenseSubjects);
// console.log(this.maxSubjectCount);
}
*/
InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
var buttonStackCount = Math.floor(licenseCompanySubjectList.length / 7) + 1;
var companyCount = this.licenseDataManager.getCompanyCount();
var buttonStackCount = Math.floor(companyCount / 7) + 1;
var gapWidth = 10;
var licenseCompanyPanelWidth = gapWidth + (InputScore.LICENSE_COMPANY_BUTTON_WIDTH + gapWidth) * buttonStackCount;
@@ -189,11 +197,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
setting.fontStyle.fontWeight = "bold";
// license company buttons
for(var i = 0; i < licenseCompanySubjectList.length; i++) {
for(var i = 0; i < companyCount; i++) {
setting.width = InputScore.LICENSE_COMPANY_BUTTON_WIDTH;
var self = this;
var companyName = licenseCompanySubjectList[i].companyName;
var companyName = this.licenseDataManager.getCompanyName(i);
this.licenseCompanyButtonList[i] = new RoundRectButton(
setting, null, companyName,
(function() { self.setVisibleLicenseSubjectPanel(true, this.text.text); })
@@ -201,10 +209,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
}
// license subject buttons
for(var i = 0; i < this.licenseCompanySubjects.length; i++) {
var subjectCount = this.licenseDataManager.getSubjectCount();
for(var i = 0; i < subjectCount; i++) {
setting.width = InputScore.LICENSE_SUBJECT_BUTTON_WIDTH;
var companySubjectData = this.licenseCompanySubjects[i];
var companySubjectData = this.licenseDataManager.getSubjectDataByIndex(i);
var companySubjectName = companySubjectData.companyName + " " + companySubjectData.subjectName;
this.licenseSubjectButtonList[i] = new RoundRectButton(setting, null, companySubjectName, null);
}
@@ -250,8 +259,9 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
return;
var buttonIndex = 0;
for(var i = 0; i < this.licenseCompanySubjects.length; i++) {
var subjectData = this.licenseCompanySubjects[i];
var subjectCount = this.licenseDataManager.getSubjectCount();
for(var i = 0; i < subjectCount; i++) {
var subjectData = this.licenseDataManager.getSubjectDataByIndex(i);
if(subjectData.companyName == companyName) {
var button = this.licenseSubjectButtonList[buttonIndex];
@@ -273,8 +283,7 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
}
InputScore.prototype.onClickCompanySubjectButton = function(companySubjectName) {
console.log(companySubjectName);
// this.subjectText.setText(companySubjectName);
this.setSubjectFullname(companySubjectName);
}
@@ -305,10 +314,12 @@ InputScore.LICENSE_BUTTON_GAP_HEIGHT = 64;
InputScore.LICENSE_SUBJECT_BUTTON_MAX_COUNT = 6;
/*
function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) {
this.companyName = companyName;
this.subjectName = subjectName;
this.timeLimit = timeLimit;
this.maxScore = maxScore;
this.gradeList = gradeList;
}
}
*/
@@ -5,11 +5,11 @@ var licenseCompanySubjectList = [
{
timeLimit: 60,
maxScore: 500,
gradeList: {
A: 400,
B: 300,
C: 200
},
gradeList: [
{ score: 400, grade: "A" },
{ score: 300, grade: "B" },
{ score: 200, grade: "C" }
],
subjects: [
"아래한글",
"한셀",
@@ -30,11 +30,11 @@ var licenseCompanySubjectList = [
{
timeLimit: 40,
maxScore: 200,
gradeList: {
고급: 160,
중급: 120,
초급: 80
},
gradeList: [
{ score: 160, grade: "고급" },
{ score: 120, grade: "중급" },
{ score: 80, grade: "초금" }
],
subjects: [
"프리젠테이션",
"스프레드시트",
@@ -46,11 +46,11 @@ var licenseCompanySubjectList = [
{
timeLimit: 40,
maxScore: 100,
gradeList: {
고급: 80,
중급: 60,
초급: 40
},
gradeList: [
{ score: 80, grade: "고급" },
{ score: 60, grade: "중급" },
{ score: 40, grade: "초금" }
],
subjects: [
"인터넷정보검색",
"정보통신상식"
@@ -0,0 +1,106 @@
function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) {
this.companyName = companyName;
this.subjectName = subjectName;
this.timeLimit = timeLimit;
this.maxScore = maxScore;
this.gradeList = gradeList;
}
LicenseCompanySubjectData.prototype.isNameOf = function(companySubjectName) {
var name = this.companyName + " " + this.subjectName;
if(name == companySubjectName)
return true;
return false;
}
function LicenseDataManager() {
this.licenseCompanies = [];
this.licenseSubjects = [];
// console.log(licenseCompanySubjectList);
this.maxSubjectCount = 0;
for(var i = 0; i < licenseCompanySubjectList.length; i++) {
this.licenseCompanies[i] = licenseCompanySubjectList[i].companyName;
var subjectCount = 0;
var companyData = licenseCompanySubjectList[i];
// console.log(companyData);
var subjectData = companyData.subjectData;
// console.log(subjectData);
for(var j = 0; j < subjectData.length; j++) {
var subjectList = subjectData[j].subjects;
subjectCount += subjectList.length;
for(var k = 0; k < subjectList.length; k++) {
var licenseCompnaySubjectItem = new LicenseCompanySubjectData(
this.licenseCompanies[i],
subjectList[k],
companyData.subjectData[j].timeLimit,
companyData.subjectData[j].maxScore,
companyData.subjectData[j].gradeList
);
this.licenseSubjects.push(licenseCompnaySubjectItem);
}
}
if(subjectCount > this.maxSubjectCount)
this.maxSubjectCount = subjectCount;
}
// console.log(this.licenseCompanies);
// console.log(this.licenseSubjects);
// console.log(this.maxSubjectCount);
}
LicenseDataManager.prototype.getCompanyCount = function() {
return this.licenseCompanies.length;
}
LicenseDataManager.prototype.getCompanyList = function() {
return null;
}
LicenseDataManager.prototype.getCompanyName = function(index) {
return this.licenseCompanies[index];
}
LicenseDataManager.prototype.hasCompany = function(companyName) {
for(var i = 0; i < this.licenseCompanies.length; i++) {
if(this.licenseCompanies[i].companyName == companyName)
return true;
}
return false;
}
LicenseDataManager.prototype.getSubjectCount = function() {
return this.licenseSubjects.length;
}
LicenseDataManager.prototype.getSubjectDataByIndex = function(index) {
return this.licenseSubjects[index];
}
LicenseDataManager.prototype.getSubjectDataByName = function(companySubjectName) {
for(var i = 0; i < this.licenseSubjects.length; i++) {
var subjectData = this.licenseSubjects[i];
if(subjectData.isNameOf(companyName))
return subjectData;
}
return null;
}
LicenseDataManager.prototype.getGrade = function(companySubjectName, score) {
var companySubjectData = this.getCompanySubjectData(companySubjectName);
console.log(companySubjectData);
// if(companySubjectData != null) {
// if(score > companySubjectData.gradeList[0].)
// }
}