import { endLevelCarryover, carryoverIntoScenario } from '@datamoc/mw_games/mwl';
const world = {
variables: {},
gold: { '1': 200 },
sides: { '1': { gold: 0, income: 2, controller: 'human' } },
units: { hero: { hp: 30, x: 1, y: 1, alive: true, side: '1' } },
maps: {},
turn: 1,
status: 'playing' as const,
};
const carried = endLevelCarryover(world, { id: '1' }, {
result: 'victory',
bonus: 50,
nextScenario: 'siege',
});
console.log(carried.gold); // 210 - 50 bonus plus 80% of 200
console.log(carried.recall); // ['hero'] - still standing, so it comes back
console.log(carryoverIntoScenario(carried, 100)); // 210 - the larger of the two, not the sum
Works out what a finished scenario hands on:
bonuspluscarryover_percentageof the side's gold, the units of that side still standing, and where the campaign goes next.A side of
nullis a scenario that ended without one (no[side], nothing human-controlled): the result and the next scenario are still recorded, with no gold and nobody to recall.