From fdfe03e76d7f084232c1fd05caa852dcec826925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Wed, 17 Apr 2024 14:45:14 +0200 Subject: [PATCH] Improve manage data script --- android/gradle.properties | 4 +-- .../metadata/android/en-US/changelogs/20.txt | 1 + .../metadata/android/fr-FR/changelogs/20.txt | 1 + lib/data/game_data.dart | 18 +++++----- pubspec.yaml | 2 +- scripts/data.json | 33 +++++-------------- scripts/manage_data.php | 33 +++++++++++++++---- 7 files changed, 49 insertions(+), 43 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/20.txt create mode 100644 fastlane/metadata/android/fr-FR/changelogs/20.txt diff --git a/android/gradle.properties b/android/gradle.properties index 6c1d873..24add27 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.19 -app.versionCode=19 +app.versionName=0.0.20 +app.versionCode=20 diff --git a/fastlane/metadata/android/en-US/changelogs/20.txt b/fastlane/metadata/android/en-US/changelogs/20.txt new file mode 100644 index 0000000..da7e104 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/20.txt @@ -0,0 +1 @@ +Improve data and management script. diff --git a/fastlane/metadata/android/fr-FR/changelogs/20.txt b/fastlane/metadata/android/fr-FR/changelogs/20.txt new file mode 100644 index 0000000..e6724ac --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/20.txt @@ -0,0 +1 @@ +Améliorations des données et du script de gestion. diff --git a/lib/data/game_data.dart b/lib/data/game_data.dart index 8b85341..1714ff8 100644 --- a/lib/data/game_data.dart +++ b/lib/data/game_data.dart @@ -73,7 +73,7 @@ class GameData { "ABEILLE": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["liquide"] + "na": [] }, "AMPOULE": { "is": ["artificiel", "inerte", "solide"], @@ -128,7 +128,7 @@ class GameData { "CANARD": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["liquide"] + "na": [] }, "CASQUETTE": { "is": ["artificiel", "inerte", "solide"], @@ -158,7 +158,7 @@ class GameData { "CONFITURE": { "is": ["artificiel", "inerte", "solide"], "isnot": ["gazeux", "liquide", "naturel", "vivant"], - "na": ["liquide"] + "na": [] }, "CORDE": { "is": ["artificiel", "inerte", "solide"], @@ -178,12 +178,12 @@ class GameData { "FENÊTRE": { "is": ["artificiel", "inerte", "solide"], "isnot": ["gazeux", "liquide", "naturel", "vivant"], - "na": ["liquide"] + "na": [] }, "FOURMI": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["liquide"] + "na": [] }, "FUSÉE": { "is": ["artificiel", "inerte", "solide"], @@ -218,7 +218,7 @@ class GameData { "LICORNE": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["naturel"] + "na": [] }, "LIVRE": { "is": ["artificiel", "inerte", "solide"], @@ -238,7 +238,7 @@ class GameData { "NOEUD": { "is": ["artificiel", "inerte"], "isnot": ["gazeux", "liquide", "naturel", "vivant"], - "na": ["artificiel", "solide"] + "na": ["solide"] }, "ORAGE": { "is": ["inerte", "naturel"], @@ -348,7 +348,7 @@ class GameData { "TORTUE": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["liquide"] + "na": [] }, "TROMPETTE": { "is": ["artificiel", "inerte", "solide"], @@ -358,7 +358,7 @@ class GameData { "VACHE": { "is": ["naturel", "solide", "vivant"], "isnot": ["artificiel", "gazeux", "inerte", "liquide"], - "na": ["liquide"] + "na": [] }, "VOILIER": { "is": ["artificiel", "inerte", "solide"], diff --git a/pubspec.yaml b/pubspec.yaml index b65f688..f51af0c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A sorting game application. publish_to: 'none' -version: 0.0.19+19 +version: 0.0.20+20 environment: sdk: '^3.0.0' diff --git a/scripts/data.json b/scripts/data.json index f114346..ff31ed1 100644 --- a/scripts/data.json +++ b/scripts/data.json @@ -99,9 +99,7 @@ "inerte", "liquide" ], - "na": [ - "liquide" - ] + "na": [] }, "AMPOULE": { "is": [ @@ -255,9 +253,7 @@ "inerte", "liquide" ], - "na": [ - "liquide" - ] + "na": [] }, "CASQUETTE": { "is": [ @@ -342,9 +338,7 @@ "naturel", "vivant" ], - "na": [ - "liquide" - ] + "na": [] }, "CORDE": { "is": [ @@ -401,9 +395,7 @@ "naturel", "vivant" ], - "na": [ - "liquide" - ] + "na": [] }, "FOURMI": { "is": [ @@ -417,9 +409,7 @@ "inerte", "liquide" ], - "na": [ - "liquide" - ] + "na": [] }, "FUSÉE": { "is": [ @@ -518,9 +508,7 @@ "inerte", "liquide" ], - "na": [ - "naturel" - ] + "na": [] }, "LIVRE": { "is": [ @@ -577,7 +565,6 @@ "vivant" ], "na": [ - "artificiel", "solide" ] }, @@ -895,9 +882,7 @@ "inerte", "liquide" ], - "na": [ - "liquide" - ] + "na": [] }, "TROMPETTE": { "is": [ @@ -925,9 +910,7 @@ "inerte", "liquide" ], - "na": [ - "liquide" - ] + "na": [] }, "VOILIER": { "is": [ diff --git a/scripts/manage_data.php b/scripts/manage_data.php index ca5b0ee..d23127c 100644 --- a/scripts/manage_data.php +++ b/scripts/manage_data.php @@ -67,6 +67,25 @@ function clean_item_mappings(array $itemMappings) $itemMappings['isnot'] = array_clean($itemMappings['isnot']); $itemMappings['na'] = array_clean($itemMappings['na']); + // remove duplicates + $itemMappings['is'] = array_clean($itemMappings['is']); + + $tmpArray = []; + foreach (array_clean($itemMappings['isnot']) as $itemIsNot) { + if (!\in_array($itemIsNot, $itemMappings['is'])) { + $tmpArray[] = $itemIsNot; + } + } + $itemMappings['isnot'] = $tmpArray; + + $tmpArray = []; + foreach (array_clean($itemMappings['na']) as $itemNa) { + if (!\in_array($itemNa, $itemMappings['is']) && !\in_array($itemNa, $itemMappings['isnot'])) { + $tmpArray[] = $itemNa; + } + } + $itemMappings['na'] = $tmpArray; + return $itemMappings; } @@ -133,7 +152,7 @@ foreach ($items as $item) { } // TODO: Should check/add unkown items from current mapping - +\ksort($mappingItems); $data['mapping'] = [ 'items' => $mappingItems, ]; @@ -315,15 +334,17 @@ $exitMainLoop = false; while ($exitMainLoop === false) { dump(''); + $missing = find_missing_associations($mappingItems, $categories, $items); + $menu = [ '0: exit', '', - '1: show categories', - '2: show items', - '3: show exclusions', - '4: show mappings', + '1: show categories (' . \count($categories) . ' found)', + '2: show items (' . \count($items) . ' found)', + '3: show exclusions (' . \count($exclusions) . ' found)', + '4: show mappings (' . \count($mappingItems) . ' found)', '', - '5: edit mappings', + '5: complete mappings (' . \count($missing) . ' missing)', ]; $answer = ask(\join("\n", $menu)); -- GitLab