feat: connect sortie recommendations to battle results
This commit is contained in:
@@ -61,6 +61,35 @@ try {
|
||||
isValidBattleSaveState(legacyStateWithoutSortieOrder, options),
|
||||
'Expected legacy battle saves without a sortie order to remain valid.'
|
||||
);
|
||||
const validRecommendationState = {
|
||||
...validState,
|
||||
sortieRecommendation: {
|
||||
version: 1,
|
||||
battleId: 'first-battle-zhuo-commandery',
|
||||
planId: 'order',
|
||||
label: '군령 달성형',
|
||||
summary: '군령 조건을 우선합니다.',
|
||||
sortieOrderId: 'elite',
|
||||
selectedUnitIds: ['liu-bei', 'guan-yu'],
|
||||
formationAssignments: { 'liu-bei': 'support', 'guan-yu': 'front' },
|
||||
unitReasons: { 'liu-bei': '지휘를 맡습니다.', 'guan-yu': '전열을 맡습니다.' }
|
||||
}
|
||||
};
|
||||
const parsedRecommendationState = parseBattleSaveState(JSON.stringify(validRecommendationState), options);
|
||||
assert(
|
||||
parsedRecommendationState?.sortieRecommendation?.planId === 'order' &&
|
||||
parsedRecommendationState.sortieRecommendation !== validRecommendationState.sortieRecommendation &&
|
||||
JSON.stringify(parsedRecommendationState.sortieRecommendation.selectedUnitIds) === JSON.stringify(['liu-bei', 'guan-yu']),
|
||||
`Expected valid recommendation provenance to round-trip through a battle save: ${JSON.stringify(parsedRecommendationState?.sortieRecommendation)}`
|
||||
);
|
||||
const corruptedRecommendationState = normalizeBattleSaveState({
|
||||
...validRecommendationState,
|
||||
sortieRecommendation: { ...validRecommendationState.sortieRecommendation, planId: 'unknown-plan' }
|
||||
}, options);
|
||||
assert(
|
||||
corruptedRecommendationState && corruptedRecommendationState.sortieRecommendation === undefined,
|
||||
'Expected corrupted optional recommendation metadata to be discarded without rejecting the battle save.'
|
||||
);
|
||||
const validCoreResonanceState = {
|
||||
...validState,
|
||||
sortieResonanceBondId: 'taoyuan',
|
||||
@@ -384,6 +413,9 @@ try {
|
||||
['invalid stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], actions: 1.5 } } }],
|
||||
['too high stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], damageDealt: 1000000 } } }],
|
||||
['invalid sortie stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], sortieBonusDamage: -1 } } }],
|
||||
['invalid strategy use stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], strategyUses: 1.5 } } }],
|
||||
['invalid signature strategy use stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], signatureStrategyUses: -1 } } }],
|
||||
['signature strategy uses exceed total strategy uses', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], strategyUses: 0, signatureStrategyUses: 1 } } }],
|
||||
['too high sortie stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], sortieExtendedBondTriggers: 1000000 } } }],
|
||||
['invalid counterplay stats value', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], intentLineBreaks: -1 } } }],
|
||||
['invalid counterplay stats precision', { battleStats: { 'liu-bei': { ...validState.battleStats['liu-bei'], intentGuardSuccesses: 1.5 } } }],
|
||||
@@ -604,7 +636,9 @@ function createValidBattleSaveState() {
|
||||
damageTaken: 3,
|
||||
defeats: 1,
|
||||
actions: 2,
|
||||
support: 0
|
||||
support: 0,
|
||||
strategyUses: 1,
|
||||
signatureStrategyUses: 1
|
||||
}
|
||||
},
|
||||
enemyUsableUseKeys: ['first-battle-zhuo-commandery:rebel-1:roar'],
|
||||
|
||||
Reference in New Issue
Block a user