summaryrefslogtreecommitdiff
path: root/web/test/fixtures.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/test/fixtures.ts')
-rw-r--r--web/test/fixtures.ts96
1 files changed, 96 insertions, 0 deletions
diff --git a/web/test/fixtures.ts b/web/test/fixtures.ts
new file mode 100644
index 0000000..805634e
--- /dev/null
+++ b/web/test/fixtures.ts
@@ -0,0 +1,96 @@
+/**
+ * Shared test fixtures (PLAN.md Phase 4): valid empty deck shapes and a full
+ * {@link GameState} factory so tests don't repeat the (now non-trivial)
+ * deck field initialisers.
+ */
+
+import type {
+ GameState,
+ LootDeck,
+ ModifierDeck,
+ SanctuaryDeck
+} from '$lib/protocol/types';
+import { LOOT_POOL_KEYS } from '$lib/protocol/types';
+
+/** The ten removable-counter gfx keys the server initialises. */
+export function emptyRemovables(): Record<string, number> {
+ return {
+ curse: 0,
+ bless: 0,
+ 'in-enfeeble': 0,
+ 'vi-enfeeble': 0,
+ 'vi-gr-enfeeble': 0,
+ 'li-enfeeble': 0,
+ 'in-empower': 0,
+ 'rm-empower': 0,
+ 'vi-empower': 0,
+ 'vi-gr-empower': 0
+ };
+}
+
+export function emptyModifierDeck(): ModifierDeck {
+ return {
+ addedMinusOnes: 0,
+ imbuement: 0,
+ badOmen: 0,
+ corrosiveSpew: false,
+ revealed: 0,
+ cassandra: false,
+ removables: emptyRemovables(),
+ drawPile: [],
+ removedPile: [],
+ discardPile: []
+ };
+}
+
+function emptyPools(): Record<(typeof LOOT_POOL_KEYS)[number], number[]> {
+ const out = {} as Record<(typeof LOOT_POOL_KEYS)[number], number[]>;
+ for (const key of LOOT_POOL_KEYS) out[key] = [];
+ return out;
+}
+
+export function emptyLootDeck(): LootDeck {
+ return {
+ drawPile: [],
+ discardPile: [],
+ addedCards: [],
+ enhancements: {},
+ '1418': false,
+ '1419': false,
+ pools: emptyPools()
+ };
+}
+
+export function emptySanctuaryDeck(): SanctuaryDeck {
+ return { multPile: [], flipPile: [] };
+}
+
+export function emptyGameState(
+ overrides: Partial<GameState> = {}
+): GameState {
+ return {
+ level: 1,
+ solo: false,
+ autoScenarioLevel: false,
+ difficulty: 1,
+ roundState: 0,
+ round: 1,
+ totalRounds: 1,
+ scenario: 'custom',
+ toastMessage: '',
+ scenarioSpecialRules: [],
+ scenarioSectionsAdded: [],
+ currentCampaign: 'Jaws of the Lion',
+ currentList: [],
+ currentAbilityDecks: [],
+ sanctuaryDeck: emptySanctuaryDeck(),
+ modifierDeck: emptyModifierDeck(),
+ modifierDeckAllies: emptyModifierDeck(),
+ lootDeck: emptyLootDeck(),
+ unlockedClasses: [],
+ showAllyDeck: false,
+ allyDeckInOGGloom: true,
+ elementState: {},
+ ...overrides
+ };
+}