Cap campaign battle history snapshots

This commit is contained in:
2026-07-05 12:04:23 +09:00
parent 20def5e151
commit d48726c21c
2 changed files with 215 additions and 94 deletions

View File

@@ -452,8 +452,15 @@ try {
defeatedEnemies: '3',
totalEnemies: '5',
objectives: [
{ id: 'village', label: 'Village', achieved: true, detail: 12, rewardGold: '80' },
{ id: '', label: 'Broken', achieved: true }
{ id: 'village', label: 'Village', achieved: true, detail: 12, summary: 'x'.repeat(220), rewardGold: '80' },
{ id: '', label: 'Broken', achieved: true },
...Array.from({ length: 30 }, (_, index) => ({
id: `bonus-${index}`,
label: `Bonus ${index}`,
achieved: false,
detail: 'Hold the ridge',
rewardGold: 10
}))
],
units: [
{
@@ -473,11 +480,36 @@ try {
x: '2',
y: '3'
},
{ id: 'broken-unit', name: 'Broken' }
{ id: 'broken-unit', name: 'Broken' },
...Array.from({ length: 120 }, (_, index) => ({
id: `enemy-${index}`,
name: `Enemy ${index}`,
faction: 'enemy',
className: 'Infantry',
classKey: 'infantry',
level: 1,
exp: 0,
hp: 20,
maxHp: 20,
attack: 12,
move: 4,
stats: { might: 8, intelligence: 5, leadership: 6, agility: 7, luck: 5 },
equipment: {},
x: index % 12,
y: Math.floor(index / 12)
}))
],
bonds: [
{ id: 'liu-bei__guan-yu', title: 'Oath Bond', unitIds: ['liu-bei', 'guan-yu'], level: '2', exp: '30', battleExp: '4' },
{ id: 'broken-bond', title: 'Broken Bond', unitIds: ['liu-bei'] }
{ id: 'broken-bond', title: 'Broken Bond', unitIds: ['liu-bei'] },
...Array.from({ length: 120 }, (_, index) => ({
id: `bond-${index}`,
title: `Bond ${index}`,
unitIds: ['liu-bei', 'guan-yu'],
level: 1,
exp: 0,
battleExp: 1
}))
],
mvp: { unitId: 'liu-bei', name: 'Liu Bei', damageDealt: '88', defeats: '2' },
itemRewards: ['Bean', 'Bean', 10, 'x'.repeat(97)],
@@ -485,8 +517,16 @@ try {
supplies: [' Bean ', 'Bean', 20, 'x'.repeat(97)],
equipment: [' Iron Sword ', 'Iron Sword'],
reputation: ['Village Thanks', ' Village Thanks '],
recruits: [{ unitId: ' guan-yu ', name: ' Guan Yu ' }, { unitId: '', name: 'Broken' }],
unlocks: [{ battleId: ' second-battle-yellow-turban-pursuit ', title: ' Next ' }, { battleId: '', title: 'Broken' }],
recruits: [
{ unitId: ' guan-yu ', name: ' Guan Yu ' },
{ unitId: '', name: 'Broken' },
...Array.from({ length: 140 }, (_, index) => ({ unitId: `recruit-${index}`, name: `Recruit ${index}` }))
],
unlocks: [
{ battleId: ' second-battle-yellow-turban-pursuit ', title: ' Next ' },
{ battleId: '', title: 'Broken' },
...Array.from({ length: 140 }, (_, index) => ({ battleId: `battle-${index}`, title: `Battle ${index}` }))
],
note: ' Reward note '
},
completedCampDialogues: ['intro', 'intro', 7],
@@ -504,11 +544,12 @@ try {
malformedReport.firstBattleReport?.battleId === 'first-battle-zhuo-commandery' &&
malformedReport.firstBattleReport.battleTitle.length > 0 &&
malformedReport.firstBattleReport.turnNumber === 4 &&
malformedReport.firstBattleReport.objectives.length === 1 &&
malformedReport.firstBattleReport.objectives.length === 24 &&
malformedReport.firstBattleReport.objectives[0].rewardGold === 80 &&
malformedReport.firstBattleReport.units.length === 1 &&
malformedReport.firstBattleReport.objectives[0].summary.length === 180 &&
malformedReport.firstBattleReport.units.length === 96 &&
malformedReport.firstBattleReport.units[0].level === 5 &&
malformedReport.firstBattleReport.bonds.length === 1 &&
malformedReport.firstBattleReport.bonds.length === 96 &&
malformedReport.firstBattleReport.bonds[0].battleExp === 4 &&
malformedReport.firstBattleReport.mvp?.damageDealt === 88 &&
malformedReport.firstBattleReport.itemRewards.length === 1 &&
@@ -516,8 +557,9 @@ try {
malformedReport.firstBattleReport.campaignRewards?.supplies[0] === 'Bean' &&
malformedReport.firstBattleReport.campaignRewards?.equipment.length === 1 &&
malformedReport.firstBattleReport.campaignRewards?.reputation.length === 1 &&
malformedReport.firstBattleReport.campaignRewards?.recruits.length === 1 &&
malformedReport.firstBattleReport.campaignRewards?.recruits.length === 128 &&
malformedReport.firstBattleReport.campaignRewards?.recruits[0].unitId === 'guan-yu' &&
malformedReport.firstBattleReport.campaignRewards?.unlocks.length === 128 &&
malformedReport.firstBattleReport.campaignRewards?.unlocks[0].battleId === 'second-battle-yellow-turban-pursuit' &&
malformedReport.firstBattleReport.campaignRewards?.note === 'Reward note' &&
malformedReport.firstBattleReport.completedCampDialogues.length === 1 &&
@@ -589,15 +631,38 @@ try {
rewardGold: '80',
targetTile: { x: '4', y: '5', radius: '2' }
},
'broken-objective'
'broken-objective',
...Array.from({ length: 30 }, (_, index) => ({
id: `history-bonus-${index}`,
label: `History Bonus ${index}`,
achieved: false,
detail: 'Hold formation',
rewardGold: 5
}))
],
units: [
{ unitId: 'liu-bei', name: 'Liu Bei', level: '4', exp: '33', hp: '28', maxHp: '30', equipment: 'broken' },
{ unitId: '', name: 'Broken Unit', level: 99 }
{ unitId: '', name: 'Broken Unit', level: 99 },
...Array.from({ length: 120 }, (_, index) => ({
unitId: `history-unit-${index}`,
name: `History Unit ${index}`,
level: 1,
exp: 0,
hp: 12,
maxHp: 12,
equipment: {}
}))
],
bonds: [
{ id: 'oath-bond', title: 'Oath Bond', level: '2', exp: '22', battleExp: '4' },
{ id: '', title: 'Broken Bond' }
{ id: '', title: 'Broken Bond' },
...Array.from({ length: 120 }, (_, index) => ({
id: `history-bond-${index}`,
title: `History Bond ${index}`,
level: 1,
exp: 0,
battleExp: 1
}))
],
reserveTraining: [
{
@@ -611,7 +676,17 @@ try {
level: '5',
exp: '44'
},
'broken-training'
'broken-training',
...Array.from({ length: 120 }, (_, index) => ({
unitId: `reserve-${index}`,
name: `Reserve ${index}`,
expGained: 3,
equipmentExpGained: 1,
focusId: 'balanced',
focusLabel: 'Balanced',
level: 1,
exp: 3
}))
],
completedAt: '2026-07-04T01:00:00.000Z'
},
@@ -664,18 +739,18 @@ try {
`Expected stale latestBattleId to recover to the latest valid settlement: ${JSON.stringify(malformedHistory)}`
);
assert(
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.objectives.length === 1 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.objectives.length === 24 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.objectives[0].rewardGold === 80 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.objectives[0].targetTile?.x === 4 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.objectives[0].status === undefined &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units.length === 1 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units.length === 96 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].level === 4 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].equipment.weapon.itemId === 'training-sword' &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].equipment.armor.itemId === 'cloth-armor' &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].equipment.accessory.itemId === 'grain-pouch' &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds.length === 1 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds.length === 96 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds[0].battleExp === 4 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.reserveTraining?.length === 1 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.reserveTraining?.length === 96 &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.reserveTraining?.[0].focusId === 'balanced',
`Expected nested battle history progress arrays to filter invalid entries and normalize numbers: ${JSON.stringify(malformedHistory)}`
);