Prefer boostable city sources when reclaiming influence
This commit is contained in:
parent
4d8939c5dd
commit
f91c47dd42
6 changed files with 22 additions and 5 deletions
|
|
@ -333,3 +333,5 @@ Viewer 0.1.106 simplifies cultural influence confirmation: editable source/targe
|
|||
Viewer 0.1.107 simplifies move/attack previews: coordinates appear once in the route, payment choices are labelled and selected visibly, defenders have a compact heading, and terrain details expand on demand. The final move/attack button includes the selected cost and stays outside the scrolling content. Desktop/mobile Roads attack checks verify payment selection does not submit prematurely and confirmation stays visible. Engine remains 0.4.80.
|
||||
|
||||
Viewer 0.1.108 / engine 0.4.81 fixes pirate events when Carthage controls pirate ships. Removal only recycles neutral ships; placement checks remaining supply before each ship. All four allied ships suppress placement, and three allies permit only one new pirate. Tests cover zero to four allied ships with both empty and full remaining neutral supply, including supply released by Hegemony.
|
||||
|
||||
Viewer 0.1.109 defaults reclaim attempts to the cheapest eligible other city that permits roll boosts. Self-targeting remains available and is the fallback when no boostable city exists; explicit source selections are preserved. The cheaper-source warning no longer recommends losing roll boosts just to save range cost. Influence regression tests and Svelte/build checks pass. Engine remains 0.4.81.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.108",
|
||||
"version": "0.1.109",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.108",
|
||||
"version": "0.1.109",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.108",
|
||||
"version": "0.1.109",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
</button>{/each}
|
||||
</div>{/if}
|
||||
{#if !paymentStep}
|
||||
<p class="movement-hint">Choose the source on the map or above. The lowest-cost source is preselected.</p>
|
||||
<p class="movement-hint">Choose a source on the map or above. When reclaiming, another city is preferred so you can boost the roll.</p>
|
||||
<button class="primary wide" onclick={() => paymentStep = true}>Choose payment<ArrowRight size={16} /></button>
|
||||
{:else}
|
||||
<div class="decision-options influence-methods" aria-label="Influence payment method">
|
||||
|
|
|
|||
|
|
@ -178,6 +178,13 @@ test('reclaiming influence allows another city and boosting, but self-targeting
|
|||
const self = target.origins!.find((o) => o.position === 'C1');
|
||||
assert.ok(other, 'another uninfluenced city is an available source');
|
||||
assert.ok(self, 'the influenced city can still target itself');
|
||||
assert.equal(bestInfluenceOrigin(target)?.position, 'A1', 'prefer a boostable city even with a range fee');
|
||||
assert.equal(cheaperInfluenceOrigin(target, other), null, 'do not recommend unboostable self-targeting just to save range');
|
||||
assert.equal(bestInfluenceOrigin({ ...target, origins: [self] })?.position, 'C1', 'fall back to self when necessary');
|
||||
assert.equal(bestInfluenceOrigin({ ...target, origins: [self, { ...other, preventBoost: true }] })?.position, 'C1', 'do not pay extra when the other source cannot boost');
|
||||
const selection = {view: view(g), mode: 'overview', abilitiesOpen: true, influenceMode: true, influenceTarget: influenceKey(target)} as Session;
|
||||
assert.equal(activeInfluence(selection)?.source, 'A1');
|
||||
assert.equal(activeInfluence({...selection, influenceOrigin: 'C1'})?.source, 'C1', 'respect explicit self-targeting');
|
||||
let state = move(g, other.action);
|
||||
if (view(state).influenceContext?.stage === 'range')
|
||||
state = move(state, { Response: { Payment: [other.payment] } });
|
||||
|
|
|
|||
|
|
@ -39,7 +39,13 @@ export const influenceDestinationKey = (offer: InfluenceOffer) => `${offer.posit
|
|||
export function bestInfluenceOrigin(offer: InfluenceOffer) {
|
||||
const cost = (o: NonNullable<InfluenceOffer['origins']>[number]) =>
|
||||
Object.values(influenceUpfrontCost(o.actionPayment, o.payment)).reduce((sum, n) => sum + (n ?? 0), 0);
|
||||
return [...(offer.origins ?? [])].sort((a, b) => cost(a) - cost(b) || Number(!!b.free) - Number(!!a.free))[0] ?? null;
|
||||
const origins = offer.origins ?? [];
|
||||
const reclaiming = origins.some(o => o.position === offer.position);
|
||||
const boostableCities = reclaiming
|
||||
? origins.filter(o => o.position !== offer.position && !o.settlers && !o.preventBoost)
|
||||
: [];
|
||||
return [...(boostableCities.length ? boostableCities : origins)]
|
||||
.sort((a, b) => cost(a) - cost(b) || Number(!!b.free) - Number(!!a.free))[0] ?? null;
|
||||
}
|
||||
export function influenceDestinations(offers: InfluenceOffer[]) {
|
||||
return offers.filter((o, i) => offers.findIndex(other => influenceDestinationKey(other) === influenceDestinationKey(o)) === i);
|
||||
|
|
@ -118,6 +124,8 @@ export function cheaperInfluenceOrigin(
|
|||
.filter(
|
||||
(from) =>
|
||||
!from.settlers &&
|
||||
// Self-targeting loses the ability to boost, so it is not an equivalent saving.
|
||||
!(from.position === offer.position && selected?.position !== offer.position && !selected?.preventBoost) &&
|
||||
from.position !== (selected?.position ?? offer.origin) &&
|
||||
(from.payment.culture_tokens ?? 0) < currentCost,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue