1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
};
}
|