Fix: multiAlphabets (incompleted)

This commit is contained in:
2019-05-16 22:12:36 +09:00
parent 45ac1035a3
commit a54f7d30c0
2 changed files with 163 additions and 66 deletions
+12 -12
View File
@@ -101,6 +101,14 @@ StringUtil.jungsung = function(letter) {
return alphabets[1];
}
StringUtil.hasJongsung = function(letter) {
var alphabets = StringUtil.toKoreanAlphabets(letter);
if(alphabets.length == 3)
return true;
return false;
};
StringUtil.jongsung = function(letter) {
if(!StringUtil.hasJongsung(letter))
return "";
@@ -115,7 +123,7 @@ StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
return false;
};
StringUtil.isMultiLetterJungsung = function(alphabet) {
StringUtil.isMultiAlphabetJungsung = function(alphabet) {
var cMultiJung = [ 'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ' ];
for(var i = 0; i < cMultiJung.length; i++) {
if(cMultiJung[i] == alphabet)
@@ -125,7 +133,7 @@ StringUtil.isMultiLetterJungsung = function(alphabet) {
return false;
};
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
StringUtil.getMultiAlphabetFromJungsung = function(alphabet) {
var multiJungsungList = new Object();
multiJungsungList['ㅘ'] = ['ㅗ', 'ㅏ'];
multiJungsungList['ㅙ'] = ['ㅗ', 'ㅐ'];
@@ -137,7 +145,7 @@ StringUtil.getMultiLettersFromJongsung = function(alphabet) {
return multiJungsungList[alphabet];
};
StringUtil.isMultiLetterJongsung = function(alphabet) {
StringUtil.isMultiAlphabetJongsung = function(alphabet) {
var cMultiJong = [ 'ㄲ', 'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ', 'ㅆ' ];
for(var i = 0; i < cMultiJong.length; i++) {
if(cMultiJong[i] == alphabet)
@@ -147,7 +155,7 @@ StringUtil.isMultiLetterJongsung = function(alphabet) {
return false;
};
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
StringUtil.getMultiAlphabetFromJongsung = function(alphabet) {
var multiJongsungList = new Object();
multiJongsungList['ㄲ'] = ['ㄱ', 'ㄱ'];
multiJongsungList['ㄳ'] = ['ㄱ', 'ㅅ'];
@@ -166,14 +174,6 @@ StringUtil.getMultiLettersFromJongsung = function(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) {
if(firstAlphabet == secondAlphabet)
return true;
+151 -54
View File
@@ -232,6 +232,7 @@ var TypingTest = {
var typingTextMan = new TypingTextManager();
var typingPracticeContents = this.getTypingTestContents();
var typingPracticeContents = [ "꿰뚫다" , "워머신", "홧김에" ];
// console.log(typingPracticeContents);
typingTextMan.makeTestContents(typingPracticeContents);
var wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
@@ -378,17 +379,22 @@ var TypingTest = {
if(event.keyCode == Phaser.Keyboard.ENTER ||
event.keyCode == Phaser.Keyboard.SPACEBAR) {
// console.log("### enter ###");
// console.log("inputContent : " + inputContent);
// console.log("typingContent : " + typingContent);
console.log("### enter ###");
console.log("this.typingIndex : " + this.typingIndex);
console.log("inputContent : " + inputContent);
console.log("typingContent : " + typingContent);
if(inputContent === 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();
return;
}
this.playNextContent();
return;
}
}
@@ -427,7 +433,7 @@ var TypingTest = {
this.hideHighlightKey(this.highlightKey);
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
console.log(this.highlightKey);
// console.log(this.highlightKey);
this.showHighlightKey(this.highlightKey);
this.moveHands(this.highlightKey);
},
@@ -435,6 +441,9 @@ var TypingTest = {
getHighlioghtKey: function(inputContent, typingContent) {
var highlightKey = "";
if(typingContent == undefined)
return undefined;
var inputLength = inputContent.length;
var typingLength = typingContent.length;
// console.log("inputLength : " + inputLength + " / " + inputContent);
@@ -474,10 +483,10 @@ var TypingTest = {
var typingLetter = "";
var typingNextLetter = "";
console.log("-----");
console.log("inputConent : '" + inputContent + "'");
console.log("inputIndex : " + inputIndex);
console.log("misspelledIndex : " + misspelledIndex);
// console.log("-----");
// console.log("inputConent : '" + inputContent + "'");
// console.log("inputIndex : " + inputIndex);
// console.log("misspelledIndex : " + misspelledIndex);
if(inputIndex < 0)
inputLetter = "";
@@ -486,70 +495,157 @@ var TypingTest = {
else
inputLetter = inputContent[misspelledIndex];
typingLetter = typingContent[misspelledIndex];
if(inputContent.length < typingContent.length)
if(misspelledIndex <= typingContent.length)
typingNextLetter = typingContent[misspelledIndex + 1];
console.log("inputLetter : '" + inputLetter + "'");
console.log("typingLetter : '" + typingLetter + "'");
console.log("typingNextLetter : '" + typingNextLetter + "'");
// console.log("inputLetter : '" + inputLetter + "'");
// console.log("typingLetter : '" + typingLetter + "'");
// console.log("typingNextLetter : '" + typingNextLetter + "'");
var typingAlphabet = "";
// var typingAlphabet = "";
var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputLetter);
var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingLetter);
var typingNextLetterAlphabets = StringUtil.toKoreanAlphabets(typingNextLetter);
console.log("inputLetterAlphabets : " + inputLetterAlphabets);
console.log("typingLetterAlphabets : " + typingLetterAlphabets);
console.log("typingNextLetterAlphabets : " + typingNextLetterAlphabets);
// var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingLetter);
// var typingNextLetterAlphabets = StringUtil.toKoreanAlphabets(typingNextLetter);
// console.log("inputLetterAlphabets : " + inputLetterAlphabets);
// console.log("typingLetterAlphabets : " + typingLetterAlphabets);
// console.log("typingNextLetterAlphabets : " + typingNextLetterAlphabets);
// typing nothing yet
if(inputLetterAlphabets.length == 0) {
highlightKey = typingLetterAlphabets[0];
// highlightKey = typingLetterAlphabets[0];
highlightKey = StringUtil.chosung(typingLetter);
}
// after typing chosung
else if(inputLetterAlphabets.length == 1) {
if(inputLetterAlphabets[0] != typingLetterAlphabets[0])
if(StringUtil.chosung(inputLetter) != StringUtil.chosung(typingLetter))
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 {
if(inputLetterAlphabets[1] != typingLetterAlphabets[1])
highlightKey = "Backspace";
else {
if(typingLetterAlphabets.length == 3)
highlightKey = typingLetterAlphabets[2];
else
highlightKey = typingNextLetterAlphabets[0];
if(StringUtil.isMultiAlphabetJungsung(StringUtil.jungsung(typingLetter))) {
// console.log("* multi jungsung");
var jungsungLetter = StringUtil.jungsung(typingLetter);
// console.log("jungsungLetter : " + jungsungLetter);
jungsungAlphabets = StringUtil.getMultiAlphabetFromJungsung(jungsungLetter);
// console.log("jungsungAlphabets : " + jungsungAlphabets);
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)) {
if(inputLetterAlphabets[2] == typingLetterAlphabets[2])
highlightKey = typingNextLetterAlphabet[0]; // next letter chosung
// after typing jungsung
else if(inputLetterAlphabets.length == 2) {
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 {
// 알바 -> 앏
if(StringUtil.isMultiLetterJongsung(inputLetterAlphabets[2])) {
var jongsungAlphabets = StringUtil.getMultiLettersFromJongsung(inputLetterAlphabets[2]);
if(typingLetterAlphabet[2] == jongsungAlphabets[0] && typingNextLetterAlphabet[0] == jongsungAlphabets[1])
highlightKey = typingNextLetterAlphabet[1]; // next letter jungsung
// console.log("* single jungsung");
if(StringUtil.jungsung(inputLetter) != typingLetterJungsung)
highlightKey = "Backspace";
else {
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
highlightKey = "Backspace";
}
}
}
highlightKey = "`";
else {
// console.log("inputLetter jongsung : " + StringUtil.jongsung(inputLetter))
// 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() {
console.log("playNextContent()");
this.typingIndex++;
this.showTypingTestContents();
this.showPlayingWordNumber();