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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/**
* 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,
SettingsPayload
} 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: [] };
}
/**
* A server settings payload in its default shape (the server's
* `Settings.forClient()` defaults).
*/
export function emptySettings(
overrides: Partial<SettingsPayload> = {}
): SettingsPayload {
return {
noInit: true,
noStandees: false,
randomStandees: false,
expireConditions: true,
autoAddStandees: true,
autoAddSpawns: true,
hideLootDeck: false,
style: 2,
showBattleGoalReminder: true,
showReminders: true,
showAmdDeck: true,
fhHazTerrainCalcInOGGloom: true,
locale: 'en',
saves: [],
characterSaves: [],
...overrides
};
}
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
};
}
|