diff --git a/android/gradle.properties b/android/gradle.properties index db7a1ee2908d6e94aeb319e1c1b548a8bb245891..14eed3944b547f02179b1b42f4b601f91b7957c0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.0.3 -app.versionCode=3 +app.versionName=0.0.4 +app.versionCode=4 diff --git a/assets/files/words-5-fr-dictionnary.txt b/assets/files/words-5-fr-dictionary.txt similarity index 100% rename from assets/files/words-5-fr-dictionnary.txt rename to assets/files/words-5-fr-dictionary.txt diff --git a/assets/skins/default_wrong.png b/assets/skins/default_wrong.png new file mode 100644 index 0000000000000000000000000000000000000000..e62d9e1d12dd0382fa4520a0ffb8736e553aa2b9 Binary files /dev/null and b/assets/skins/default_wrong.png differ diff --git a/icons/build_game_icons.sh b/icons/build_game_icons.sh index 2fddd00c1365f394427511ffa1649f078b253911..2c7d70c5b1932be4b1b50bd47b1fc6ee08a80013 100755 --- a/icons/build_game_icons.sh +++ b/icons/build_game_icons.sh @@ -51,6 +51,7 @@ function build_icon_for_skin() { build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/empty.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_empty.png build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/good.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_good.png build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/misplaced.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_misplaced.png + build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/wrong.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_wrong.png } # Game icons diff --git a/icons/skins/default/wrong.svg b/icons/skins/default/wrong.svg new file mode 100644 index 0000000000000000000000000000000000000000..9c89cb27d9bdfc10d1787888b3f6db7eb3f22252 --- /dev/null +++ b/icons/skins/default/wrong.svg @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 100 100" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="linearGradient1569" x1="26.688" x2="77.95" y1=".40612" y2="99.665" gradientUnits="userSpaceOnUse"><stop stop-color="#b9b9b9" offset="0"/><stop stop-color="#767676" offset="1"/></linearGradient></defs><rect width="100" height="100" ry="2" fill="none"/><rect width="100" height="100" fill="url(#linearGradient1569)" stroke="#5d5d5d" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg> diff --git a/lib/provider/data.dart b/lib/provider/data.dart index 6b3bfe942dd50ae74f4919f891e8f83117a6fc68..7d87dc85b5429c885ad0917b4db57f4526de62ca 100644 --- a/lib/provider/data.dart +++ b/lib/provider/data.dart @@ -84,6 +84,11 @@ class Data extends ChangeNotifier { notifyListeners(); } } + void currentGuessSubmitWrongWord() { + print('Adding unknown word'); + addGuess(_currentGuess); + notifyListeners(); + } void addGuess(String word) { print('addGuess('+word+')'); _guesses.add(word); diff --git a/lib/utils/game_utils.dart b/lib/utils/game_utils.dart index fbbb9aee85b82906c3c9142c47f6dd7f87fe86e7..5fb4c00fa7f5aea8a972d97ab120dcdcab87c83a 100644 --- a/lib/utils/game_utils.dart +++ b/lib/utils/game_utils.dart @@ -61,8 +61,12 @@ class GameUtils { List<String> tips = List<String>.filled(wordLength, '', growable: false); - if ((word.length != wordLength) || (candidate.length != wordLength)) { - return tips; + if ( + (word.length != wordLength) + || (candidate.length != wordLength) + || (!RandomPickWord.checkWordExists(candidate)) + ) { + return List<String>.filled(wordLength, 'wrong', growable: false); } String replaceCharAt(String oldString, int index, String newChar) { @@ -102,11 +106,25 @@ class GameUtils { static bool submitWord(Data myProvider) { print('submitWord'); - // TODO: check this word is allowed - myProvider.currentGuessSubmitWord(); + + if (GameUtils.checkCurrentlyGuessedWordExists(myProvider)) { + print('Ok word allowed'); + myProvider.currentGuessSubmitWord(); + } else { + print('Unknown word'); + myProvider.currentGuessSubmitWrongWord(); + } + return true; } + static bool checkCurrentlyGuessedWordExists(Data myProvider) { + String guessedWord = myProvider.currentGuess; + print('Checking word "' + guessedWord + '"...'); + + return RandomPickWord.checkWordExists(guessedWord); + } + static bool isGameFinished(Data myProvider) { print('isGameFinished'); diff --git a/lib/utils/random_pick_word.dart b/lib/utils/random_pick_word.dart index 8b24c5a17727131061693de52c5faba94c72c010..56bcdb8a646b4573934772fafacd5555023abf13 100644 --- a/lib/utils/random_pick_word.dart +++ b/lib/utils/random_pick_word.dart @@ -30,10 +30,10 @@ class RandomPickWord { String wordBaseFilename = 'words-' + length.toString() + '-' + lang; - // Get full dictionnary (eligible words) + // Get full dictionary (eligible words) print('Reload dictionary'); try { - String wordsFile = wordBaseFilename + '-' + 'dictionnary'; + String wordsFile = wordBaseFilename + '-' + 'dictionary'; var data = await rootBundle.loadString('assets/files/' + wordsFile + '.txt'); LineSplitter.split(data).forEach((line) { if (line.length == length) { @@ -74,4 +74,8 @@ class RandomPickWord { print('Picked word: ' + _word); } + + static bool checkWordExists(String word) { + return dictionary.contains(word); + } }