Add: difficulty for level
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
function ExtractWordManager() {
|
function ExtractWordManager() {
|
||||||
this.init();
|
this.initVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractWordManager.prototype.init = function() {
|
ExtractWordManager.prototype.initVariables = function() {
|
||||||
this.koreanWordList = [];
|
this.koreanWordList = [];
|
||||||
this.koreanWordList[0] = koreanBasicWordList;
|
this.koreanWordList[0] = koreanBasicWordList;
|
||||||
this.koreanWordList[1] = koreanLeftUpperWordList;
|
this.koreanWordList[1] = koreanLeftUpperWordList;
|
||||||
@@ -27,29 +27,74 @@ ExtractWordManager.prototype.init = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtractWordManager.prototype.getWord = function(wordLevel, wordLength) {
|
ExtractWordManager.prototype.isValidWordForLevel = function(word, difficultyForLevel) {
|
||||||
if(isKoreanTypingApp())
|
// console.log("word : " + word);
|
||||||
return this.getKoreanWord(wordLevel, wordLength);
|
// console.log("difficultyForLevel : " + difficultyForLevel);
|
||||||
else
|
if(word == "")
|
||||||
return this.getEnglishWord(wordLevel, wordLength);
|
return false;
|
||||||
|
|
||||||
|
var wordLength = word.length;
|
||||||
|
|
||||||
|
if(difficultyForLevel == ExtractWordManager.DIFFICULTY_EASY) {
|
||||||
|
var maxWordLength = 0;
|
||||||
|
|
||||||
|
if(isKoreanTypingApp()) {
|
||||||
|
maxWordLength = ExtractWordManager.DIFFICULTY_EASY_KOREAN_WORD_LENGTH;
|
||||||
|
} else {
|
||||||
|
maxWordLength = ExtractWordManager.DIFFICULTY_EASY_ENGLISH_WORD_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wordLength <= maxWordLength)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
var minWordLength = 0;
|
||||||
|
|
||||||
|
if(isKoreanTypingApp()) {
|
||||||
|
minWordLength = ExtractWordManager.DIFFICULTY_EASY_KOREAN_WORD_LENGTH;
|
||||||
|
} else {
|
||||||
|
minWordLength = ExtractWordManager.DIFFICULTY_EASY_ENGLISH_WORD_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wordLength > minWordLength)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.getWord = function(wordLevel, difficultyForLevel) {
|
||||||
|
// console.log("wordLevel : " + wordLevel);
|
||||||
|
// console.log("difficultyForLevel : " + difficultyForLevel);
|
||||||
|
var word = "";
|
||||||
|
var wordLength = 0;
|
||||||
|
var count = 0;
|
||||||
|
while(word == "" || !this.isValidWordForLevel(word, difficultyForLevel)) {
|
||||||
|
if(isKoreanTypingApp())
|
||||||
|
word = this.getRandomWord(this.koreanWordList[wordLevel]);
|
||||||
|
else
|
||||||
|
word = this.getRandomWord(this.englishWordList[wordLevel]);
|
||||||
|
|
||||||
|
// console.log(word);
|
||||||
|
count++;
|
||||||
|
if(count > 100) {
|
||||||
|
console.log("warning : infinity loop!!!");
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractWordManager.prototype.getRandomWord = function(wordList) {
|
ExtractWordManager.prototype.getRandomWord = function(wordList) {
|
||||||
var index = Math.floor(Math.random() * wordList.length);
|
var randomIndex = Math.floor(Math.random() * wordList.length);
|
||||||
return wordList[index];
|
return wordList[randomIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtractWordManager.prototype.getKoreanWord = function(wordLevel, wordLength) {
|
|
||||||
return this.getRandomWord(this.koreanWordList[wordLevel]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtractWordManager.prototype.getEnglishWord = function(wordLevel, wordLength) {
|
|
||||||
return this.getRandomWord(this.englishWordList[wordLevel]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtractWordManager.prototype.removeWord = function(wordLevel, word) {
|
ExtractWordManager.prototype.removeWord = function(wordLevel, word) {
|
||||||
console.log("remove : " + wordLevel + ", " + word);
|
// console.log("remove : " + wordLevel + ", " + word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,3 +228,12 @@ ExtractWordManager.ENGLISH_LETTER_RIGHT = [
|
|||||||
"h", "j", "k", "l",
|
"h", "j", "k", "l",
|
||||||
"n", "m"
|
"n", "m"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.DIFFICULTY_EASY = 0;
|
||||||
|
ExtractWordManager.DIFFICULTY_HARD = 1
|
||||||
|
|
||||||
|
ExtractWordManager.DIFFICULTY_EASY_KOREAN_WORD_LENGTH = 2;
|
||||||
|
ExtractWordManager.DIFFICULTY_EASY_ENGLISH_WORD_LENGTH = 3;
|
||||||
@@ -48,7 +48,7 @@ function FlyingSaucer(lineIndex) {
|
|||||||
FlyingSaucer.prototype.initVariables = function() {
|
FlyingSaucer.prototype.initVariables = function() {
|
||||||
this.isActivated = false;
|
this.isActivated = false;
|
||||||
this.wordLevel = 0;
|
this.wordLevel = 0;
|
||||||
this.wordLength = 0;
|
this.difficultyForLevel = 0;
|
||||||
this.standardScore = 0;
|
this.standardScore = 0;
|
||||||
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
||||||
this.jetStatus = FlyingSaucer.JET_STATUS_HIGH;
|
this.jetStatus = FlyingSaucer.JET_STATUS_HIGH;
|
||||||
@@ -190,8 +190,12 @@ FlyingSaucer.prototype.moveInitialPos = function() {
|
|||||||
|
|
||||||
FlyingSaucer.prototype.startAttack = function() {
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.wordLevel = this.gameLevelManager.getWordLevel();
|
this.wordLevel = this.gameLevelManager.getWordLevel();
|
||||||
this.wordLength = this.gameLevelManager.getWordLength(this.wordLevel);
|
this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel();
|
||||||
this.word = this.extractWordManager.getWord(this.wordLevel, this.wordLength);
|
// console.log("====");
|
||||||
|
// console.log("this.wordLevel : " + this.wordLevel);
|
||||||
|
// console.log("this.difficultyForLevel : " + this.difficultyForLevel);
|
||||||
|
this.word = this.extractWordManager.getWord(this.wordLevel, this.difficultyForLevel);
|
||||||
|
// console.log("this.word : " + this.word);
|
||||||
this.setWord(this.word);
|
this.setWord(this.word);
|
||||||
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
|
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
|
||||||
// console.log(this.standardScore);
|
// console.log(this.standardScore);
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
function GameLevelManager() {
|
function GameLevelManager() {
|
||||||
this.wordLevel = 0;
|
this.wordLevel = 0;
|
||||||
this.wordLength = GameLevelManager.MIN_WORD_LENGTH;
|
|
||||||
this.clearPoint = 0.1;
|
this.clearedWordCountForLevel = [0, 0, 0, 0, 0];
|
||||||
|
|
||||||
|
this.difficultyForLevelList = [];
|
||||||
|
for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++)
|
||||||
|
this.difficultyForLevelList[i] = ExtractWordManager.DIFFICULTY_EASY;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getWordLevel = function() {
|
GameLevelManager.prototype.getWordLevel = function() {
|
||||||
return this.wordLevel;
|
return this.wordLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getWordLength = function() {
|
GameLevelManager.prototype.getDifficultyForLevel = function() {
|
||||||
return this.wordLength;
|
return this.difficultyForLevelList[this.wordLevel];
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) {
|
GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) {
|
||||||
@@ -18,31 +22,58 @@ GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) {
|
|||||||
|
|
||||||
|
|
||||||
GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
|
GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
|
||||||
console.log("wordLevel : " + wordLevel);
|
// console.log("====");
|
||||||
console.log("landingRatio : " + landingRatio);
|
// for(var i = 0; i < this.difficultyForLevelList.length; i++) {
|
||||||
if(this.wordLevel == GameLevelManager.MAX_KOR_WORD_LEVEL || wordLevel < this.wordLevel) {
|
// console.log("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]);
|
||||||
this.wordLength++;
|
// }
|
||||||
|
|
||||||
|
// console.log("wordLevel : " + wordLevel);
|
||||||
|
// console.log("landingRatio : " + landingRatio);
|
||||||
|
if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL || wordLevel < this.wordLevel) {
|
||||||
|
this.increaseClearedWordCountForLevel(wordLevel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) {
|
if(wordLevel < this.wordLevel || landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) {
|
||||||
this.wordLength++;
|
this.increaseClearedWordCountForLevel(wordLevel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.goNextWordLevel();
|
this.goNextWordLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) {
|
||||||
|
this.clearedWordCountForLevel[wordLevel]++;
|
||||||
|
|
||||||
|
var difficulty = this.difficultyForLevelList[wordLevel];
|
||||||
|
var clearedWordCount = this.clearedWordCountForLevel[wordLevel];
|
||||||
|
var clearedWordCountForNextLevel = GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL[difficulty];
|
||||||
|
|
||||||
|
// console.log("=============");
|
||||||
|
// console.log("difficulty : " + difficulty);
|
||||||
|
// console.log("clearedWordCount : " + clearedWordCount);
|
||||||
|
// console.log("clearedWordCountForNextLevel : " + clearedWordCountForNextLevel);
|
||||||
|
|
||||||
|
if(difficulty == ExtractWordManager.DIFFICULTY_EASY
|
||||||
|
&& clearedWordCount >= clearedWordCountForNextLevel) {
|
||||||
|
|
||||||
|
this.difficultyForLevelList[wordLevel] = ExtractWordManager.DIFFICULTY_HARD;
|
||||||
|
// console.log("level[" + wordLevel + "] : difficulty -> HARD");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.goNextWordLevel = function() {
|
GameLevelManager.prototype.goNextWordLevel = function() {
|
||||||
console.log("goNextWordLevel");
|
|
||||||
this.wordLevel++;
|
this.wordLevel++;
|
||||||
this.wordLength = 1;
|
console.log("goNextWordLevel to " + this.wordLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7;
|
GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.9;
|
||||||
GameLevelManager.WARNING_LANDING_RATIO = 0.1;
|
GameLevelManager.WARNING_LANDING_RATIO = 0.1;
|
||||||
|
|
||||||
GameLevelManager.MAX_KOR_WORD_LEVEL = 5;
|
GameLevelManager.MAX_WORD_LEVEL = 6;
|
||||||
|
|
||||||
GameLevelManager.MIN_WORD_LENGTH = 2;
|
GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL = [5, 6, 7, 8, 9, 10];
|
||||||
|
|
||||||
|
GameLevelManager.KOREAN_WORD_LENGTH = [2, 3];
|
||||||
|
GameLevelManager.ENGLISH_WORD_LENGTH = [3, 6];;
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
<script src="../../game/typing/word_list/korean_right_lower.js"></script>
|
<script src="../../game/typing/word_list/korean_right_lower.js"></script>
|
||||||
<script src="../../game/typing/word_list/korean_left_upper_double.js"></script>
|
<script src="../../game/typing/word_list/korean_left_upper_double.js"></script>
|
||||||
<script src="../../game/typing/word_list/korean_right_upper_double.js"></script>
|
<script src="../../game/typing/word_list/korean_right_upper_double.js"></script>
|
||||||
<script src="../../game/typing/word_list/korean_word.js"></script>
|
<!-- <script src="../../game/typing/word_list/korean_word.js"></script> -->
|
||||||
|
|
||||||
<script src="../../game/typing/word_list/english_basic.js"></script>
|
<script src="../../game/typing/word_list/english_basic.js"></script>
|
||||||
<script src="../../game/typing/word_list/english_left_lower.js"></script>
|
<script src="../../game/typing/word_list/english_left_lower.js"></script>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<script src="../../game/typing/word_list/english_right_lower.js"></script>
|
<script src="../../game/typing/word_list/english_right_lower.js"></script>
|
||||||
<script src="../../game/typing/word_list/english_right_upper.js"></script>
|
<script src="../../game/typing/word_list/english_right_upper.js"></script>
|
||||||
<script src="../../game/typing/word_list/english_second_finger.js"></script>
|
<script src="../../game/typing/word_list/english_second_finger.js"></script>
|
||||||
<script src="../../game/typing/word_list/english_word.js"></script>
|
<!-- <script src="../../game/typing/word_list/english_word.js"></script> -->
|
||||||
|
|
||||||
<!-- Shoot down! flyingsaucer : source files -->
|
<!-- Shoot down! flyingsaucer : source files -->
|
||||||
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user