Files
chocomae/src/game/typing/examination/game.js
T
2019-09-15 19:25:40 +09:00

813 lines
28 KiB
JavaScript

var TypingExamination = {
create: function() {
// for developing
sessionStorageManager.setMaestroName("삼화초");
sessionStorageManager.setMaestroID(3);
sessionStorageManager.setMaestroAccountType(4);
sessionStorageManager.setPlayerName("박지상");
sessionStorageManager.setPlayerID(35);
sessionStorageManager.setPlayerAccountType(0);
sessionStorageManager.setPlayingAppID(100);
sessionStorageManager.setPlayingAppName("examination_korean");
sessionStorageManager.setPlayingAppKoreanName("타자 검정");
sessionStorageManager.setRecord(0);
sessionStorageManager.setAppHighestRecord(100.123);
this.dbConnectManager = new DBConnectManager();
sessionStorageManager.setRecord(0);
var self = this;
this.initTypingData();
sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener(
(function() { this.timeOver(); }).bind(this)
);
game.stage.backgroundColor = '#4d4d4d';
/*
// keyboard shortcut - useless. this.keyboard is chargning for ESC event
this.keyboardShortcut = new KeyboardShortcut();
this.keyboardShortcut.addCallback(
Phaser.KeyCode.ESC, // keyCode
null, // keyDownHandler
(function() { this.back(); }).bind(this), // keyUpHandler
"keyboard_test" // callerClassName
);
*/
// top ui
var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
screenTopUI.makeFullScreenButton();
this.averageTypingSpeedText = new AverageTypingSpeed();
// this.contentProgressText = new ContentProgress();
this.stageTimer = new StageTimer(
TypingExamination.GAME_TIME_SEC,
(function() {
this.setClickEnable(false);
this.timeOver();
}).bind(this)
);
this.stageTimer.setDisplayType(StageTimer.DISPLAY_TYPE_NON_SEC);
// typing content
var typingContentBG = new TypingContentBG();
typingContentBG.makeExaminationContentBG();
this.animalList = new AnimalList(670);
var TYPING_CONTENT_X = 60;
var TYPING_CONTENT_Y = 340;
var RECORD_POSITION_X = 960;
var FONT_SIZE = 32;
var TYPING_TEXT_OFFSET_HEIGHT = 40;
// textStyleBasic.font = "bold 38px Arial";
// textStyleBasic.backgroundColor = "rgba(0, 0, 0, 0.25)";
// current text
textStyleBasic.font = "38px Courier New";
this.textTypingContent = game.add.text(
TYPING_CONTENT_X, TYPING_CONTENT_Y,
"", textStyleBasic
)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
this.textTypingContent.anchor.set(0, 0.5);
this.textTypingContent.fontSize = FONT_SIZE;
textStyleBasic.font = "38px Arial";
textStyleBasic.backgroundColor = null;
this.textTypingLine = game.add.text(
RECORD_POSITION_X, TYPING_CONTENT_Y,
"", textStyleBasic
)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// .addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
this.textTypingLine.anchor.set(1, 0.5);
var TYPING_OFFSET_Y = 70;
var TYPING_PREVIEW_OFFSET_Y = 70;
// textStyleBasic.font = "38px Arial";
textStyleBasic.backgroundColor = null;
// done text
var textDoneColor = [ '#99994d', '#88884d', '#77774d', '#66664d' ];
// var textDoneColor = [ '#99994d', '#99994d', '#99994d', '#99994d' ];
this.textTypingContentsDone = [];
this.textTypingRecordsDone = [];
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
textStyleBasic.font = "38px Courier New";
this.textTypingContentsDone[i] = game.add.text(
TYPING_CONTENT_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
"", textStyleBasic
)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textDoneColor[i], 0);
this.textTypingContentsDone[i].anchor.set(0, 0.5);
this.textTypingContentsDone[i].fontSize = FONT_SIZE;
textStyleBasic.font = "38px Arial";
this.textTypingRecordsDone[i] = game.add.text(
RECORD_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
"", textStyleBasic
)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textDoneColor[i], 0);
this.textTypingRecordsDone[i].anchor.set(1, 0.5);
this.textTypingRecordsDone[i].fontSize = FONT_SIZE;
}
// preview text
var textPreviewColor = [ '#999999', '#888888', '#777777', '#666666' ];
// var textPreviewColor = [ '#999999', '#999999', '#999999', '#999999' ];
this.textTypingContentPreview = [];
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
textStyleBasic.font = "38px Courier New";
this.textTypingContentPreview[i] = game.add.text(
TYPING_CONTENT_X,
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
"", textStyleBasic
)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textPreviewColor[i], 0);
this.textTypingContentPreview[i].anchor.set(0, 0.5);
this.textTypingContentPreview[i].fontSize = FONT_SIZE;
}
// input text
this.inputTextContent = new InputText(TYPING_CONTENT_X - 10, TYPING_CONTENT_Y + 70, 800, 50);
this.inputTextContent.anchor.set(0, 0.5);
this.inputTextContent.canvasInput.value('');
this.inputTextContent.canvasInput.focus();
this.inputTextContent.canvasInput.fontSize(FONT_SIZE);
// this.inputTextContent.canvasInput.fontWeight("");
this.inputTextContent.canvasInput.fontFamily("Courier New");
// this.inputTextContent.canvasInput.fontFamily("Courier New");
this.inputTextContent.canvasInput.placeHolder("");
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
// inputTextContent.canvasInput._onkeyup = function() {
this.inputTextContent.canvasInput._onkeyup = function() {
self.checkTypingContents(event);
// warning
// : checkTypingContents is called onkeyup and onkeydown
}
// bottom ui
var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
this.loadExaminationContent();
// this.countDown();
},
/*
countDown() {
var style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
this.countDownText = game.add.text(0, 0, "", style);
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
this.countDownText.stroke = "#333";
this.countDownText.strokeThickness = 50;
this.countDownNumber = 3;
if(isDebugMode())
this.countDownNumber = 1;
this.tweenCountDown();
}
tweenCountDown() {
if(this.countDownNumber === 0) {
this.startGame();
return;
}
this.countDownText.text = this.countDownNumber.toString();
this.countDownText.alpha = 1;
var countDownTween = game.add.tween(this.countDownText);
countDownTween.to( { alpha: 0 }, GAME_SCREEN_SIZE.x, Phaser.Easing.Linear.None, true);
countDownTween.onComplete.add(this.tweenCountDown, this);
this.countDownNumber--;
}
*/
back: function() {
sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/menu_typing_test.html';
},
startGame: function() {
this.averageTypingSpeedText.print(0);
this.showTypingExaminationContents();
this.showPlayingWordNumber();
// this.updateKeyboard();
this.stageTimer.start();
},
timeOver: function() {
var timeOverText = new TimeOverText();
// this.stopAndGoResult();
},
gameOver: function() {
var missionClearText = new MissionClearText();
this.stopAndGoResult();
},
stopAndGoResult: function() {
this.animalList.stopAnimation();
sessionStorageManager.setRecord(this.typingRecordTotal);
if(!isExperienceMaestroAccount())
this.updateResultRecord();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
},
updateResultRecord: function() {
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
this.dbConnectManager.updateResultRecord(
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
sessionStorageManager.getPlayingAppID(),
sessionStorageManager.getRecord()
);
}
},
goResult: function() {
location.href = '../../web/client/result.html';
},
initTypingData: function() {
this.typingIndex = 0;
this.isGameOver = false;
this.isTyping = false;
this.timeTypingStart = 0;
this.timeTypingEnd = 0;
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
},
loadExaminationContent: function() {
game.load.onLoadComplete.add(this.literatureLoadComplete, this);
game.load.text("literature", "./../../game/typing/literature_list/korean_national_anthem.txt");
game.load.text("cold_noodle", "./../../game/typing/literature_list/korean_cold_noodle.txt");
game.load.start();
},
literatureLoadComplete: function() {
game.load.onFileComplete.remove(this.loadExaminationContent, this);
game.load.onLoadComplete.remove(this.literatureLoadComplete, this);
// var literature = game.cache.getText("literature");
var literature = game.cache.getText("cold_noodle");
var examinationContent = literature.split("\n");
for(var i = 0; i < examinationContent.length; i++) {
examinationContent[i] = examinationContent[i].replace(/\r/g, "");
// examinationContent[i] = examinationContent[i].replace(/ /g, TypingExamination.SPACE_INDICATOR);
}
// console.log('playingStageData.language : ' + playingStageData.language);
// console.log('playingStageData.level : ' + playingStageData.level);
// console.log('examinationContent : ' + examinationContent);
var typingTextMan = new TypingTextManager();
typingTextMan.makeExaminationContents(examinationContent);
this.typingExaminationContents = typingTextMan.getContents();
// console.log(this.typingExaminationContents);
this.typingContentLength = this.typingExaminationContents.length;
this.typingRecordForLines = [];
this.typingElapsedTime = [];
for(var i = 0; i < this.typingContentLength; i++) {
this.typingRecordForLines[i] = 0;
this.typingElapsedTime[i] = 0;
}
this.startGame();
},
replaceSpaceWithSpaceIndicator: function(text) {
return text.replace(/ /g, TypingExamination.SPACE_INDICATOR);
},
showTypingExaminationContents: function() {
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
var doneIndex = this.typingIndex - i - 1;
if(doneIndex < 0) {
this.textTypingContentsDone[i].text = "";
this.textTypingRecordsDone[i].text = "";
} else {
this.textTypingContentsDone[i].text = this.typingExaminationContents[doneIndex];
this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]);
}
}
if(this.typingIndex == this.typingContentLength) {
this.textTypingContent.text = "";
return;
}
var contentText = this.typingExaminationContents[this.typingIndex];
this.textTypingContent.text = this.replaceSpaceWithSpaceIndicator(contentText);
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
var previewIndex = this.typingIndex + i + 1;
if(previewIndex < this.typingExaminationContents.length) {
var previewText = this.typingExaminationContents[previewIndex];
this.textTypingContentPreview[i].text = this.replaceSpaceWithSpaceIndicator(previewText);
} else
this.textTypingContentPreview[i].text = "";
}
},
resetTypingContent: function() {
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
this.inputTextContent.canvasInput.value('');
},
checkTypingContents: function(event) {
if(this.isGameOver)
return;
// var inputContent = inputText.replace(/ /g, TypingExamination.SPACE_INDICATOR);
var inputContent = this.inputTextContent.canvasInput.value();
var trimmedInputContent = inputContent.trim();
var typingContent = this.typingExaminationContents[this.typingIndex].trim();
if(event.keyCode == Phaser.Keyboard.ENTER ||
event.keyCode == Phaser.Keyboard.SPACEBAR) {
// console.log("### enter ###");
// console.log("this.typingIndex : " + this.typingIndex);
// console.log("trimmedInputContent : [" + trimmedInputContent + "], length : " + trimmedInputContent.length);
// console.log("typingContent : [" + typingContent + "], length : " + typingContent.length);
if(trimmedInputContent === typingContent) {
// console.log("input completed");
this.calculateTypingRecord(typingContent);
// console.log("this.typingIndex : " + this.typingIndex);
// console.log("this.typingContentLength : " + this.typingContentLength);
if(this.typingIndex == this.typingContentLength - 1) {
this.isGameOver = true;
this.gameOver();
return;
}
this.playNextContent();
return;
}
}
if(this.isTyping == false) {
// console.log(event);
this.setTimeTypingStart();
}
this.showTypingContentHighlight(inputContent, typingContent);
// this.updateKeyboard();
},
showTypingContentHighlight: function(inputContent, typingContent) {
console.log(inputContent + "=");
console.log(typingContent + "=");
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_RIGHT, 0);
if(typingContent == null)
return;
// var replaceSpaceIndicatorInputContent = inputContent.replace(/ /g, TypingExamination.SPACE_INDICATOR);
var typingContentLength = typingContent.length;
for(var i = 0; i < typingContentLength; i++) {
// console.log("typingContent.charAt(i) : " + typingContent.charAt(i));
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
if(typingContent.charAt(i) != inputContent.charAt(i)) {
console.log("inputContent.charAt(" + i + ") : " + inputContent.charCodeAt(i).toString(16) + ", " + inputContent.charAt(i));
console.log("typingContent.charAt(" + i + ") : " + typingContent.charCodeAt(i).toString(16) + ", " + typingContent.charAt(i));
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, i);
return;
}
}
},
/*
updateKeyboard: function() {
var inputContent = this.inputTextContent.canvasInput.value();
var typingContent = this.typingExaminationContents[this.typingIndex];
this.hideHighlightKey(this.highlightKey);
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
// console.log(this.highlightKey);
this.showHighlightKey(this.highlightKey);
this.moveHands(this.highlightKey);
},
*/
getHighlioghtKey: function(inputContent, typingContent) {
if(typingContent == undefined)
return undefined;
var highlightKey = "";
var inputIndex = inputContent.length - 1;
var inputLength = inputContent.length;
var typingLength = typingContent.length;
// console.log("inputLength : " + inputLength + " / " + inputContent);
// console.log("typingLength : " + typingLength + " / " + typingContent);
var misspelledIndex = -1;
for(var i = 0; i < typingLength; i++) {
// console.log("inputContent[i] : " + inputContent[i] + ", typingContent[i] : " + typingContent[i]);
if(inputContent[i] != typingContent[i]) {
misspelledIndex = i;
break;
}
}
// over typing
if(inputLength > typingLength) {
highlightKey = "Backspace";
}
// complete typing
else if(inputContent == typingContent) {
highlightKey = "Enter";
}
// english typing test
else if(isEnglishTypingApp()) {
// console.log("===== english");
// console.log("misspelledIndex : " + misspelledIndex);
// console.log("inputIndex : " + inputIndex);
if(misspelledIndex > inputIndex)
highlightKey = typingContent[misspelledIndex];
else
highlightKey = "Backspace";
}
// korean typing test
else {
// console.log(misspelledIndex + " / " + typingContent[misspelledIndex]);
if(typingContent[misspelledIndex] == " ")
highlightKey = " ";
else {
var inputLetter = "";
var typingLetter = "";
var typingNextLetter = "";
// console.log("-----");
// console.log("inputConent : '" + inputContent + "'");
// console.log("inputIndex : " + inputIndex);
// console.log("typingLength : " + typingLength);
// console.log("misspelledIndex : " + misspelledIndex);
if(inputIndex < 0)
inputLetter = "";
else if(misspelledIndex > inputIndex)
inputLetter = "";
else
inputLetter = inputContent[misspelledIndex];
typingLetter = typingContent[misspelledIndex];
if(misspelledIndex <= typingContent.length)
typingNextLetter = typingContent[misspelledIndex + 1];
// console.log("inputLetter : '" + inputLetter + "'");
// console.log("typingLetter : '" + typingLetter + "'");
// console.log("typingNextLetter : '" + typingNextLetter + "'");
// 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);
if(misspelledIndex < inputIndex) {
highlightKey = "Backspace";
}
// typing nothing yet
else if(inputLetterAlphabets.length == 0) {
// highlightKey = typingLetterAlphabets[0];
highlightKey = StringUtil.chosung(typingLetter);
}
// after typing chosung
else if(inputLetterAlphabets.length == 1) {
if(StringUtil.chosung(inputLetter) != StringUtil.chosung(typingLetter))
highlightKey = "Backspace";
else {
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);
}
}
}
// after typing jungsung
else if(inputLetterAlphabets.length == 2) {
var typingLetterJungsung = StringUtil.jungsung(typingLetter);
// console.log("* 222");
// inputLetter jungsung == typingLetter jungsung
// inputLetter chosung != typingLetter chosung
if(StringUtil.chosung(inputLetter) != StringUtil.chosung(typingLetter))
highlightKey = "Backspace";
else 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 {
// 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) {
// inputLetter chosung != typingLetter chosung
if(StringUtil.chosung(inputLetter) != StringUtil.chosung(typingLetter))
highlightKey = "Backspace";
// inputLetter jungsung != typingLetter jungsung
else if(StringUtil.jungsung(inputLetter) != StringUtil.jungsung(typingLetter))
highlightKey = "Backspace";
// 입력할 글자에 종성이 있을 경우
else if(StringUtil.hasJongsung(typingLetter)) {
// console.log("has jongsung");
var typingLetterJongsung = StringUtil.jongsung(typingLetter);
// 입력한 글자의 종성과 입력할 글자의 종성이 같은 경우
if(StringUtil.jongsung(inputLetter) == typingLetterJongsung) {
if(inputIndex == typingLength - 1)
highlightKey = "Enter";
else
highlightKey = StringUtil.chosung(typingNextLetter);
}
// 입력한 글자의 종성이 입력할 글자와 다를 경우
else {
if(inputIndex == typingLength - 1)
highlightKey = "Backspace";
// 입력할 글자의 종성이 합성자음일 경우
else if(StringUtil.isMultiAlphabetJongsung(typingLetterJongsung)) {
var inputJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(inputLetter));
var typingJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(typingLetter));
// 입력할 글자의 종성과 입력한 글자의 종성이 같은 경우
if(typingLetterJongsung == StringUtil.jongsung(inputLetter))
highlightKey = StringUtil.chosung(typingNextLetter);
else if(StringUtil.jongsung(inputLetter) == typingJongsungAlphabets[0])
highlightKey = typingJongsungAlphabets[1];
else
highlightKey = "Backspace";
}
// 입력할 글자의 종성이 단자음일 경우 : 알바 -> 앏
else {
var inputLetterJongsung = StringUtil.jongsung(inputLetter);
// console.log("*** single jongsung");
// console.log("inputLetter : " + inputLetter);
// console.log("StringUtil.jongsung(inputLetter) : " + StringUtil.jongsung(inputLetter));
// console.log("inputLetterJongsung : " + inputLetterJongsung);
if(StringUtil.isMultiAlphabetJongsung(inputLetterJongsung)) {
var inputJongsungAlphabets = StringUtil.getMultiAlphabetFromJongsung(StringUtil.jongsung(inputLetter));
// console.log("inputJongsungAlphabets : " + inputJongsungAlphabets);
if(StringUtil.jongsung(typingLetter) == inputJongsungAlphabets[0] && StringUtil.chosung(typingNextLetter) == inputJongsungAlphabets[1])
highlightKey = StringUtil.jungsung(typingNextLetter);
else
highlightKey = "Backspace";
}
else {
highlightKey = StringUtil.chosung(typingNextLetter);
}
}
}
}
// 입력할 글자에 종성이 없을 경우
else {
// console.log("inputLetter jongsung : " + StringUtil.jongsung(inputLetter))
// console.log("typingNextLetter chosung : " + StringUtil.chosung(typingNextLetter))
if(StringUtil.hasJongsung(inputLetter)) {
// console.log("### has jongsung");
if(inputIndex == typingLength - 1)
highlightKey = "Backspace";
else {
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";
}
}
}
else
highlightKey = "Backspace";
}
}
}
}
if(highlightKey == " ")
highlightKey = "Space";
return highlightKey;
},
calculateTypingRecord: function(typingContent) {
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
this.isTyping = false;
this.timeTypingEnd = game.time.elapsedSince(0);
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
// console.log('elapsedTimeMS : ' + elapsedTimeMS);
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
// console.log('typingContentLength : ' + typingContentLength);
var typingContentPlusEnterCount = typingContentLength + TypingExamination.TYPING_COUNT_PLUS_ENTER;
var typingRecord = (typingContentPlusEnterCount + TypingExamination.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
this.typingLetterCountTotal += typingContentPlusEnterCount;
this.typingRecordForLines[this.typingIndex] = typingRecord;
// console.log(this.typingRecordForLines[this.typingIndex]);
var typingElapsedTimeTotal = 0;
for(var 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.typingElapsedTime);
// console.log(this.typingLetterCountTotal);
// console.log(typingElapsedTimeTotal);
// console.log(typingRecordTotal);
var typingRecordTotalInteger = Math.floor(this.typingRecordTotal);
this.averageTypingSpeedText.print(typingRecordTotalInteger);
// console.log('-------------- total --------------');
// console.log('typingLetterCountTotal : ' + this.typingLetterCountTotal);
// console.log('typingElapsedTimeTotal : ' + typingElapsedTimeTotal);
// console.log('typingRecordTotal : ' + this.typingRecordTotal);
// console.log('-----------------------------------');
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordTotalInteger, Animal.TYPE_TEST);
this.animalList.activate(animalLevelID);
this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
},
playNextContent: function() {
this.typingIndex++;
this.showTypingExaminationContents();
this.showPlayingWordNumber();
this.resetTypingContent();
// this.updateKeyboard();
},
showPlayingWordNumber: function() {
// this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
var currentLine = this.typingIndex + 1;
this.textTypingLine.text = currentLine + " / " + this.typingContentLength;
},
setTimeTypingStart: function() {
if(this.inputTextContent.canvasInput.value() == "")
return;
this.timeTypingStart = game.time.elapsedSince(0);
var timeGap = this.timeTypingStart - this.timeTypingEnd;
if(timeGap < 50)
return;
this.isTyping = true;
// console.log('last End : ' + this.timeTypingEnd);
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
}
}
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4; // 3;
TypingExamination.TYPING_CONTENT_DONE_COUNT = 4; // 3;
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
TypingExamination.OFFSET_RIGHT_ALIGN = 10;
TypingExamination.WORD_COUNT_FOR_STAGE = 10;
TypingExamination.COLOR_CONTENT_INPUT = "#dddddd";
TypingExamination.COLOR_CONTENT_RIGHT = "#ffff4d";