Add: test and practice
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/////////////////////////////
|
||||
// Main game
|
||||
|
||||
const CONTENT_ID = "Menu";
|
||||
|
||||
let game = new Phaser.Game(
|
||||
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y,
|
||||
Phaser.CANVAS, CONTENT_ID
|
||||
);
|
||||
|
||||
game.state.add('MenuTypingTest', MenuTypingTest);
|
||||
game.state.start('MenuTypingTest');
|
||||
+46
-19
@@ -47,7 +47,11 @@ class MenuApp {
|
||||
// console.log(replyJSON);
|
||||
|
||||
self.makeMouseAppButtons(replyJSON.MouseAppList);
|
||||
self.makeTypingButtons(replyJSON.TypingPracticeAppCount, replyJSON.TypingAppList);
|
||||
self.makeTypingButtons(
|
||||
replyJSON.TypingPracticeAppCount,
|
||||
replyJSON.TypingTestAppCount,
|
||||
replyJSON.TypingAppList
|
||||
);
|
||||
}
|
||||
|
||||
makeMouseAppButtons(mouseAppJSON) {
|
||||
@@ -73,12 +77,17 @@ class MenuApp {
|
||||
}
|
||||
}
|
||||
|
||||
makeTypingButtons(typingPracticeAppCount, typingAppJSON) {
|
||||
// console.log(typingPracticeAppCount);
|
||||
// console.log(typingAppJSON);
|
||||
makeTypingButtons(typingPracticeAppCount, typingTestAppCount, typingAppJSON) {
|
||||
console.log(typingPracticeAppCount);
|
||||
console.log(typingTestAppCount);
|
||||
console.log(typingAppJSON);
|
||||
|
||||
let isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false;
|
||||
let typingAppTotalCount = Object.keys(typingAppJSON).length + (isTypingPracticeAppExist ? 1 : 0);
|
||||
let isTypingTestAppExist = typingTestAppCount > 0 ? true : false;
|
||||
|
||||
let typingAppTotalCount = Object.keys(typingAppJSON).length
|
||||
+ (isTypingPracticeAppExist ? 1 : 0)
|
||||
+ (isTypingTestAppExist ? 1 : 0);
|
||||
let typingAppIndex = 0;
|
||||
|
||||
for(let typingButtonIndex = 0; typingButtonIndex < typingAppTotalCount; typingButtonIndex++) {
|
||||
@@ -90,32 +99,50 @@ class MenuApp {
|
||||
typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y
|
||||
);
|
||||
|
||||
if(typingButtonIndex == 0 && isTypingPracticeAppExist) {
|
||||
if(isTypingPracticeAppExist) {
|
||||
isTypingPracticeAppExist = false;
|
||||
|
||||
new GameAppButton(
|
||||
posX, posY, AppButton.TYPE_TYPING_PRACTICE,
|
||||
"", "타자 연습\n(임시)",
|
||||
"", "타자 연습",
|
||||
() => {
|
||||
location.href = '../../web/client/menu_typing_practice.html';
|
||||
}
|
||||
);
|
||||
} else {
|
||||
let app = typingAppJSON[typingAppIndex];
|
||||
let isKoreanTypingApp = app.AppID < 32 ? true : false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isTypingTestAppExist) {
|
||||
isTypingTestAppExist = false;
|
||||
|
||||
new GameAppButton(
|
||||
posX, posY, AppButton.TYPE_TYPING_APP,
|
||||
"icon_fullscreen",
|
||||
// (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName,
|
||||
app.KoreanName,
|
||||
posX, posY, AppButton.TYPE_TYPING_PRACTICE,
|
||||
"", "타자 시험",
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = app.AppID;
|
||||
sessionStorageManager.playingAppName = app.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = app.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
location.href = '../../web/client/menu_typing_test.html';
|
||||
}
|
||||
);
|
||||
typingAppIndex++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
let app = typingAppJSON[typingAppIndex];
|
||||
let isKoreanTypingApp = app.AppID < 32 ? true : false;
|
||||
|
||||
new GameAppButton(
|
||||
posX, posY, AppButton.TYPE_TYPING_APP,
|
||||
"icon_fullscreen",
|
||||
// (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName,
|
||||
app.KoreanName,
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = app.AppID;
|
||||
sessionStorageManager.playingAppName = app.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = app.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
typingAppIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////
|
||||
// MenuApp
|
||||
// MenuTypingPractice
|
||||
|
||||
class MenuTypingPractice {
|
||||
|
||||
@@ -23,7 +23,7 @@ class MenuTypingPractice {
|
||||
let screenBottom = new ScreenBottom();
|
||||
screenBottom.makeBottomLine();
|
||||
// screenBottom.printBottomLeftText("게임 진행 정보");
|
||||
screenBottom.printBottomCenterText("타자 연습");
|
||||
screenBottom.printBottomCenterText("메뉴 > 타자 연습");
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ class MenuTypingPractice {
|
||||
let koreanTypingPracticeAppCount = Object.keys(replyJSON.Korean).length;
|
||||
let englishTypingPracticeAppCount = Object.keys(replyJSON.English).length;
|
||||
|
||||
// let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||
// let koreanTypingPracticeAppIndex = 0;
|
||||
for(let i = 0; i < koreanTypingPracticeAppCount; i++) {
|
||||
let activeApp = replyJSON.Korean[i];
|
||||
|
||||
@@ -66,12 +64,12 @@ class MenuTypingPractice {
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// startX = game.world.width / 2 - (buttonWidthGap * englishTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||
for(let i = 0; i < englishTypingPracticeAppCount; i++) {
|
||||
let activeApp = replyJSON.English[i];
|
||||
|
||||
@@ -87,6 +85,7 @@ class MenuTypingPractice {
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/////////////////////////////
|
||||
// MenuTypingTest
|
||||
|
||||
class MenuTypingTest {
|
||||
|
||||
preload() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png');
|
||||
}
|
||||
|
||||
create() {
|
||||
self = this;
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// top
|
||||
let backButton = new BackButton( () => {
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
});
|
||||
let fullscreenButton = new FullscreenButton(this.game);
|
||||
|
||||
|
||||
// bottom
|
||||
let screenBottom = new ScreenBottom();
|
||||
screenBottom.makeBottomLine();
|
||||
// screenBottom.printBottomLeftText("게임 진행 정보");
|
||||
screenBottom.printBottomCenterText("메뉴 > 타자 시험");
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
|
||||
|
||||
this.makeActiveTypingTestAppButtons();
|
||||
}
|
||||
|
||||
|
||||
makeActiveTypingTestAppButtons() {
|
||||
let dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestTypingTestAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
self.loginSucceeded,
|
||||
self.loginFailed
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
loginSucceeded(replyJSON) {
|
||||
// console.log(replyJSON);
|
||||
|
||||
let buttonWidthGap = TypingPracticeButton.BUTTON_WIDTH + MenuTypingTest.BUTTON_GAP;
|
||||
|
||||
let koreanTypingTestAppCount = Object.keys(replyJSON.Korean).length;
|
||||
let englishTypingTestAppCount = Object.keys(replyJSON.English).length;
|
||||
|
||||
// let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingTestAppCount / 2) - (buttonWidthGap / 2);
|
||||
// let koreanTypingTestAppIndex = 0;
|
||||
for(let i = 0; i < koreanTypingTestAppCount; i++) {
|
||||
let activeApp = replyJSON.Korean[i];
|
||||
|
||||
let posX = self.getButtonPosX(i, koreanTypingTestAppCount);
|
||||
let posY = self.getButtonPosY(i, koreanTypingTestAppCount,
|
||||
TypingPracticeButton.BUTTON_UPPER_POS_Y
|
||||
);
|
||||
|
||||
new TypingPracticeButton(
|
||||
posX, posY, LANGUAGE_KOREAN,
|
||||
TypingPracticeButton.NONE_ICON,
|
||||
activeApp.KoreanName,
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// startX = game.world.width / 2 - (buttonWidthGap * englishTypingTestAppCount / 2) - (buttonWidthGap / 2);
|
||||
for(let i = 0; i < englishTypingTestAppCount; i++) {
|
||||
let activeApp = replyJSON.English[i];
|
||||
|
||||
let posX = self.getButtonPosX(i, englishTypingTestAppCount);
|
||||
let posY = self.getButtonPosY(i, englishTypingTestAppCount,
|
||||
TypingPracticeButton.BUTTON_LOWER_POS_Y
|
||||
);
|
||||
|
||||
new TypingPracticeButton(
|
||||
posX, posY, LANGUAGE_ENGLISH,
|
||||
TypingPracticeButton.NONE_ICON,
|
||||
activeApp.KoreanName,
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getButtonPosX(index, buttonCount) {
|
||||
let gap = TypingPracticeButton.BUTTON_WIDTH + TypingPracticeButton.BUTTON_GAP;
|
||||
let maxColumnNum = Math.floor( (game.world.width - TypingPracticeButton.MARGIN_VERTICAL) / gap );
|
||||
// console.log("maxColumnNum : " + maxColumnNum);
|
||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
// console.log("rowCount : " + rowCount);
|
||||
|
||||
let columnIndex = index % maxColumnNum;
|
||||
// console.log("columnIndex : " + columnIndex);
|
||||
let rowIndex = Math.floor(index / maxColumnNum);
|
||||
// console.log("rowIndex : " + rowIndex);
|
||||
|
||||
let columnCountForThisRow = 0;
|
||||
if(rowIndex < rowCount - 1)
|
||||
columnCountForThisRow = maxColumnNum;
|
||||
else
|
||||
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
|
||||
// console.log("columnCountForThisRow : " + columnCountForThisRow);
|
||||
|
||||
let startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
|
||||
return startX + gap * columnIndex;
|
||||
}
|
||||
|
||||
getButtonPosY(index, buttonCount, startPosY) {
|
||||
let gap = TypingPracticeButton.BUTTON_HEIGHT + TypingPracticeButton.BUTTON_GAP;
|
||||
let maxColumnNum = Math.floor( (game.world.width - TypingPracticeButton.MARGIN_VERTICAL) / gap );
|
||||
// console.log("maxColumnNum : " + maxColumnNum);
|
||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
// console.log("rowCount : " + rowCount);
|
||||
|
||||
let rowIndex = Math.floor(index / maxColumnNum);
|
||||
// console.log("rowIndex : " + rowIndex);
|
||||
|
||||
let startY = startPosY - ( (gap / 2) * (rowCount - 1) );
|
||||
return startY + gap * rowIndex;
|
||||
}
|
||||
|
||||
|
||||
loginFailed(replyJSON) {
|
||||
console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user