Anchor generic resource gains above the main city
This commit is contained in:
parent
cb703313d3
commit
df1d6b462a
6 changed files with 35 additions and 8 deletions
|
|
@ -607,3 +607,10 @@ Negotiations now protects the partner's cities even when no units occupy them,
|
|||
including cities defended only by a fortress. Regression tests verify that both
|
||||
fortified and unfortified cities are reachable before Negotiations but blocked
|
||||
on the opponent's turn while the effect is active.
|
||||
|
||||
## Viewer 0.1.179
|
||||
|
||||
Generic resource gains appear above the civilization's oldest remaining city in
|
||||
the displayed board state. Tile-specific gains keep their existing positions;
|
||||
players without cities retain the screen-position fallback. Replay uses its
|
||||
historical cities. All 14 resource tests and UI checks pass. Engine stays 0.4.121.
|
||||
|
|
|
|||
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.178",
|
||||
"version": "0.1.179",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.178",
|
||||
"version": "0.1.179",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.178",
|
||||
"version": "0.1.179",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { mount, unmount } from 'svelte';
|
|||
import ResourceGainBadge from './ResourceGainBadge.svelte';
|
||||
import { positionXY } from './model';
|
||||
import { playerColor, type Session } from './types';
|
||||
import type { ResourceMarker } from './resource-playback';
|
||||
import { resourceMarkerPosition, type ResourceMarker } from './resource-playback';
|
||||
|
||||
export class ResourceOverlay {
|
||||
private nodes: { node: HTMLDivElement; at: THREE.Vector3 | null; component: ReturnType<typeof mount> }[] = [];
|
||||
|
|
@ -29,7 +29,9 @@ export class ResourceOverlay {
|
|||
groups.set(key, [...(groups.get(key) ?? []), marker]);
|
||||
}
|
||||
for (const group of groups.values()) {
|
||||
const { player, position } = group[0];
|
||||
const { player } = group[0];
|
||||
const players = s.playback?.frame?.players ?? s.game?.players ?? [];
|
||||
const position = resourceMarkerPosition(group[0], players);
|
||||
const node = document.createElement('div');
|
||||
if (position) node.dataset.position = position;
|
||||
Object.assign(node.style, { position: 'absolute', left: '0', top: '0', visibility: 'hidden' });
|
||||
|
|
@ -41,7 +43,7 @@ export class ResourceOverlay {
|
|||
markers: group,
|
||||
animate,
|
||||
transient: !s.playback,
|
||||
civilization: s.game?.players.find((p) => p.id === player)?.civilization ?? 'Player',
|
||||
civilization: players.find((p) => p.id === player)?.civilization ?? 'Player',
|
||||
},
|
||||
});
|
||||
const [x, z] = position ? positionXY(position) : [0, 0];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { frameResources, describeResources } from './resource-playback.ts';
|
||||
import { frameResources, describeResources, resourceMarkerPosition } from './resource-playback.ts';
|
||||
import { groupPlaybackFrames, playbackSteps } from './replay-actions.ts';
|
||||
import { frameDetails, frameEffects, sinceLastTurn, recapStart } from './playback.ts';
|
||||
import type { Game, LoggedAction } from './types.ts';
|
||||
|
|
@ -319,3 +319,16 @@ test('bartering and research rewards show unanchored icons with actual gains, ex
|
|||
assert.deepEqual(frameResources(game, 1, game.board_history!.frames[2]).markers,
|
||||
[{ player: 1, resource: 'ideas', amount: 1 }, { player: 1, resource: 'mood_tokens', amount: 1 }]);
|
||||
});
|
||||
|
||||
test('generic resource markers follow the displayed player main city, preserving specific locations', () => {
|
||||
const marker = { player: 1, resource: 'gold' as const, amount: 2 };
|
||||
const players = [{ id: 1, civilization: 'Rome', cities: [
|
||||
{ position: 'B1', mood_state: 'Happy' }, { position: 'C2', mood_state: 'Neutral' },
|
||||
] }];
|
||||
assert.equal(resourceMarkerPosition(marker, players), 'B1');
|
||||
assert.equal(resourceMarkerPosition({ ...marker, position: 'D3' }, players), 'D3');
|
||||
players[0].cities.shift();
|
||||
assert.equal(resourceMarkerPosition(marker, players), 'C2');
|
||||
assert.equal(resourceMarkerPosition(marker, []), undefined);
|
||||
assert.equal(resourceMarkerPosition(marker, [{ ...players[0], cities: [] }]), undefined);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { publicActions, playingAction } from './replay-actions.ts';
|
||||
import { resources, resourceNames, type BoardFrame, type Game, type Pile, type Resource } from './types.ts';
|
||||
import { resources, resourceNames, type BoardFrame, type Game, type Pile, type Player, type Resource } from './types.ts';
|
||||
|
||||
export interface ResourceMarker {
|
||||
player: number;
|
||||
|
|
@ -7,6 +7,11 @@ export interface ResourceMarker {
|
|||
resource: Resource;
|
||||
amount: number;
|
||||
}
|
||||
/** Generic gains follow the oldest remaining city in the displayed board state. */
|
||||
export function resourceMarkerPosition(marker: ResourceMarker, players: Player[]): string | undefined {
|
||||
return marker.position ?? players.find((player) => player.id === marker.player)?.cities?.[0]?.position;
|
||||
}
|
||||
|
||||
export interface ResourceGain {
|
||||
player: number;
|
||||
pile: Pile;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue