Add: practice alphabet
This commit is contained in:
@@ -51,13 +51,13 @@ class TypingPractice {
|
||||
.addColor(textPreviewColor[0], 0);
|
||||
|
||||
|
||||
let keyMapper = null;
|
||||
if(sessionStorageManager.playingAppName.indexOf("korean") > 0)
|
||||
keyMapper = new KoreanKeyMapper();
|
||||
else
|
||||
keyMapper = new EnglishKeyMapper();
|
||||
this.keyMapper = new KeyMapper();
|
||||
new Keyboard(this.keyMapper);
|
||||
|
||||
new Keyboard(keyMapper);
|
||||
game.input.keyboard.processKeyPress = () => {
|
||||
self.checkTypingContents(event);
|
||||
}
|
||||
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
|
||||
|
||||
|
||||
/*
|
||||
@@ -85,7 +85,7 @@ class TypingPractice {
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
|
||||
|
||||
// this.startGame();
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
|
||||
@@ -101,26 +101,36 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
goResult() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||
this.textTypingContent.text = "= 연습 끝 =";
|
||||
/*
|
||||
sessionStorageManager.record = this.typingRecordTotal;
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
*/
|
||||
}
|
||||
|
||||
initTypingData() {
|
||||
this.typingContents = this.getTypingPracticeContents();
|
||||
console.log(this.typingContents);
|
||||
let randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
console.log(randomContents);
|
||||
this.wordCountForStage = TypingPractice.WORD_COUNT_FOR_STAGE;
|
||||
if(isDebugMode())
|
||||
this.wordCountForStage = 3;
|
||||
this.typingRandomContents = randomContents.slice(1, this.wordCountForStage + 1); // start Num, end Num (not index)
|
||||
console.log(this.typingRandomContents);
|
||||
this.typingContentLength = this.typingContents.length;
|
||||
this.typingIndex = 0;
|
||||
|
||||
|
||||
|
||||
this.isTyping = false;
|
||||
this.timeTypingStart = 0;
|
||||
this.timeTypingEnd = 0;
|
||||
// this.timeTypingStart = 0;
|
||||
// this.timeTypingEnd = 0;
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
@@ -128,22 +138,48 @@ class TypingPractice {
|
||||
|
||||
|
||||
getTypingPracticeContents() {
|
||||
let TypingPracticeContents = this.loadTestContent();
|
||||
let TypingPracticeContents = this.loadPracticeContent();
|
||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||
// console.log('TypingPracticeContents : ' + TypingPracticeContents);
|
||||
|
||||
this.typingRecordForLines = [];
|
||||
this.typingElapsedTime = [];
|
||||
for(let i = 0; i < TypingPracticeContents.length; i++) {
|
||||
this.typingRecordForLines[i] = 0;
|
||||
this.typingElapsedTime[i] = 0;
|
||||
}
|
||||
// this.typingRecordForLines = [];
|
||||
// this.typingElapsedTime = [];
|
||||
// for(let i = 0; i < TypingPracticeContents.length; i++) {
|
||||
// this.typingRecordForLines[i] = 0;
|
||||
// this.typingElapsedTime[i] = 0;
|
||||
// }
|
||||
|
||||
return TypingPracticeContents;
|
||||
}
|
||||
|
||||
loadTestContent() {
|
||||
loadTemporaryContent() {
|
||||
testContent = [
|
||||
"ㅃ",
|
||||
"ㅂ",
|
||||
"ㅈ",
|
||||
"ㅉ",
|
||||
"ㄸ",
|
||||
"ㄷ",
|
||||
"ㄱ",
|
||||
"ㄲ",
|
||||
"ㅅ"
|
||||
];
|
||||
// testContent = [
|
||||
// "a",
|
||||
// "s",
|
||||
// "d",
|
||||
// "f",
|
||||
// "j",
|
||||
// "k",
|
||||
// "l",
|
||||
// ";",
|
||||
// "'"
|
||||
// ];
|
||||
return testContent;
|
||||
}
|
||||
|
||||
loadPracticeContent() {
|
||||
let appName = "";
|
||||
if(isTypingTestStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(5);
|
||||
@@ -213,40 +249,87 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
showTypingPracticeContents() {
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
this.textTypingRecordsDone[i].text = "";
|
||||
} else {
|
||||
this.textTypingContentsDone[i].text = this.typingRandomContents[doneIndex];
|
||||
this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]);
|
||||
}
|
||||
}
|
||||
let doneIndex = this.typingIndex - 1;
|
||||
if(doneIndex < 0)
|
||||
this.textTypingContentsDone.text = "";
|
||||
else
|
||||
this.textTypingContentsDone.text = this.typingRandomContents[doneIndex];
|
||||
// for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
// let doneIndex = this.typingIndex - i - 1;
|
||||
// if(doneIndex < 0) {
|
||||
// this.textTypingContentsDone.text = "";
|
||||
// } else {
|
||||
// this.textTypingContentsDone.text = this.typingRandomContents[doneIndex];
|
||||
// }
|
||||
// }
|
||||
|
||||
if(this.typingIndex == this.wordCountForStage) {
|
||||
if(this.typingIndex === this.wordCountForStage) {
|
||||
this.textTypingContent.text = "";
|
||||
return;
|
||||
}
|
||||
|
||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
let previewIndex = this.typingIndex + i + 1;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
let previewIndex = this.typingIndex + 1;
|
||||
if(previewIndex > this.typingRandomContents.length - 1)
|
||||
this.textTypingContentPreview.text = "";
|
||||
else
|
||||
this.textTypingContentPreview.text = this.typingRandomContents[previewIndex];
|
||||
// for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
// let previewIndex = this.typingIndex + i + 1;
|
||||
// if(previewIndex < this.typingRandomContents.length)
|
||||
// this.textTypingContentPreview.text = this.typingRandomContents[previewIndex];
|
||||
// else
|
||||
// this.textTypingContentPreview.text = "";
|
||||
// }
|
||||
}
|
||||
|
||||
/*
|
||||
resetTypingContent() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_WRONG, 0);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
getKeyCode(text) {
|
||||
return this.keyMapper.getKeyIDOfText(text);
|
||||
}
|
||||
|
||||
isKeyPressed(inputContent, typingContent) {
|
||||
let inputContentKeyCode = this.getKeyCode(inputContent);
|
||||
let typingContentKeyCode = this.getKeyCode(typingContent);
|
||||
|
||||
if(inputContentKeyCode !== typingContentKeyCode)
|
||||
return false;
|
||||
|
||||
let isShiftInputContent = this.shiftKey.isDown;
|
||||
let isShiftTypingContent = this.keyMapper.isShiftText(typingContent);
|
||||
|
||||
if(isShiftInputContent !== isShiftTypingContent)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
checkTypingContents(evnet) {
|
||||
let inputContent = event.key;
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
// if(this.getKeyCode(inputContent) === this.getKeyCode(typingContent)
|
||||
// && this.getShiftTypeOfText(inputContent) === this.getShiftTypeOfText(typingContent)) {
|
||||
// console.log("correct key");
|
||||
// }
|
||||
|
||||
// if(shiftKey.isDown)
|
||||
// console.log(this.shiftKey);
|
||||
if(this.isKeyPressed(inputContent, typingContent)) {
|
||||
this.playNextContent();
|
||||
|
||||
if(this.typingIndex === this.wordCountForStage) {
|
||||
this.goResult();
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
// console.log("### enter ###");
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
@@ -270,8 +353,10 @@ class TypingPractice {
|
||||
|
||||
this.showTypingContentHighlight();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
showTypingContentHighlight() {
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
@@ -293,7 +378,9 @@ class TypingPractice {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
calculateTypingRecord(typingContent) {
|
||||
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
|
||||
|
||||
@@ -310,17 +397,17 @@ class TypingPractice {
|
||||
|
||||
let typingRecord = (typingContentPlusEnterCount + TypingPractice.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||
|
||||
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
||||
// this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
||||
this.typingLetterCountTotal += typingContentPlusEnterCount;
|
||||
this.typingRecordForLines[this.typingIndex] = typingRecord;
|
||||
// this.typingRecordForLines[this.typingIndex] = typingRecord;
|
||||
// console.log(this.typingRecordForLines[this.typingIndex]);
|
||||
|
||||
let typingElapsedTimeTotal = 0;
|
||||
for(let i = 0; i <= this.typingIndex; i++) {
|
||||
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
|
||||
typingElapsedTimeTotal += this.typingElapsedTime[i];
|
||||
}
|
||||
this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
|
||||
// let typingElapsedTimeTotal = 0;
|
||||
// for(let i = 0; i <= this.typingIndex; i++) {
|
||||
// // console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
|
||||
// typingElapsedTimeTotal += this.typingElapsedTime[i];
|
||||
// }
|
||||
// this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
|
||||
// console.log(this.typingLetterCountTotal);
|
||||
// console.log(typingElapsedTimeTotal);
|
||||
// console.log(typingRecordTotal);
|
||||
@@ -331,18 +418,20 @@ class TypingPractice {
|
||||
// console.log('typingRecordTotal : ' + typingRecordTotal);
|
||||
// console.log('-----------------------------------');
|
||||
}
|
||||
*/
|
||||
|
||||
playNextContent() {
|
||||
this.typingIndex++;
|
||||
this.showTypingPracticeContents();
|
||||
this.showPlayingWordNumber();
|
||||
this.resetTypingContent();
|
||||
// this.resetTypingContent();
|
||||
}
|
||||
|
||||
showPlayingWordNumber() {
|
||||
this.contentProgressText.print(this.typingIndex + 1, this.wordCountForStage);
|
||||
}
|
||||
|
||||
/*
|
||||
setTimeTypingStart() {
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
let timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
@@ -356,6 +445,7 @@ class TypingPractice {
|
||||
|
||||
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user