feat: complete campaign flow and optimize battle assets
This commit is contained in:
@@ -35,6 +35,16 @@ try {
|
||||
assert(normalizeBattleSaveSlot(Number.NaN, 3) === 1, 'Expected NaN slot to normalize to slot 1.');
|
||||
assert(normalizeBattleSaveSlot(99, 3) === 3, 'Expected overflowing slot to clamp to slot count.');
|
||||
assert(isValidBattleSaveState(validState, options), 'Expected valid battle save to pass validation.');
|
||||
const parsedProgressedStats = parseBattleSaveState(JSON.stringify(validState), options)?.units[0]?.stats;
|
||||
assert(
|
||||
JSON.stringify(parsedProgressedStats) === JSON.stringify(validState.units[0].stats),
|
||||
'Expected battle-earned unit attributes to round-trip through battle-save parsing.'
|
||||
);
|
||||
const legacyUnitsWithoutStats = validState.units.map(({ stats: _stats, ...unit }) => unit);
|
||||
assert(
|
||||
isValidBattleSaveState({ ...validState, units: legacyUnitsWithoutStats }, options),
|
||||
'Expected legacy battle saves without unit attributes to remain valid.'
|
||||
);
|
||||
const validCompletedAttackHistoryState = {
|
||||
...validState,
|
||||
actedUnitIds: ['liu-bei', 'guan-yu'],
|
||||
@@ -361,6 +371,9 @@ try {
|
||||
['invalid unit attack', { units: patchUnit(0, { attack: -1 }) }],
|
||||
['invalid unit move precision', { units: patchUnit(0, { move: 3.5 }) }],
|
||||
['too high unit move', { units: patchUnit(0, { move: 100 }) }],
|
||||
['invalid unit stats shape', { units: patchUnit(0, { stats: { might: 80 } }) }],
|
||||
['invalid unit stats precision', { units: patchUnit(0, { stats: { ...validState.units[0].stats, agility: 72.5 } }) }],
|
||||
['too high unit stat', { units: patchUnit(0, { stats: { ...validState.units[0].stats, might: 1000 } }) }],
|
||||
['duplicate live unit tile', { units: patchUnit(1, { x: validState.units[0].x, y: validState.units[0].y }) }],
|
||||
['invalid unit x', { units: patchUnit(0, { x: 12 }) }],
|
||||
['invalid unit direction', { units: patchUnit(0, { direction: 'down' }) }],
|
||||
@@ -567,6 +580,7 @@ function createValidBattleSaveState() {
|
||||
maxHp: 30,
|
||||
attack: 10,
|
||||
move: 4,
|
||||
stats: { might: 78, intelligence: 82, leadership: 85, agility: 72, luck: 88 },
|
||||
x: 1,
|
||||
y: 2,
|
||||
direction: 'south',
|
||||
@@ -580,6 +594,7 @@ function createValidBattleSaveState() {
|
||||
maxHp: 34,
|
||||
attack: 14,
|
||||
move: 4,
|
||||
stats: { might: 97, intelligence: 76, leadership: 92, agility: 73, luck: 69 },
|
||||
x: 2,
|
||||
y: 2,
|
||||
direction: 'south',
|
||||
@@ -593,6 +608,7 @@ function createValidBattleSaveState() {
|
||||
maxHp: 20,
|
||||
attack: 8,
|
||||
move: 3,
|
||||
stats: { might: 52, intelligence: 34, leadership: 39, agility: 46, luck: 41 },
|
||||
x: 8,
|
||||
y: 4,
|
||||
direction: 'west',
|
||||
|
||||
Reference in New Issue
Block a user