Show adjacent exploration arrows in sea route guide
This commit is contained in:
parent
ed097a2a8f
commit
97d79a58f9
6 changed files with 56 additions and 5 deletions
|
|
@ -393,3 +393,5 @@ Viewer 0.1.136 shows current food / storage limit with the food icon beside each
|
|||
Viewer 0.1.137 aligns recipient food counts beside the selection checkbox rather than stretching the count across half the row.
|
||||
|
||||
Viewer 0.1.140 adds the Market trade-income bonus and its per-opponent-turn limit to the compact building description in every supported language.
|
||||
|
||||
Viewer 0.1.141 adds arrows from sea spaces to every adjacent unexplored hex in the sea-route guide, alongside existing Navigation perimeter routes.
|
||||
|
|
|
|||
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.140",
|
||||
"version": "0.1.141",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.140",
|
||||
"version": "0.1.141",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.140",
|
||||
"version": "0.1.141",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as THREE from 'three';
|
||||
import { positionXY } from './model.ts';
|
||||
import { seaArea, seaConnections, seaEdgePoint } from './sea-routes.ts';
|
||||
import { seaArea, seaConnections, seaEdgePoint, seaExplorationConnections } from './sea-routes.ts';
|
||||
import type { Terrain } from './types';
|
||||
|
||||
/** Read-only geography overlay. It never creates or submits game actions. */
|
||||
|
|
@ -45,6 +45,24 @@ export class SeaOverlay {
|
|||
const material = this.material([from, to], '#e5faf2', 0.8);
|
||||
this.group.add(new THREE.Mesh(new THREE.TubeGeometry(curve, 1, 0.032, 5, false), material));
|
||||
}
|
||||
|
||||
for (const [from, to] of seaExplorationConnections(tiles)) {
|
||||
const start = point(from), end = point(to);
|
||||
const direction = end.clone().sub(start).normalize();
|
||||
const material = this.material([from], '#725226', 0.9);
|
||||
const tip = end.clone().addScaledVector(direction, -0.3);
|
||||
const base = tip.clone().addScaledVector(direction, -0.32);
|
||||
const side = new THREE.Vector3(-direction.z, 0, direction.x).multiplyScalar(0.18);
|
||||
for (const [a, b] of [
|
||||
[start.clone().addScaledVector(direction, 0.65), tip],
|
||||
[base.clone().add(side), tip],
|
||||
[base.clone().sub(side), tip],
|
||||
]) {
|
||||
this.group.add(new THREE.Mesh(
|
||||
new THREE.TubeGeometry(new THREE.LineCurve3(a, b), 1, 0.033, 5, false), material,
|
||||
));
|
||||
}
|
||||
}
|
||||
const seen = new Set<string>();
|
||||
for (const path of paths) {
|
||||
const from = path[0],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { seaArea, seaConnections } from './sea-routes.ts';
|
||||
import { seaArea, seaConnections, seaExplorationConnections } from './sea-routes.ts';
|
||||
import { SeaOverlay } from './sea-overlay.ts';
|
||||
import * as THREE from 'three';
|
||||
|
||||
|
|
@ -53,3 +53,22 @@ test('sea previews work before enabling the guide, hide unrelated routes and cle
|
|||
overlay.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('sea exploration includes every adjacent hidden hex without crossing hidden land', () => {
|
||||
const tiles: [string, import('./types').Terrain][] = [
|
||||
['D2', 'Water'], ['C2', 'Unexplored'], ['D3', 'Unexplored'],
|
||||
['E2', 'Unexplored'], ['F2', 'Unexplored'], ['C1', 'Mountain'],
|
||||
];
|
||||
assert.deepEqual(seaExplorationConnections(tiles).map(([, to]) => to).sort(), ['C2', 'D3', 'E2']);
|
||||
const overlay = new SeaOverlay();
|
||||
try {
|
||||
overlay.update(tiles, []);
|
||||
overlay.setFocus('D2');
|
||||
assert.equal(overlay.group.children.filter((o) => o instanceof THREE.Mesh &&
|
||||
o.geometry instanceof THREE.TubeGeometry &&
|
||||
(o.material as THREE.MeshBasicMaterial).opacity > 0).length, 9);
|
||||
overlay.setFocus('G8');
|
||||
assert.equal(overlay.group.visible, false);
|
||||
} finally { overlay.dispose(); }
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,3 +46,15 @@ export function seaEdgePoint(position: string, tiles: [string, Terrain][]): [num
|
|||
const length = Math.hypot(dx, dz) || 1;
|
||||
return [x + (dx / length) * 1.35, z + (dz / length) * 1.35];
|
||||
}
|
||||
|
||||
|
||||
// Adjacent exploration uses only visible terrain; never inspect a hidden region.
|
||||
export function seaExplorationConnections(tiles: [string, Terrain][]): [string, string][] {
|
||||
const hidden = tiles.filter(([, terrain]) => terrain === 'Unexplored').map(([p]) => p);
|
||||
return tiles.filter(([, terrain]) => terrain === 'Water').flatMap(([from]) =>
|
||||
hidden.filter((to) => {
|
||||
const a = positionXY(from), b = positionXY(to);
|
||||
return Math.abs((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 - 3) < 0.001;
|
||||
}).map((to): [string, string] => [from, to]),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue