Round CHOAM income after totaling eligible support

This commit is contained in:
Quintine committed 2026-10-27 10:59:21 +11:00
1 parent 54787c7f7b
commit dff0c77a5b
8 files changed
+161 -26

No files matched your search

+11
View File
@@ -297,6 +297,17 @@ void test('Habbanya selects ordinary and Stone ties; canceled free-support and e
{ normal: 2, elite: 1, paidNormal: 0, paidElite: 0 },
]);
});
void test('CHOAM quotes half of the total other-faction support with one final floor', () => {
const g = input();
g.participants = [...g.participants, { id: 'c', faction: 'choam' }];
g.attacker.plan.dial = g.attacker.plan.support = 3;
g.defender.plan.dial = g.defender.plan.support = 5;
const before = structuredClone(g), q = quoteBattleResolution(g);
assert.deepEqual(q.choamIncome, { owner: 'c', amount: 4 });
assert.deepEqual(q.payments.map(payment => payment.ownPayment), [3, 5]);
assert.deepEqual(q.payments.map(payment => payment.bankSupport), [0, 0]);
assert.deepEqual(g, before);
});
void test('funding consumes explicit current escrow and includes Stronghold bank support in CHOAM income without debiting the bank or donor twice', () => {
const g = input();
g.participants = [
+16 -4
View File
@@ -196,16 +196,28 @@ void test('the ally can choose CHOAM to pay despite having its own spice; forged
assert.equal(result.response, null);
assert.equal(player(result, 'c').spice, 7); // Six after funding, plus one from opponent; no self rebate.
});
void test('income rounds down each other player payment and is collected only once after combat choices', () => {
void test('income rounds down the combined support and is collected only once after combat choices', () => {
let g = settle(plan(plan(start(fixture(false)), 'g', 3), 'e', 3));
assert.equal(g.response, null);
assert.equal(player(g, 'c').spice, 12); // No cancellation choice: income settles immediately.
assert.equal(player(g, 'c').spice, 13); // Half of 3 + 3; uncontested income settles immediately.
assert.equal(player(g, 'g').spice, 7);
assert.equal(player(g, 'e').spice, 7);
g = allow(g);
assert.equal(player(g, 'c').spice, 12);
assert.equal(player(g, 'c').spice, 13);
assert.equal(g.pendingChoamBattleIncome, null);
assert.equal(g.decision?.kind, 'choamMarket');
g = send(g, 'c', { type: 'decision', done: true });
assert.equal(player(g, 'c').spice, 12);
assert.equal(player(g, 'c').spice, 13);
});
void test('two other combatants paying three and five yield four CHOAM income without changing either debit', () => {
let g = settle(plan(plan(start(fixture(false)), 'g', 3), 'e', 5));
assert.equal(player(g, 'c').spice, 14);
assert.equal(player(g, 'g').spice, 7);
assert.equal(player(g, 'e').spice, 5);
assert.equal(g.pendingChoamBattleIncome, null);
assert.equal(g.decision?.kind, 'choamMarket');
g = send(g, 'c', { type: 'decision', done: true });
assert.equal(player(g, 'c').spice, 14);
});
void test('Karama redirects just this battle income to the bank without refunding force payments', () => {
const initial = fixture(false);