Fix: multiAlphabets (incompleted)
This commit is contained in:
@@ -101,6 +101,14 @@ StringUtil.jungsung = function(letter) {
|
|||||||
return alphabets[1];
|
return alphabets[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringUtil.hasJongsung = function(letter) {
|
||||||
|
var alphabets = StringUtil.toKoreanAlphabets(letter);
|
||||||
|
if(alphabets.length == 3)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
StringUtil.jongsung = function(letter) {
|
StringUtil.jongsung = function(letter) {
|
||||||
if(!StringUtil.hasJongsung(letter))
|
if(!StringUtil.hasJongsung(letter))
|
||||||
return "";
|
return "";
|
||||||
@@ -115,7 +123,7 @@ StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
StringUtil.isMultiLetterJungsung = function(alphabet) {
|
StringUtil.isMultiAlphabetJungsung = function(alphabet) {
|
||||||
var cMultiJung = [ 'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ' ];
|
var cMultiJung = [ 'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ' ];
|
||||||
for(var i = 0; i < cMultiJung.length; i++) {
|
for(var i = 0; i < cMultiJung.length; i++) {
|
||||||
if(cMultiJung[i] == alphabet)
|
if(cMultiJung[i] == alphabet)
|
||||||
@@ -125,7 +133,7 @@ StringUtil.isMultiLetterJungsung = function(alphabet) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
StringUtil.getMultiAlphabetFromJungsung = function(alphabet) {
|
||||||
var multiJungsungList = new Object();
|
var multiJungsungList = new Object();
|
||||||
multiJungsungList['ㅘ'] = ['ㅗ', 'ㅏ'];
|
multiJungsungList['ㅘ'] = ['ㅗ', 'ㅏ'];
|
||||||
multiJungsungList['ㅙ'] = ['ㅗ', 'ㅐ'];
|
multiJungsungList['ㅙ'] = ['ㅗ', 'ㅐ'];
|
||||||
@@ -137,7 +145,7 @@ StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
|||||||
return multiJungsungList[alphabet];
|
return multiJungsungList[alphabet];
|
||||||
};
|
};
|
||||||
|
|
||||||
StringUtil.isMultiLetterJongsung = function(alphabet) {
|
StringUtil.isMultiAlphabetJongsung = function(alphabet) {
|
||||||
var cMultiJong = [ 'ㄲ', 'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ', 'ㅆ' ];
|
var cMultiJong = [ 'ㄲ', 'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ', 'ㅆ' ];
|
||||||
for(var i = 0; i < cMultiJong.length; i++) {
|
for(var i = 0; i < cMultiJong.length; i++) {
|
||||||
if(cMultiJong[i] == alphabet)
|
if(cMultiJong[i] == alphabet)
|
||||||
@@ -147,7 +155,7 @@ StringUtil.isMultiLetterJongsung = function(alphabet) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
StringUtil.getMultiAlphabetFromJongsung = function(alphabet) {
|
||||||
var multiJongsungList = new Object();
|
var multiJongsungList = new Object();
|
||||||
multiJongsungList['ㄲ'] = ['ㄱ', 'ㄱ'];
|
multiJongsungList['ㄲ'] = ['ㄱ', 'ㄱ'];
|
||||||
multiJongsungList['ㄳ'] = ['ㄱ', 'ㅅ'];
|
multiJongsungList['ㄳ'] = ['ㄱ', 'ㅅ'];
|
||||||
@@ -166,14 +174,6 @@ StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
|||||||
return multiJongsungList[alphabet];
|
return multiJongsungList[alphabet];
|
||||||
}
|
}
|
||||||
|
|
||||||
StringUtil.hasJongsung = function(alphabet) {
|
|
||||||
var alphabets = StringUtil.toKoreanAlphabets(alphabet);
|
|
||||||
if(alphabets.length == 3)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
|
StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
|
||||||
if(firstAlphabet == secondAlphabet)
|
if(firstAlphabet == secondAlphabet)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+151
-54
@@ -232,6 +232,7 @@ var TypingTest = {
|
|||||||
var typingTextMan = new TypingTextManager();
|
var typingTextMan = new TypingTextManager();
|
||||||
|
|
||||||
var typingPracticeContents = this.getTypingTestContents();
|
var typingPracticeContents = this.getTypingTestContents();
|
||||||
|
var typingPracticeContents = [ "꿰뚫다" , "워머신", "홧김에" ];
|
||||||
// console.log(typingPracticeContents);
|
// console.log(typingPracticeContents);
|
||||||
typingTextMan.makeTestContents(typingPracticeContents);
|
typingTextMan.makeTestContents(typingPracticeContents);
|
||||||
var wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
|
var wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
|
||||||
@@ -378,17 +379,22 @@ var TypingTest = {
|
|||||||
|
|
||||||
if(event.keyCode == Phaser.Keyboard.ENTER ||
|
if(event.keyCode == Phaser.Keyboard.ENTER ||
|
||||||
event.keyCode == Phaser.Keyboard.SPACEBAR) {
|
event.keyCode == Phaser.Keyboard.SPACEBAR) {
|
||||||
// console.log("### enter ###");
|
console.log("### enter ###");
|
||||||
// console.log("inputContent : " + inputContent);
|
console.log("this.typingIndex : " + this.typingIndex);
|
||||||
// console.log("typingContent : " + typingContent);
|
console.log("inputContent : " + inputContent);
|
||||||
|
console.log("typingContent : " + typingContent);
|
||||||
|
|
||||||
if(inputContent === typingContent) {
|
if(inputContent === typingContent) {
|
||||||
this.calculateTypingRecord(typingContent);
|
this.calculateTypingRecord(typingContent);
|
||||||
this.playNextContent();
|
|
||||||
|
|
||||||
if(this.typingIndex == this.typingContentLength)
|
console.log("this.typingIndex : " + this.typingIndex);
|
||||||
|
console.log("this.typingContentLength : " + this.typingContentLength);
|
||||||
|
if(this.typingIndex == this.typingContentLength - 1) {
|
||||||
this.gameOver();
|
this.gameOver();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.playNextContent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +433,7 @@ var TypingTest = {
|
|||||||
|
|
||||||
this.hideHighlightKey(this.highlightKey);
|
this.hideHighlightKey(this.highlightKey);
|
||||||
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
|
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
|
||||||
console.log(this.highlightKey);
|
// console.log(this.highlightKey);
|
||||||
this.showHighlightKey(this.highlightKey);
|
this.showHighlightKey(this.highlightKey);
|
||||||
this.moveHands(this.highlightKey);
|
this.moveHands(this.highlightKey);
|
||||||
},
|
},
|
||||||
@@ -435,6 +441,9 @@ var TypingTest = {
|
|||||||
getHighlioghtKey: function(inputContent, typingContent) {
|
getHighlioghtKey: function(inputContent, typingContent) {
|
||||||
var highlightKey = "";
|
var highlightKey = "";
|
||||||
|
|
||||||
|
if(typingContent == undefined)
|
||||||
|
return undefined;
|
||||||
|
|
||||||
var inputLength = inputContent.length;
|
var inputLength = inputContent.length;
|
||||||
var typingLength = typingContent.length;
|
var typingLength = typingContent.length;
|
||||||
// console.log("inputLength : " + inputLength + " / " + inputContent);
|
// console.log("inputLength : " + inputLength + " / " + inputContent);
|
||||||
@@ -474,10 +483,10 @@ var TypingTest = {
|
|||||||
var typingLetter = "";
|
var typingLetter = "";
|
||||||
var typingNextLetter = "";
|
var typingNextLetter = "";
|
||||||
|
|
||||||
console.log("-----");
|
// console.log("-----");
|
||||||
console.log("inputConent : '" + inputContent + "'");
|
// console.log("inputConent : '" + inputContent + "'");
|
||||||
console.log("inputIndex : " + inputIndex);
|
// console.log("inputIndex : " + inputIndex);
|
||||||
console.log("misspelledIndex : " + misspelledIndex);
|
// console.log("misspelledIndex : " + misspelledIndex);
|
||||||
|
|
||||||
if(inputIndex < 0)
|
if(inputIndex < 0)
|
||||||
inputLetter = "";
|
inputLetter = "";
|
||||||
@@ -486,70 +495,157 @@ var TypingTest = {
|
|||||||
else
|
else
|
||||||
inputLetter = inputContent[misspelledIndex];
|
inputLetter = inputContent[misspelledIndex];
|
||||||
typingLetter = typingContent[misspelledIndex];
|
typingLetter = typingContent[misspelledIndex];
|
||||||
if(inputContent.length < typingContent.length)
|
if(misspelledIndex <= typingContent.length)
|
||||||
typingNextLetter = typingContent[misspelledIndex + 1];
|
typingNextLetter = typingContent[misspelledIndex + 1];
|
||||||
|
|
||||||
console.log("inputLetter : '" + inputLetter + "'");
|
// console.log("inputLetter : '" + inputLetter + "'");
|
||||||
console.log("typingLetter : '" + typingLetter + "'");
|
// console.log("typingLetter : '" + typingLetter + "'");
|
||||||
console.log("typingNextLetter : '" + typingNextLetter + "'");
|
// console.log("typingNextLetter : '" + typingNextLetter + "'");
|
||||||
|
|
||||||
var typingAlphabet = "";
|
// var typingAlphabet = "";
|
||||||
var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputLetter);
|
var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputLetter);
|
||||||
var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingLetter);
|
// var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingLetter);
|
||||||
var typingNextLetterAlphabets = StringUtil.toKoreanAlphabets(typingNextLetter);
|
// var typingNextLetterAlphabets = StringUtil.toKoreanAlphabets(typingNextLetter);
|
||||||
console.log("inputLetterAlphabets : " + inputLetterAlphabets);
|
// console.log("inputLetterAlphabets : " + inputLetterAlphabets);
|
||||||
console.log("typingLetterAlphabets : " + typingLetterAlphabets);
|
// console.log("typingLetterAlphabets : " + typingLetterAlphabets);
|
||||||
console.log("typingNextLetterAlphabets : " + typingNextLetterAlphabets);
|
// console.log("typingNextLetterAlphabets : " + typingNextLetterAlphabets);
|
||||||
|
|
||||||
|
// typing nothing yet
|
||||||
if(inputLetterAlphabets.length == 0) {
|
if(inputLetterAlphabets.length == 0) {
|
||||||
highlightKey = typingLetterAlphabets[0];
|
// highlightKey = typingLetterAlphabets[0];
|
||||||
|
highlightKey = StringUtil.chosung(typingLetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// after typing chosung
|
||||||
else if(inputLetterAlphabets.length == 1) {
|
else if(inputLetterAlphabets.length == 1) {
|
||||||
if(inputLetterAlphabets[0] != typingLetterAlphabets[0])
|
if(StringUtil.chosung(inputLetter) != StringUtil.chosung(typingLetter))
|
||||||
highlightKey = "Backspace";
|
highlightKey = "Backspace";
|
||||||
else
|
|
||||||
highlightKey = typingLetterAlphabets[1];
|
|
||||||
}
|
|
||||||
else if(inputLetterAlphabets.length == 2) {
|
|
||||||
if(StringUtil.isMultiLetterJongsung(typingLetterAlphabets[1])) {
|
|
||||||
var jungsungAlphabets = StringUtil.getMultiLettersFromJongsung(typingLetterAlphabets[1]);
|
|
||||||
if(inputLetterAlphabets[1] == jungsungAlphabets[0])
|
|
||||||
highlightKey = jungsungAlphabets[1];
|
|
||||||
else
|
|
||||||
highlightKey = "Backspace";
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if(inputLetterAlphabets[1] != typingLetterAlphabets[1])
|
if(StringUtil.isMultiAlphabetJungsung(StringUtil.jungsung(typingLetter))) {
|
||||||
highlightKey = "Backspace";
|
// console.log("* multi jungsung");
|
||||||
else {
|
var jungsungLetter = StringUtil.jungsung(typingLetter);
|
||||||
if(typingLetterAlphabets.length == 3)
|
// console.log("jungsungLetter : " + jungsungLetter);
|
||||||
highlightKey = typingLetterAlphabets[2];
|
jungsungAlphabets = StringUtil.getMultiAlphabetFromJungsung(jungsungLetter);
|
||||||
else
|
// console.log("jungsungAlphabets : " + jungsungAlphabets);
|
||||||
highlightKey = typingNextLetterAlphabets[0];
|
highlightKey = jungsungAlphabets[0];
|
||||||
|
// console.log(highlightKey);
|
||||||
|
} else {
|
||||||
|
// console.log("* single jungsung");
|
||||||
|
highlightKey = StringUtil.jungsung(typingLetter);
|
||||||
|
// console.log(highlightKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(inputLetterAlphabets.length == 3) {
|
|
||||||
if(StringUtil.hasJongsung(typingLetterAlphabet)) {
|
// after typing jungsung
|
||||||
if(inputLetterAlphabets[2] == typingLetterAlphabets[2])
|
else if(inputLetterAlphabets.length == 2) {
|
||||||
highlightKey = typingNextLetterAlphabet[0]; // next letter chosung
|
var typingLetterJungsung = StringUtil.jungsung(typingLetter);
|
||||||
|
// console.log("* 222");
|
||||||
|
// inputLetter jungsung == typingLetter jungsung
|
||||||
|
if(StringUtil.jungsung(inputLetter) == StringUtil.jungsung(typingLetter)) {
|
||||||
|
if(StringUtil.hasJongsung(typingLetter)) {
|
||||||
|
// highlightKey = StringUtil.jongsung(typingLetter);
|
||||||
|
var typingLetterJongsung = StringUtil.jongsung(typingLetter);
|
||||||
|
// typingLetter jongsung is multi alphabet
|
||||||
|
if(StringUtil.isMultiAlphabetJongsung(typingLetterJongsung)) {
|
||||||
|
var typingJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(typingLetter));
|
||||||
|
highlightKey = typingJongsungAlphabets[0];
|
||||||
|
}
|
||||||
|
// typingLetter jongsung is single alphabet
|
||||||
|
else {
|
||||||
|
highlightKey = typingLetterJongsung;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
highlightKey = StringUtil.chosung(typingNextLetter);
|
||||||
|
}
|
||||||
|
// inputLetter jungsung != typingLetter jungsung
|
||||||
|
else {
|
||||||
|
if(StringUtil.isMultiAlphabetJungsung(typingLetterJungsung)) {
|
||||||
|
// console.log("* multi jungsung");
|
||||||
|
var jungsungAlphabets = StringUtil.getMultiAlphabetFromJungsung(typingLetterJungsung);
|
||||||
|
// console.log(" * jungsungAlphabets : " + jungsungAlphabets);
|
||||||
|
if(StringUtil.jungsung(inputLetter) == jungsungAlphabets[0])
|
||||||
|
highlightKey = jungsungAlphabets[1];
|
||||||
|
else
|
||||||
|
highlightKey = "Backspace";
|
||||||
|
}
|
||||||
|
// single letter jungsung
|
||||||
else {
|
else {
|
||||||
// 알바 -> 앏
|
// console.log("* single jungsung");
|
||||||
if(StringUtil.isMultiLetterJongsung(inputLetterAlphabets[2])) {
|
if(StringUtil.jungsung(inputLetter) != typingLetterJungsung)
|
||||||
var jongsungAlphabets = StringUtil.getMultiLettersFromJongsung(inputLetterAlphabets[2]);
|
highlightKey = "Backspace";
|
||||||
if(typingLetterAlphabet[2] == jongsungAlphabets[0] && typingNextLetterAlphabet[0] == jongsungAlphabets[1])
|
else {
|
||||||
highlightKey = typingNextLetterAlphabet[1]; // next letter jungsung
|
if(StringUtil.hasJongsung(typingLetter)) {
|
||||||
|
// highlightKey = StringUtil.jongsung(typingLetter);
|
||||||
|
var typingLetterJongsung = StringUtil.jongsung(typingLetter);
|
||||||
|
if(StringUtil.isMultiAlphabetJongsung(typingLetterJongsung)) {
|
||||||
|
var jongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(inputLetter));
|
||||||
|
if(StringUtil.jongsung(typingLetter) == jongsungAlphabets[0] && StringUtil.chosung(typingNextLetter) == jongsungAlphabets[1])
|
||||||
|
highlightKey = StringUtil.jungsung(typingNextLetter);
|
||||||
|
else if(StringUtil.jongsung(inputLetter) == jongsungAlphabets[0])
|
||||||
|
highlightKey = jongsungAlphabets[1];
|
||||||
|
else
|
||||||
|
highlightKey = "Backspace";
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
highlightKey = StringUtil.chosung(typingNextLetter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// after typing jongsung
|
||||||
|
else if(inputLetterAlphabets.length == 3) {
|
||||||
|
// 입력할 글자에 종성이 있을 경우
|
||||||
|
if(StringUtil.hasJongsung(typingLetter)) {
|
||||||
|
var typingLetterJongsung = StringUtil.jongsung(typingLetter);
|
||||||
|
// 입력한 글자의 종성과 입력할 글자의 종성이 같은 경우
|
||||||
|
if(StringUtil.jongsung(inputLetter) == typingLetterJongsung)
|
||||||
|
highlightKey = StringUtil.chosung(typingNextLetter);
|
||||||
|
// 입력한 글자의 종성이 입력할 글자와 다를 경우
|
||||||
|
else {
|
||||||
|
var inputJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(inputLetter));
|
||||||
|
var typingJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(typingLetter));
|
||||||
|
// 입력할 글자의 종성이 합성자음일 경우
|
||||||
|
if(StringUtil.isMultiAlphabetJongsung(typingLetterJongsung)) {
|
||||||
|
// 입력할 글자의 종성과 입력한 글자의 종성이 같은 경우
|
||||||
|
if(typingLetterJongsung == StringUtil.jongsung(inputLetter))
|
||||||
|
highlightKey = StringUtil.chosung(typingNextLetter);
|
||||||
|
else if(StringUtil.jongsung(inputLetter) == typingJongsungAlphabets[0])
|
||||||
|
highlightKey = typingJongsungAlphabets[1];
|
||||||
|
else
|
||||||
|
highlightKey = "Backspace";
|
||||||
|
}
|
||||||
|
// 입력할 글자의 종성이 단자음일 경우 : 알바 -> 앏
|
||||||
|
else {
|
||||||
|
if(StringUtil.jongsung(typingLetter) == inputJongsungAlphabets[0] && StringUtil.chosung(typingNextLetter) == inputJongsungAlphabets[1])
|
||||||
|
highlightKey = StringUtil.jungsung(typingNextLetter);
|
||||||
|
// else if(StringUtil.jongsung(inputLetter) == inputJongsungAlphabets[0])
|
||||||
|
// highlightKey = inputJongsungAlphabets[1];
|
||||||
else
|
else
|
||||||
highlightKey = "Backspace";
|
highlightKey = "Backspace";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// console.log("inputLetter jongsung : " + StringUtil.jongsung(inputLetter))
|
||||||
highlightKey = "`";
|
// console.log("typingNextLetter chosung : " + StringUtil.chosung(typingNextLetter))
|
||||||
|
if(StringUtil.jongsung(inputLetter) == StringUtil.chosung(typingNextLetter)) {
|
||||||
|
// highlightKey = StringUtil.jungsung(typingNextLetter);
|
||||||
|
if(StringUtil.isMultiAlphabetJungsung(StringUtil.jungsung(typingNextLetter))) {
|
||||||
|
// console.log("* multi jungsung");
|
||||||
|
jungsungAlphabets = StringUtil.getMultiAlphabetFromJungsung(StringUtil.jungsung(typingNextLetter));
|
||||||
|
highlightKey = jungsungAlphabets[0];
|
||||||
|
// console.log(highlightKey);
|
||||||
|
} else {
|
||||||
|
// console.log("* single jungsung");
|
||||||
|
highlightKey = StringUtil.jungsung(typingNextLetter);
|
||||||
|
// console.log(highlightKey);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
highlightKey = "Backspace";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// highlightKey = "ㄱ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,6 +746,7 @@ var TypingTest = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
playNextContent: function() {
|
playNextContent: function() {
|
||||||
|
console.log("playNextContent()");
|
||||||
this.typingIndex++;
|
this.typingIndex++;
|
||||||
this.showTypingTestContents();
|
this.showTypingTestContents();
|
||||||
this.showPlayingWordNumber();
|
this.showPlayingWordNumber();
|
||||||
|
|||||||
Reference in New Issue
Block a user