Add: test and practice
This commit is contained in:
@@ -51,4 +51,44 @@ function isTypingGame() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTypingPracticeStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
console.log(appName);
|
||||||
|
console.log(appName.indexOf("practice_"));
|
||||||
|
if(appName.indexOf("practice_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingTestStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
console.log(appName.indexOf("test_"));
|
||||||
|
if(appName.indexOf("test_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingWordStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_word") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingSentenceStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_sentence") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
|
|||||||
@@ -134,6 +134,23 @@ class DBConnectManager {
|
|||||||
xhr.send("maestro_id=" + maestroID);
|
xhr.send("maestro_id=" + maestroID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestTypingTestAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", this.phpPath + "server/app/menu_active_typing_test_app_list.php", true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||||
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
|
||||||
|
if(replyJSON != null)
|
||||||
|
onSucceededListener(replyJSON);
|
||||||
|
else
|
||||||
|
onFailedListener(replyJSON);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send("maestro_id=" + maestroID);
|
||||||
|
}
|
||||||
|
|
||||||
requestPlayerHistory(maestroID, date, listener) {
|
requestPlayerHistory(maestroID, date, listener) {
|
||||||
let historyRecordManager = new HistoryRecordManager();
|
let historyRecordManager = new HistoryRecordManager();
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
// console.log(replyJSON);
|
||||||
|
|
||||||
self.makeMouseAppButtons(replyJSON.MouseAppList);
|
self.makeMouseAppButtons(replyJSON.MouseAppList);
|
||||||
self.makeTypingButtons(replyJSON.TypingPracticeAppCount, replyJSON.TypingAppList);
|
self.makeTypingButtons(
|
||||||
|
replyJSON.TypingPracticeAppCount,
|
||||||
|
replyJSON.TypingTestAppCount,
|
||||||
|
replyJSON.TypingAppList
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeMouseAppButtons(mouseAppJSON) {
|
makeMouseAppButtons(mouseAppJSON) {
|
||||||
@@ -73,12 +77,17 @@ class MenuApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
makeTypingButtons(typingPracticeAppCount, typingAppJSON) {
|
makeTypingButtons(typingPracticeAppCount, typingTestAppCount, typingAppJSON) {
|
||||||
// console.log(typingPracticeAppCount);
|
console.log(typingPracticeAppCount);
|
||||||
// console.log(typingAppJSON);
|
console.log(typingTestAppCount);
|
||||||
|
console.log(typingAppJSON);
|
||||||
|
|
||||||
let isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false;
|
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;
|
let typingAppIndex = 0;
|
||||||
|
|
||||||
for(let typingButtonIndex = 0; typingButtonIndex < typingAppTotalCount; typingButtonIndex++) {
|
for(let typingButtonIndex = 0; typingButtonIndex < typingAppTotalCount; typingButtonIndex++) {
|
||||||
@@ -90,32 +99,50 @@ class MenuApp {
|
|||||||
typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y
|
typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y
|
||||||
);
|
);
|
||||||
|
|
||||||
if(typingButtonIndex == 0 && isTypingPracticeAppExist) {
|
if(isTypingPracticeAppExist) {
|
||||||
|
isTypingPracticeAppExist = false;
|
||||||
|
|
||||||
new GameAppButton(
|
new GameAppButton(
|
||||||
posX, posY, AppButton.TYPE_TYPING_PRACTICE,
|
posX, posY, AppButton.TYPE_TYPING_PRACTICE,
|
||||||
"", "타자 연습\n(임시)",
|
"", "타자 연습",
|
||||||
() => {
|
() => {
|
||||||
location.href = '../../web/client/menu_typing_practice.html';
|
location.href = '../../web/client/menu_typing_practice.html';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
let app = typingAppJSON[typingAppIndex];
|
continue;
|
||||||
let isKoreanTypingApp = app.AppID < 32 ? true : false;
|
}
|
||||||
|
|
||||||
|
if(isTypingTestAppExist) {
|
||||||
|
isTypingTestAppExist = false;
|
||||||
|
|
||||||
new GameAppButton(
|
new GameAppButton(
|
||||||
posX, posY, AppButton.TYPE_TYPING_APP,
|
posX, posY, AppButton.TYPE_TYPING_PRACTICE,
|
||||||
"icon_fullscreen",
|
"", "타자 시험",
|
||||||
// (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName,
|
|
||||||
app.KoreanName,
|
|
||||||
() => {
|
() => {
|
||||||
sessionStorageManager.playingAppID = app.AppID;
|
location.href = '../../web/client/menu_typing_test.html';
|
||||||
sessionStorageManager.playingAppName = app.AppName;
|
|
||||||
sessionStorageManager.playingAppKoreanName = app.KoreanName;
|
|
||||||
location.href = '../../web/client/start.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 {
|
class MenuTypingPractice {
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ class MenuTypingPractice {
|
|||||||
let screenBottom = new ScreenBottom();
|
let screenBottom = new ScreenBottom();
|
||||||
screenBottom.makeBottomLine();
|
screenBottom.makeBottomLine();
|
||||||
// screenBottom.printBottomLeftText("게임 진행 정보");
|
// screenBottom.printBottomLeftText("게임 진행 정보");
|
||||||
screenBottom.printBottomCenterText("타자 연습");
|
screenBottom.printBottomCenterText("메뉴 > 타자 연습");
|
||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
|
|
||||||
|
|
||||||
@@ -49,8 +49,6 @@ class MenuTypingPractice {
|
|||||||
let koreanTypingPracticeAppCount = Object.keys(replyJSON.Korean).length;
|
let koreanTypingPracticeAppCount = Object.keys(replyJSON.Korean).length;
|
||||||
let englishTypingPracticeAppCount = Object.keys(replyJSON.English).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++) {
|
for(let i = 0; i < koreanTypingPracticeAppCount; i++) {
|
||||||
let activeApp = replyJSON.Korean[i];
|
let activeApp = replyJSON.Korean[i];
|
||||||
|
|
||||||
@@ -66,12 +64,12 @@ class MenuTypingPractice {
|
|||||||
() => {
|
() => {
|
||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
|
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||||
location.href = '../../web/client/start.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// startX = game.world.width / 2 - (buttonWidthGap * englishTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
|
||||||
for(let i = 0; i < englishTypingPracticeAppCount; i++) {
|
for(let i = 0; i < englishTypingPracticeAppCount; i++) {
|
||||||
let activeApp = replyJSON.English[i];
|
let activeApp = replyJSON.English[i];
|
||||||
|
|
||||||
@@ -87,6 +85,7 @@ class MenuTypingPractice {
|
|||||||
() => {
|
() => {
|
||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
|
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||||
location.href = '../../web/client/start.html';
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,8 +16,14 @@ class Result {
|
|||||||
|
|
||||||
// top
|
// top
|
||||||
let backButton = new BackButton( () => {
|
let backButton = new BackButton( () => {
|
||||||
|
if(isTypingPracticeStage())
|
||||||
|
location.href = '../../web/client/menu_typing_practice.html';
|
||||||
|
else if(isTypingTestStage())
|
||||||
|
location.href = '../../web/client/menu_typing_test.html';
|
||||||
|
else
|
||||||
|
location.href = '../../web/client/menu_app.html';
|
||||||
|
|
||||||
sessionStorageManager.resetPlayingAppData();
|
sessionStorageManager.resetPlayingAppData();
|
||||||
location.href = '../../web/client/menu_app.html';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let fullscreenButton = new FullscreenButton(this.game);
|
let fullscreenButton = new FullscreenButton(this.game);
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ class Start {
|
|||||||
|
|
||||||
// top
|
// top
|
||||||
let backButton = new BackButton( () => {
|
let backButton = new BackButton( () => {
|
||||||
sessionStorageManager.playingAppName = null;
|
if(isTypingPracticeStage())
|
||||||
sessionStorageManager.playingAppKoreanName = null;
|
location.href = '../../web/client/menu_typing_practice.html';
|
||||||
sessionStorageManager.record = null;
|
else if(isTypingTestStage())
|
||||||
sessionStorageManager.bestRecord = null;
|
location.href = '../../web/client/menu_typing_test.html';
|
||||||
|
else
|
||||||
|
location.href = '../../web/client/menu_app.html';
|
||||||
|
|
||||||
location.href = '../../web/client/menu_app.html';
|
sessionStorageManager.resetPlayingAppData();
|
||||||
});
|
});
|
||||||
|
|
||||||
let fullscreenButton = new FullscreenButton(this.game);
|
let fullscreenButton = new FullscreenButton(this.game);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Typing Test
|
// TypingTest
|
||||||
|
|
||||||
class Test {
|
class TypingTest {
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
self = this;
|
self = this;
|
||||||
@@ -14,7 +14,8 @@ class Test {
|
|||||||
// top
|
// top
|
||||||
let backButton = new BackButton( () => {
|
let backButton = new BackButton( () => {
|
||||||
sessionStorageManager.resetPlayingAppData();
|
sessionStorageManager.resetPlayingAppData();
|
||||||
location.href = '../../web/client/menu_app.html';
|
|
||||||
|
location.href = '../../web/client/menu_typing_test.html';
|
||||||
});
|
});
|
||||||
|
|
||||||
this.averageTypingSpeedText = new AverageTypingSpeed();
|
this.averageTypingSpeedText = new AverageTypingSpeed();
|
||||||
@@ -29,7 +30,7 @@ class Test {
|
|||||||
bar.beginFill(0x000000, 0.2);
|
bar.beginFill(0x000000, 0.2);
|
||||||
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
|
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
|
||||||
|
|
||||||
if(this.isWordStage())
|
if(isTypingWordStage())
|
||||||
textStyleBasic.font = "bold 84px Arial";
|
textStyleBasic.font = "bold 84px Arial";
|
||||||
else // Sentence stage
|
else // Sentence stage
|
||||||
textStyleBasic.font = "bold 48px Arial";
|
textStyleBasic.font = "bold 48px Arial";
|
||||||
@@ -37,21 +38,21 @@ class Test {
|
|||||||
this.textTypingContent = game.add.text(0, 2, "test", textStyleBasic)
|
this.textTypingContent = game.add.text(0, 2, "test", textStyleBasic)
|
||||||
.setTextBounds(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120)
|
.setTextBounds(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
.addColor(Test.COLOR_CONTENT_WRONG, 0);
|
.addColor(TypingTest.COLOR_CONTENT_WRONG, 0);
|
||||||
|
|
||||||
textStyleBasic.font = "32px Arial";
|
textStyleBasic.font = "32px Arial";
|
||||||
|
|
||||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||||
this.textTypingContentsDone = [];
|
this.textTypingContentsDone = [];
|
||||||
this.textTypingRecordsDone = [];
|
this.textTypingRecordsDone = [];
|
||||||
for(var i = 0; i < Test.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(var i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
this.textTypingContentsDone[i] = game.add.text(0, 2, "test", textStyleBasic)
|
this.textTypingContentsDone[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||||
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
|
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
.addColor(textDoneColor[i], 0);
|
.addColor(textDoneColor[i], 0);
|
||||||
|
|
||||||
var scorePositionX = 780;
|
var scorePositionX = 780;
|
||||||
if(this.isWordStage())
|
if(isTypingWordStage())
|
||||||
scorePositionX = 600;
|
scorePositionX = 600;
|
||||||
|
|
||||||
this.textTypingRecordsDone[i] = game.add.text(0, 2, "", textStyleBasic)
|
this.textTypingRecordsDone[i] = game.add.text(0, 2, "", textStyleBasic)
|
||||||
@@ -63,7 +64,7 @@ class Test {
|
|||||||
|
|
||||||
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||||
this.textTypingContentPreview = [];
|
this.textTypingContentPreview = [];
|
||||||
for(var i = 0; i < Test.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
for(var i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
this.textTypingContentPreview[i] = game.add.text(0, 2, "test", textStyleBasic)
|
this.textTypingContentPreview[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||||
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
|
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
@@ -148,13 +149,13 @@ class Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initTypingData() {
|
initTypingData() {
|
||||||
this.typingTestContents = this.getTypingTestContents();
|
this.typingContents = this.getTypingTestContents();
|
||||||
var randomContents = Phaser.ArrayUtils.shuffle(this.typingTestContents);
|
var randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||||
this.wordCountForStage = Test.WORD_COUNT_FOR_STAGE;
|
this.wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
|
||||||
if(isDebugMode())
|
if(isDebugMode())
|
||||||
this.wordCountForStage = 3;
|
this.wordCountForStage = 3;
|
||||||
this.typingRandomContents = randomContents.slice(1, this.wordCountForStage + 1); // start Num, end Num (not index)
|
this.typingRandomContents = randomContents.slice(1, this.wordCountForStage + 1); // start Num, end Num (not index)
|
||||||
this.typingContentLength = this.typingTestContents.length;
|
this.typingContentLength = this.typingContents.length;
|
||||||
this.typingIndex = 0;
|
this.typingIndex = 0;
|
||||||
|
|
||||||
this.isTyping = false;
|
this.isTyping = false;
|
||||||
@@ -185,16 +186,20 @@ class Test {
|
|||||||
loadTestContent() {
|
loadTestContent() {
|
||||||
var testContent = [];
|
var testContent = [];
|
||||||
switch(sessionStorageManager.playingAppName) {
|
switch(sessionStorageManager.playingAppName) {
|
||||||
case "korean_word":
|
case "test_korean_word":
|
||||||
|
case "practice_korean_word":
|
||||||
testContent = koreanWordList;
|
testContent = koreanWordList;
|
||||||
break;
|
break;
|
||||||
case "korean_sentence":
|
case "test_korean_sentence":
|
||||||
|
case "practice_korean_sentence":
|
||||||
testContent = koreanSentenceList;
|
testContent = koreanSentenceList;
|
||||||
break;
|
break;
|
||||||
case "english_word":
|
case "test_english_word":
|
||||||
|
case "practice_english_word":
|
||||||
testContent = englishWordList;
|
testContent = englishWordList;
|
||||||
break;
|
break;
|
||||||
case "english_sentence":
|
case "test_english_sentence":
|
||||||
|
case "practice_english_sentence":
|
||||||
testContent = englishSentenceList;
|
testContent = englishSentenceList;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -202,12 +207,8 @@ class Test {
|
|||||||
return testContent;
|
return testContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
isWordStage() {
|
|
||||||
return ( (sessionStorageManager.playingAppID % 10) === 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
showTypingTestContents() {
|
showTypingTestContents() {
|
||||||
for(var i = 0; i < Test.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(var i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
var doneIndex = this.typingIndex - i - 1;
|
var doneIndex = this.typingIndex - i - 1;
|
||||||
if(doneIndex < 0) {
|
if(doneIndex < 0) {
|
||||||
this.textTypingContentsDone[i].text = "";
|
this.textTypingContentsDone[i].text = "";
|
||||||
@@ -225,7 +226,7 @@ class Test {
|
|||||||
|
|
||||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||||
|
|
||||||
for(var i = 0; i < Test.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
for(var i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
var previewIndex = this.typingIndex + i + 1;
|
var previewIndex = this.typingIndex + i + 1;
|
||||||
if(previewIndex < this.typingRandomContents.length)
|
if(previewIndex < this.typingRandomContents.length)
|
||||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||||
@@ -236,7 +237,7 @@ class Test {
|
|||||||
|
|
||||||
resetTypingContent() {
|
resetTypingContent() {
|
||||||
this.textTypingContent.clearColors();
|
this.textTypingContent.clearColors();
|
||||||
this.textTypingContent.addColor(Test.COLOR_CONTENT_WRONG, 0);
|
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_WRONG, 0);
|
||||||
this.inputTextContent.canvasInput.value('');
|
this.inputTextContent.canvasInput.value('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +272,7 @@ class Test {
|
|||||||
var inputContent = this.inputTextContent.canvasInput.value();
|
var inputContent = this.inputTextContent.canvasInput.value();
|
||||||
|
|
||||||
this.textTypingContent.clearColors();
|
this.textTypingContent.clearColors();
|
||||||
this.textTypingContent.addColor(Test.COLOR_CONTENT_RIGHT, 0);
|
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_RIGHT, 0);
|
||||||
|
|
||||||
if(typingContent == null)
|
if(typingContent == null)
|
||||||
return;
|
return;
|
||||||
@@ -282,7 +283,7 @@ class Test {
|
|||||||
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
|
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
|
||||||
|
|
||||||
if(typingContent.charAt(i) != inputContent.charAt(i)) {
|
if(typingContent.charAt(i) != inputContent.charAt(i)) {
|
||||||
this.textTypingContent.addColor(Test.COLOR_CONTENT_WRONG, i);
|
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_WRONG, i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,9 +301,9 @@ class Test {
|
|||||||
|
|
||||||
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||||
// console.log('typingContentLength : ' + typingContentLength);
|
// console.log('typingContentLength : ' + typingContentLength);
|
||||||
var typingContentPlusEnterCount = typingContentLength + Test.TYPING_COUNT_PLUS_ENTER;
|
var typingContentPlusEnterCount = typingContentLength + TypingTest.TYPING_COUNT_PLUS_ENTER;
|
||||||
|
|
||||||
var typingRecord = (typingContentPlusEnterCount + Test.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
var typingRecord = (typingContentPlusEnterCount + TypingTest.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||||
|
|
||||||
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
||||||
this.typingLetterCountTotal += typingContentPlusEnterCount;
|
this.typingLetterCountTotal += typingContentPlusEnterCount;
|
||||||
@@ -356,17 +357,17 @@ class Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Test.TYPING_CONTENT_PREVIEW_COUNT = 3;
|
TypingTest.TYPING_CONTENT_PREVIEW_COUNT = 3;
|
||||||
Test.TYPING_CONTENT_DONE_COUNT = 3;
|
TypingTest.TYPING_CONTENT_DONE_COUNT = 3;
|
||||||
Test.TYPING_COUNT_PLUS_ENTER = 1;
|
TypingTest.TYPING_COUNT_PLUS_ENTER = 1;
|
||||||
|
|
||||||
Test.OFFSET_RIGHT_ALIGN = 10;
|
TypingTest.OFFSET_RIGHT_ALIGN = 10;
|
||||||
|
|
||||||
Test.WORD_COUNT_FOR_STAGE = 10;
|
TypingTest.WORD_COUNT_FOR_STAGE = 10;
|
||||||
// if(isDebugMode())
|
// if(isDebugMode())
|
||||||
// WORD_COUNT_FOR_STAGE = 3;
|
// WORD_COUNT_FOR_STAGE = 3;
|
||||||
|
|
||||||
Test.COLOR_CONTENT_WRONG = "#aaaaaa";
|
TypingTest.COLOR_CONTENT_WRONG = "#aaaaaa";
|
||||||
Test.COLOR_CONTENT_RIGHT = "#ffff4d";
|
TypingTest.COLOR_CONTENT_RIGHT = "#ffff4d";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ class Loading {
|
|||||||
// this.preloadBar.alpha = 1;
|
// this.preloadBar.alpha = 1;
|
||||||
|
|
||||||
if(isDebugMode()) {
|
if(isDebugMode()) {
|
||||||
this.state.start('Test');
|
this.state.start('TypingTest');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.start('Test');
|
this.state.start('TypingTest');
|
||||||
// this.startMenu();
|
// this.startMenu();
|
||||||
// this.startTypingTestStage();
|
// this.startTypingTestStage();
|
||||||
// this.startTypingTestResult();
|
// this.startTypingTestResult();
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ let game = new Phaser.Game(
|
|||||||
game.state.add('Loading', Loading);
|
game.state.add('Loading', Loading);
|
||||||
game.state.start('Loading');
|
game.state.start('Loading');
|
||||||
|
|
||||||
game.state.add('Test', Test);
|
game.state.add('TypingTest', TypingTest);
|
||||||
// game.state.add('Menu', Menu);
|
// game.state.add('Menu', Menu);
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>메뉴</title>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> -->
|
||||||
|
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.js"></script> -->
|
||||||
|
<script src="../../../resources/js/phaser.min.js"></script>
|
||||||
|
|
||||||
|
<!-- global source files -->
|
||||||
|
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||||
|
<script src="../../game/global/global_variables.js"></script>
|
||||||
|
|
||||||
|
<!-- library source files -->
|
||||||
|
<script src="../../game/lib/input_type_text.js"></script>
|
||||||
|
<script src="../../game/lib/round_rect_button.js"></script>
|
||||||
|
<script src="../../game/lib/back_button.js"></script>
|
||||||
|
<script src="../../game/lib/fullscreen_button.js"></script>
|
||||||
|
<script src="../../game/lib/app_button.js"></script>
|
||||||
|
<script src="../../game/lib/typing_practice_button.js"></script>
|
||||||
|
<script src="../../game/lib/screen_bottom.js"></script>
|
||||||
|
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||||
|
|
||||||
|
<!-- source files -->
|
||||||
|
<script src="../../game/menu/menu_typing_test.js"></script>
|
||||||
|
<script src="../../game/menu/main_menu_typing_test.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body{
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas{
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="MenuApp" style="text-align:center;" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -10,6 +10,7 @@ include "./../setup/connect_db.php";
|
|||||||
$replyJSON = array();
|
$replyJSON = array();
|
||||||
$replyJSON["MouseAppList"] = get_mouse_app_list($maestro_id);
|
$replyJSON["MouseAppList"] = get_mouse_app_list($maestro_id);
|
||||||
$replyJSON["TypingPracticeAppCount"] = get_typing_practice_app_count($maestro_id);
|
$replyJSON["TypingPracticeAppCount"] = get_typing_practice_app_count($maestro_id);
|
||||||
|
$replyJSON["TypingTestAppCount"] = get_typing_test_app_count($maestro_id);
|
||||||
$replyJSON["TypingAppList"] = get_typing_app_list($maestro_id);
|
$replyJSON["TypingAppList"] = get_typing_app_list($maestro_id);
|
||||||
$db_conn->close();
|
$db_conn->close();
|
||||||
|
|
||||||
@@ -55,7 +56,24 @@ function get_typing_practice_app_count($maestro_id) {
|
|||||||
$query = "
|
$query = "
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM moty_app AS A
|
FROM moty_app AS A
|
||||||
INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND A.AppType < 50 AND AA.MaestroID=?";
|
INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND A.AppType <= 2 AND AA.MaestroID=?";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $maestro_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($typing_practice_app_count);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $typing_practice_app_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_typing_test_app_count($maestro_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM moty_app AS A
|
||||||
|
INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND A.AppType > 10 AND A.AppType <= 12 AND AA.MaestroID=?";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param("i", $maestro_id);
|
$stmt->bind_param("i", $maestro_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ $maestro_id = $_POST["maestro_id"];
|
|||||||
include "./../setup/connect_db.php";
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
|
||||||
$replyJSON["Korean"] = get_active_typing_practice_app_list($maestro_id, 10);
|
$replyJSON["Korean"] = get_active_typing_practice_app_list($maestro_id, 1);
|
||||||
$replyJSON["English"] = get_active_typing_practice_app_list($maestro_id, 20);
|
$replyJSON["English"] = get_active_typing_practice_app_list($maestro_id, 2);
|
||||||
$db_conn->close();
|
$db_conn->close();
|
||||||
|
|
||||||
if($replyJSON.length === 0) {
|
if($replyJSON.length === 0) {
|
||||||
@@ -29,7 +29,8 @@ function get_active_typing_practice_app_list($maestro_id, $type) {
|
|||||||
$query = "
|
$query = "
|
||||||
SELECT A.AppID, A.AppName, A.KoreanName
|
SELECT A.AppID, A.AppName, A.KoreanName
|
||||||
FROM moty_app AS A
|
FROM moty_app AS A
|
||||||
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID = ? AND A.AppType = ?
|
INNER JOIN moty_active_app AS AA
|
||||||
|
ON A.AppID = AA.AppID AND AA.MaestroID = ? AND A.AppType = ?
|
||||||
ORDER BY A.AppID ASC";
|
ORDER BY A.AppID ASC";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('ii', $maestro_id, $type);
|
$stmt->bind_param('ii', $maestro_id, $type);
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
include "./../send_error_code.php";
|
||||||
|
|
||||||
|
$maestro_id = $_POST["maestro_id"];
|
||||||
|
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
|
||||||
|
$replyJSON["Korean"] = get_active_typing_practice_app_list($maestro_id, 11);
|
||||||
|
$replyJSON["English"] = get_active_typing_practice_app_list($maestro_id, 12);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
if($replyJSON.length === 0) {
|
||||||
|
send_error_message($replyJSON, "앱 목록 가져오기 실패");
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_active_typing_practice_app_list($maestro_id, $type) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT A.AppID, A.AppName, A.KoreanName
|
||||||
|
FROM moty_app AS A
|
||||||
|
INNER JOIN moty_active_app AS AA
|
||||||
|
ON A.AppID = AA.AppID AND AA.MaestroID = ? AND A.AppType = ?
|
||||||
|
ORDER BY A.AppID ASC";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('ii', $maestro_id, $type);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($app_id, $app_name, $korean_name);
|
||||||
|
|
||||||
|
$return_array = array();
|
||||||
|
while($stmt->fetch()) {
|
||||||
|
$row_array['AppID'] = $app_id;
|
||||||
|
$row_array['AppName'] = $app_name;
|
||||||
|
$row_array['KoreanName'] = $korean_name;
|
||||||
|
array_push($return_array, $row_array);
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $return_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user