Add: test and practice
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/////////////////////////////
|
||||
// Typing Test
|
||||
// TypingTest
|
||||
|
||||
class Test {
|
||||
class TypingTest {
|
||||
|
||||
create() {
|
||||
self = this;
|
||||
@@ -14,7 +14,8 @@ class Test {
|
||||
// top
|
||||
let backButton = new BackButton( () => {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
|
||||
location.href = '../../web/client/menu_typing_test.html';
|
||||
});
|
||||
|
||||
this.averageTypingSpeedText = new AverageTypingSpeed();
|
||||
@@ -29,7 +30,7 @@ class Test {
|
||||
bar.beginFill(0x000000, 0.2);
|
||||
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
|
||||
|
||||
if(this.isWordStage())
|
||||
if(isTypingWordStage())
|
||||
textStyleBasic.font = "bold 84px Arial";
|
||||
else // Sentence stage
|
||||
textStyleBasic.font = "bold 48px Arial";
|
||||
@@ -37,21 +38,21 @@ class Test {
|
||||
this.textTypingContent = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120)
|
||||
.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";
|
||||
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
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)
|
||||
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
|
||||
var scorePositionX = 780;
|
||||
if(this.isWordStage())
|
||||
if(isTypingWordStage())
|
||||
scorePositionX = 600;
|
||||
|
||||
this.textTypingRecordsDone[i] = game.add.text(0, 2, "", textStyleBasic)
|
||||
@@ -63,7 +64,7 @@ class Test {
|
||||
|
||||
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
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)
|
||||
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
@@ -148,13 +149,13 @@ class Test {
|
||||
}
|
||||
|
||||
initTypingData() {
|
||||
this.typingTestContents = this.getTypingTestContents();
|
||||
var randomContents = Phaser.ArrayUtils.shuffle(this.typingTestContents);
|
||||
this.wordCountForStage = Test.WORD_COUNT_FOR_STAGE;
|
||||
this.typingContents = this.getTypingTestContents();
|
||||
var randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
this.wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
|
||||
if(isDebugMode())
|
||||
this.wordCountForStage = 3;
|
||||
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.isTyping = false;
|
||||
@@ -185,16 +186,20 @@ class Test {
|
||||
loadTestContent() {
|
||||
var testContent = [];
|
||||
switch(sessionStorageManager.playingAppName) {
|
||||
case "korean_word":
|
||||
case "test_korean_word":
|
||||
case "practice_korean_word":
|
||||
testContent = koreanWordList;
|
||||
break;
|
||||
case "korean_sentence":
|
||||
case "test_korean_sentence":
|
||||
case "practice_korean_sentence":
|
||||
testContent = koreanSentenceList;
|
||||
break;
|
||||
case "english_word":
|
||||
case "test_english_word":
|
||||
case "practice_english_word":
|
||||
testContent = englishWordList;
|
||||
break;
|
||||
case "english_sentence":
|
||||
case "test_english_sentence":
|
||||
case "practice_english_sentence":
|
||||
testContent = englishSentenceList;
|
||||
break;
|
||||
}
|
||||
@@ -202,12 +207,8 @@ class Test {
|
||||
return testContent;
|
||||
}
|
||||
|
||||
isWordStage() {
|
||||
return ( (sessionStorageManager.playingAppID % 10) === 0 );
|
||||
}
|
||||
|
||||
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;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
@@ -225,7 +226,7 @@ class Test {
|
||||
|
||||
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;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
@@ -236,7 +237,7 @@ class Test {
|
||||
|
||||
resetTypingContent() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(Test.COLOR_CONTENT_WRONG, 0);
|
||||
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_WRONG, 0);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ class Test {
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(Test.COLOR_CONTENT_RIGHT, 0);
|
||||
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_RIGHT, 0);
|
||||
|
||||
if(typingContent == null)
|
||||
return;
|
||||
@@ -282,7 +283,7 @@ class Test {
|
||||
// console.log("inputContent.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;
|
||||
}
|
||||
}
|
||||
@@ -300,9 +301,9 @@ class Test {
|
||||
|
||||
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||
// 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.typingLetterCountTotal += typingContentPlusEnterCount;
|
||||
@@ -356,17 +357,17 @@ class Test {
|
||||
}
|
||||
|
||||
|
||||
Test.TYPING_CONTENT_PREVIEW_COUNT = 3;
|
||||
Test.TYPING_CONTENT_DONE_COUNT = 3;
|
||||
Test.TYPING_COUNT_PLUS_ENTER = 1;
|
||||
TypingTest.TYPING_CONTENT_PREVIEW_COUNT = 3;
|
||||
TypingTest.TYPING_CONTENT_DONE_COUNT = 3;
|
||||
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())
|
||||
// WORD_COUNT_FOR_STAGE = 3;
|
||||
|
||||
Test.COLOR_CONTENT_WRONG = "#aaaaaa";
|
||||
Test.COLOR_CONTENT_RIGHT = "#ffff4d";
|
||||
TypingTest.COLOR_CONTENT_WRONG = "#aaaaaa";
|
||||
TypingTest.COLOR_CONTENT_RIGHT = "#ffff4d";
|
||||
|
||||
|
||||
|
||||
@@ -81,11 +81,11 @@ class Loading {
|
||||
// this.preloadBar.alpha = 1;
|
||||
|
||||
if(isDebugMode()) {
|
||||
this.state.start('Test');
|
||||
this.state.start('TypingTest');
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.start('Test');
|
||||
this.state.start('TypingTest');
|
||||
// this.startMenu();
|
||||
// this.startTypingTestStage();
|
||||
// this.startTypingTestResult();
|
||||
|
||||
@@ -12,5 +12,5 @@ let game = new Phaser.Game(
|
||||
game.state.add('Loading', Loading);
|
||||
game.state.start('Loading');
|
||||
|
||||
game.state.add('Test', Test);
|
||||
game.state.add('TypingTest', TypingTest);
|
||||
// game.state.add('Menu', Menu);
|
||||
|
||||
Reference in New Issue
Block a user