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
+29 -18
View File
@@ -1,5 +1,6 @@
function InputScore(chart) { function InputScore(chart) {
this.chart = chart; this.chart = chart;
this.licenseDataManager = new LicenseDataManager();
this.initVariables(); this.initVariables();
@@ -31,8 +32,8 @@ function InputScore(chart) {
var subjectTextSetting = this.makeInputTextSetting(280, "과목 입력"); var subjectTextSetting = this.makeInputTextSetting(280, "과목 입력");
this.subjectText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting); this.subjectFullnameText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting);
this.subjectText.setText(this.subject); this.setSubjectFullname(this.subjectFullname);
var titleTextStyle = { font: "36px Arial", fill: "#fff", align: "center"}; var titleTextStyle = { font: "36px Arial", fill: "#fff", align: "center"};
this.titleText = game.add.text(440, this.inputScorePosY + 40, "점수", titleTextStyle); this.titleText = game.add.text(440, this.inputScorePosY + 40, "점수", titleTextStyle);
@@ -60,7 +61,7 @@ function InputScore(chart) {
(function() { this.onClickSendToServerButton(); }).bind(this) (function() { this.onClickSendToServerButton(); }).bind(this)
); );
this.loadLicenseCompanySubjectData(); // this.loadLicenseCompanySubjectData();
this.makeLicenseCompanySubjectPanel(); this.makeLicenseCompanySubjectPanel();
this.setVisibleLicenseCompanyPanel(false); this.setVisibleLicenseCompanyPanel(false);
this.setVisibleLicenseSubjectPanel(false, ""); this.setVisibleLicenseSubjectPanel(false, "");
@@ -69,8 +70,8 @@ function InputScore(chart) {
InputScore.prototype.initVariables = function() { InputScore.prototype.initVariables = function() {
this.inputScorePosY = GAME_SCREEN_SIZE.y - InputScore.INPUT_SCORE_GROUP_OFFSET_Y; this.inputScorePosY = GAME_SCREEN_SIZE.y - InputScore.INPUT_SCORE_GROUP_OFFSET_Y;
this.subject = "ITQ 파워포인트"; this.subjectFullname = "ITQ 파워포인트";
this.recentSubject = this.subject; this.recentSubject = this.subjectFullname;
this.licenseCompanyButtonList = []; this.licenseCompanyButtonList = [];
this.licenseSubjectButtonList = []; this.licenseSubjectButtonList = [];
@@ -103,7 +104,11 @@ InputScore.prototype.makeInputText = function(x, y, setting) {
return inputText; return inputText;
} }
InputScore.prototype.setSubjectFullname = function(fullname) {
this.subjectFullname = fullname;
// this.subjectFullnameText.text = fullname;
this.subjectFullnameText.setText(this.subjectFullname);
}
InputScore.prototype.onClickSubjectButton = function() { InputScore.prototype.onClickSubjectButton = function() {
if(!this.licenseCompanyPanel.visible) if(!this.licenseCompanyPanel.visible)
@@ -116,9 +121,10 @@ InputScore.prototype.onClickSubjectButton = function() {
/*
InputScore.prototype.loadLicenseCompanySubjectData = function() { InputScore.prototype.loadLicenseCompanySubjectData = function() {
this.licenseCompanies = []; this.licenseCompanies = [];
this.licenseCompanySubjects = []; this.licenseSubjects = [];
// console.log(licenseCompanySubjectList); // console.log(licenseCompanySubjectList);
this.maxSubjectCount = 0; this.maxSubjectCount = 0;
@@ -143,7 +149,7 @@ InputScore.prototype.loadLicenseCompanySubjectData = function() {
companyData.subjectData[j].gradeList 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.licenseCompanies);
// console.log(this.licenseCompanySubjects); // console.log(this.licenseSubjects);
// console.log(this.maxSubjectCount); // console.log(this.maxSubjectCount);
} }
*/
InputScore.prototype.makeLicenseCompanySubjectPanel = function() { 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 gapWidth = 10;
var licenseCompanyPanelWidth = gapWidth + (InputScore.LICENSE_COMPANY_BUTTON_WIDTH + gapWidth) * buttonStackCount; var licenseCompanyPanelWidth = gapWidth + (InputScore.LICENSE_COMPANY_BUTTON_WIDTH + gapWidth) * buttonStackCount;
@@ -189,11 +197,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
setting.fontStyle.fontWeight = "bold"; setting.fontStyle.fontWeight = "bold";
// license company buttons // 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; setting.width = InputScore.LICENSE_COMPANY_BUTTON_WIDTH;
var self = this; var self = this;
var companyName = licenseCompanySubjectList[i].companyName; var companyName = this.licenseDataManager.getCompanyName(i);
this.licenseCompanyButtonList[i] = new RoundRectButton( this.licenseCompanyButtonList[i] = new RoundRectButton(
setting, null, companyName, setting, null, companyName,
(function() { self.setVisibleLicenseSubjectPanel(true, this.text.text); }) (function() { self.setVisibleLicenseSubjectPanel(true, this.text.text); })
@@ -201,10 +209,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
} }
// license subject buttons // 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; setting.width = InputScore.LICENSE_SUBJECT_BUTTON_WIDTH;
var companySubjectData = this.licenseCompanySubjects[i]; var companySubjectData = this.licenseDataManager.getSubjectDataByIndex(i);
var companySubjectName = companySubjectData.companyName + " " + companySubjectData.subjectName; var companySubjectName = companySubjectData.companyName + " " + companySubjectData.subjectName;
this.licenseSubjectButtonList[i] = new RoundRectButton(setting, null, companySubjectName, null); this.licenseSubjectButtonList[i] = new RoundRectButton(setting, null, companySubjectName, null);
} }
@@ -250,8 +259,9 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
return; return;
var buttonIndex = 0; var buttonIndex = 0;
for(var i = 0; i < this.licenseCompanySubjects.length; i++) { var subjectCount = this.licenseDataManager.getSubjectCount();
var subjectData = this.licenseCompanySubjects[i]; for(var i = 0; i < subjectCount; i++) {
var subjectData = this.licenseDataManager.getSubjectDataByIndex(i);
if(subjectData.companyName == companyName) { if(subjectData.companyName == companyName) {
var button = this.licenseSubjectButtonList[buttonIndex]; var button = this.licenseSubjectButtonList[buttonIndex];
@@ -273,8 +283,7 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
} }
InputScore.prototype.onClickCompanySubjectButton = function(companySubjectName) { InputScore.prototype.onClickCompanySubjectButton = function(companySubjectName) {
console.log(companySubjectName); this.setSubjectFullname(companySubjectName);
// this.subjectText.setText(companySubjectName);
} }
@@ -305,6 +314,7 @@ InputScore.LICENSE_BUTTON_GAP_HEIGHT = 64;
InputScore.LICENSE_SUBJECT_BUTTON_MAX_COUNT = 6; InputScore.LICENSE_SUBJECT_BUTTON_MAX_COUNT = 6;
/*
function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) { function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) {
this.companyName = companyName; this.companyName = companyName;
this.subjectName = subjectName; this.subjectName = subjectName;
@@ -312,3 +322,4 @@ function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore
this.maxScore = maxScore; this.maxScore = maxScore;
this.gradeList = gradeList; this.gradeList = gradeList;
} }
*/
@@ -5,11 +5,11 @@ var licenseCompanySubjectList = [
{ {
timeLimit: 60, timeLimit: 60,
maxScore: 500, maxScore: 500,
gradeList: { gradeList: [
A: 400, { score: 400, grade: "A" },
B: 300, { score: 300, grade: "B" },
C: 200 { score: 200, grade: "C" }
}, ],
subjects: [ subjects: [
"아래한글", "아래한글",
"한셀", "한셀",
@@ -30,11 +30,11 @@ var licenseCompanySubjectList = [
{ {
timeLimit: 40, timeLimit: 40,
maxScore: 200, maxScore: 200,
gradeList: { gradeList: [
고급: 160, { score: 160, grade: "고급" },
중급: 120, { score: 120, grade: "중급" },
초급: 80 { score: 80, grade: "초금" }
}, ],
subjects: [ subjects: [
"프리젠테이션", "프리젠테이션",
"스프레드시트", "스프레드시트",
@@ -46,11 +46,11 @@ var licenseCompanySubjectList = [
{ {
timeLimit: 40, timeLimit: 40,
maxScore: 100, maxScore: 100,
gradeList: { gradeList: [
고급: 80, { score: 80, grade: "고급" },
중급: 60, { score: 60, grade: "중급" },
초급: 40 { score: 40, grade: "초금" }
}, ],
subjects: [ 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].)
// }
}
+1
View File
@@ -57,6 +57,7 @@
<script src="../../game/license_timer/license_data/company_subject.js"></script> <script src="../../game/license_timer/license_data/company_subject.js"></script>
<!-- game : source files --> <!-- game : source files -->
<script src="../../game/license_timer/license_data_manager.js"></script>
<script src="../../game/license_timer/loading.js"></script> <script src="../../game/license_timer/loading.js"></script>
<script src="../../game/license_timer/login.js"></script> <script src="../../game/license_timer/login.js"></script>
<script src="../../game/license_timer/timer.js"></script> <script src="../../game/license_timer/timer.js"></script>