From 0e68490e75a8a63aa6b2fd2d953a47b90e79d414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 14 Dec 2021 14:46:24 +0100 Subject: [PATCH] Refactoring with a MapStore A great deal of the complexity of the current code is that we must chain 2 reactive values (one in the map "GameScene.MapPlayersByKey" and one in the snapshot store). The new generic MapStore class can be used to listen to stores inside a map. When the store inside the map, or the map itself is modified, the resulting store is updated. --- .../src/Components/Companion/Companion.svelte | 27 ++-- front/src/Components/Woka/Woka.svelte | 11 +- front/src/Phaser/Companion/Companion.ts | 12 +- front/src/Phaser/Entity/Character.ts | 17 ++- front/src/Phaser/Game/GameScene.ts | 50 +------ front/src/Stores/PictureStore.ts | 6 + front/src/Stores/PlayersStore.ts | 2 +- front/src/Stores/UserCompanionPictureStore.ts | 8 -- front/src/Stores/UserWokaPictureStore.ts | 8 -- front/src/Stores/Utils/MapStore.ts | 122 ++++++++++++++++++ front/tests/Stores/Utils/MapStoreTest.ts | 97 ++++++++++++++ 11 files changed, 277 insertions(+), 83 deletions(-) create mode 100644 front/src/Stores/PictureStore.ts delete mode 100644 front/src/Stores/UserCompanionPictureStore.ts delete mode 100644 front/src/Stores/UserWokaPictureStore.ts create mode 100644 front/src/Stores/Utils/MapStore.ts create mode 100644 front/tests/Stores/Utils/MapStoreTest.ts diff --git a/front/src/Components/Companion/Companion.svelte b/front/src/Components/Companion/Companion.svelte index 984e8bba..dd3db351 100644 --- a/front/src/Components/Companion/Companion.svelte +++ b/front/src/Components/Companion/Companion.svelte @@ -1,7 +1,6 @@ - +