Verify unlock reward settlement
This commit is contained in:
@@ -108,6 +108,14 @@ try {
|
|||||||
resetCampaignState();
|
resetCampaignState();
|
||||||
const firstScenario = battleScenarios['first-battle-zhuo-commandery'];
|
const firstScenario = battleScenarios['first-battle-zhuo-commandery'];
|
||||||
const alliedFirstBattleUnits = firstScenario.units.filter((unit) => unit.faction === 'ally');
|
const alliedFirstBattleUnits = firstScenario.units.filter((unit) => unit.faction === 'ally');
|
||||||
|
const firstScenarioUnlocks = firstScenario.campaignReward?.unlockBattleId
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
battleId: firstScenario.campaignReward.unlockBattleId,
|
||||||
|
title: firstScenario.campaignReward.unlockLabel ?? battleScenarios[firstScenario.campaignReward.unlockBattleId].title
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: [];
|
||||||
const firstBattleReport = {
|
const firstBattleReport = {
|
||||||
battleId: firstScenario.id,
|
battleId: firstScenario.id,
|
||||||
battleTitle: firstScenario.title,
|
battleTitle: firstScenario.title,
|
||||||
@@ -120,7 +128,7 @@ try {
|
|||||||
units: alliedFirstBattleUnits,
|
units: alliedFirstBattleUnits,
|
||||||
bonds: firstScenario.bonds.map((bond) => ({ ...bond, battleExp: 0 })),
|
bonds: firstScenario.bonds.map((bond) => ({ ...bond, battleExp: 0 })),
|
||||||
itemRewards: ['Bean x2', 'Iron Sword 1'],
|
itemRewards: ['Bean x2', 'Iron Sword 1'],
|
||||||
campaignRewards: { supplies: ['Bean x2'], equipment: ['Iron Sword 1'], reputation: [], recruits: [], unlocks: [] },
|
campaignRewards: { supplies: ['Bean x2'], equipment: ['Iron Sword 1'], reputation: [], recruits: [], unlocks: firstScenarioUnlocks },
|
||||||
completedCampDialogues: [],
|
completedCampDialogues: [],
|
||||||
completedCampVisits: [],
|
completedCampVisits: [],
|
||||||
createdAt: '2026-07-03T09:00:00.000Z'
|
createdAt: '2026-07-03T09:00:00.000Z'
|
||||||
@@ -135,11 +143,17 @@ try {
|
|||||||
repeatedSettlement.battleHistory[firstScenario.id]?.rewardGold === 100,
|
repeatedSettlement.battleHistory[firstScenario.id]?.rewardGold === 100,
|
||||||
`Expected repeated battle report settlement to avoid duplicate gold/items: ${JSON.stringify(repeatedSettlement)}`
|
`Expected repeated battle report settlement to avoid duplicate gold/items: ${JSON.stringify(repeatedSettlement)}`
|
||||||
);
|
);
|
||||||
|
assert(
|
||||||
|
repeatedSettlement.firstBattleReport?.campaignRewards?.unlocks[0]?.battleId === 'second-battle-yellow-turban-pursuit' &&
|
||||||
|
repeatedSettlement.firstBattleReport.campaignRewards.unlocks[0].title === firstScenarioUnlocks[0]?.title &&
|
||||||
|
repeatedSettlement.battleHistory[firstScenario.id]?.campaignRewards?.unlocks[0]?.battleId === 'second-battle-yellow-turban-pursuit',
|
||||||
|
`Expected campaign unlock rewards to survive repeated battle report settlement: ${JSON.stringify(repeatedSettlement)}`
|
||||||
|
);
|
||||||
setFirstBattleReport({
|
setFirstBattleReport({
|
||||||
...firstBattleReport,
|
...firstBattleReport,
|
||||||
rewardGold: 140,
|
rewardGold: 140,
|
||||||
itemRewards: ['Bean x3', 'Wine', 'Iron Armor 1'],
|
itemRewards: ['Bean x3', 'Wine', 'Iron Armor 1'],
|
||||||
campaignRewards: { supplies: ['Bean x3', 'Wine'], equipment: ['Iron Armor 1'], reputation: [], recruits: [], unlocks: [] }
|
campaignRewards: { supplies: ['Bean x3', 'Wine'], equipment: ['Iron Armor 1'], reputation: [], recruits: [], unlocks: firstScenarioUnlocks }
|
||||||
});
|
});
|
||||||
const revisedSettlement = getCampaignState();
|
const revisedSettlement = getCampaignState();
|
||||||
assert(
|
assert(
|
||||||
|
|||||||
Reference in New Issue
Block a user