diff --git a/app/components/map/InfoCard.vue b/app/components/map/InfoCard.vue index b53c9b7..990c6fb 100644 --- a/app/components/map/InfoCard.vue +++ b/app/components/map/InfoCard.vue @@ -25,7 +25,7 @@ const { current } = useCurrentWorld()
{{ $t('map.info.relation') }}
- {{ $t(`map.legend.${village.relation}`) }} + {{ $t(`map.legend.${village.relation}`) }}
{{ $t('map.info.points') }}
{{ village.points }}
diff --git a/app/components/map/LegendSwatch.vue b/app/components/map/LegendSwatch.vue new file mode 100644 index 0000000..67d34fe --- /dev/null +++ b/app/components/map/LegendSwatch.vue @@ -0,0 +1,20 @@ + + + + diff --git a/app/components/map/VillageDefs.vue b/app/components/map/VillageDefs.vue new file mode 100644 index 0000000..dabdc61 --- /dev/null +++ b/app/components/map/VillageDefs.vue @@ -0,0 +1,22 @@ + + + + diff --git a/app/components/map/Villages.vue b/app/components/map/Villages.vue new file mode 100644 index 0000000..149a96d --- /dev/null +++ b/app/components/map/Villages.vue @@ -0,0 +1,15 @@ + + + + diff --git a/app/diorama/mapVillage.ts b/app/diorama/mapVillage.ts new file mode 100644 index 0000000..0cd2d8f --- /dev/null +++ b/app/diorama/mapVillage.ts @@ -0,0 +1,484 @@ +// Villages on the world map, seen from above like the village pictures on the Die Stämme +// map: a predefined picture per points tier (six, like its v1 to v6), hand-placed, not +// generated from counts. A round plot of trodden earth fills the field, its edge in the +// relation colour; on it the roofs seen from above (two halves either side of the ridge, or +// four facets of a hipped roof, lit from the upper left like the village, a flat shadow to +// the lower right), the yard, paths to the gate and gardens; a stake palisade from the third +// tier, a stone wall with towers from the fifth, the headquarters the biggest roof in the +// middle with the flag. Barbarian villages have the same layouts worn: darker, roofs gone +// grey and broken, a house burnt down, weeds in the yard, gaps in the palisade, no flag. +// Crown forts are a stone keep in a walled ring. Each look is drawn once as an SVG +// (`MapVillageDefs`) and placed with ; the relation colour (the plot's edge and the flag) +// is `currentColor`, set per village. Two variants per tier, mirrored, picked by the village +// id. Units: a field is 100 × 100, the plot's centre at 0|0. + +import { mix, scale } from './iso' +import { C } from './models' + +export type MapTier = 1 | 2 | 3 | 4 | 5 | 6 + +/** One path of a look: the shapes of one colour and layer, merged into one element. */ +export interface MapVillageShape { + d: string + fill?: string + stroke?: string + width?: number + dash?: string +} + +export interface MapVillageLook { + id: string + shapes: MapVillageShape[] +} + +/** Lowest points of tiers 2 to 6; below the first, tier 1. */ +export const MAP_TIER_POINTS = [300, 1000, 3000, 6000, 10000] as const + +/** Six sizes by points, like the village pictures on the Die Stämme map. */ +export const mapTier = (points: number): MapTier => (MAP_TIER_POINTS.findIndex((p) => points < p) + 1 || 6) as MapTier + +/** The relation colour, set on each . */ +const OWNER = 'currentColor' +/** Stands for the shadow colour of the plot's earth until the look is built. */ +const SHADOW = 'shadow' +/** The plot's dark rim, so every relation colour stands off the grass. */ +const RIM = '#2b2118' +const EARTH = '#6c5940' +const EARTH_WORN = '#574a3a' +/** Paths, the plaza and the yard: trodden lighter. */ +const PATH = '#806a4c' +const PATH_WORN = '#655542' +const WEEDS = '#575c3c' +/** Weathered grey that a barbarian village's roofs fade to. */ +const WEATHER = '#77726a' + +// Light from the upper left, as in the village: what faces it keeps its colour, what faces +// away drops to two thirds and cools a little, the rest in between. +const LIGHT: [number, number] = [-0.6, -0.8] +function tone(base: string, nx: number, ny: number): string { + const d = nx * LIGHT[0] + ny * LIGHT[1] + return d > 0.35 ? scale(base, 1.05) : d < -0.35 ? mix(scale(base, 0.64), '#2a3038', 0.12) : scale(base, 0.84) +} + +type Pt = [number, number] +const f = (n: number) => (Math.round(n * 10) / 10).toString() +const poly = (pts: Pt[]) => `M${pts.map(([x, y]) => `${f(x)} ${f(y)}`).join('L')}Z` +const line = (pts: Pt[]) => `M${pts.map(([x, y]) => `${f(x)} ${f(y)}`).join('L')}` +const circle = (cx: number, cy: number, r: number) => `M${f(cx - r)} ${f(cy)}a${f(r)} ${f(r)} 0 1 0 ${f(2 * r)} 0a${f(r)} ${f(r)} 0 1 0 ${f(-2 * r)} 0Z` +const box = (cx: number, cy: number, hw: number, hh: number) => poly([[cx - hw, cy - hh], [cx + hw, cy - hh], [cx + hw, cy + hh], [cx - hw, cy + hh]]) +/** An arc round the plot's centre (or moved by dx|dy, for its shadow) from angle a0 to a1 (radians, clockwise on screen). */ +function arc(r: number, a0: number, a1: number, dx = 0, dy = 0) { + const p = (a: number) => `${f(dx + Math.cos(a) * r)} ${f(dy + Math.sin(a) * r)}` + return `M${p(a0)}A${f(r)} ${f(r)} 0 ${a1 - a0 > Math.PI ? 1 : 0} 1 ${p(a1)}` +} +const rotate = ([x, y]: Pt, a: number): Pt => [x * Math.cos(a) - y * Math.sin(a), x * Math.sin(a) + y * Math.cos(a)] + +// Painter's layers, bottom to top. Shapes within a layer never overlap, so each colour of a +// layer can be one path. +const enum L { + Base, + Ground, + Furrows, + Shadow, + Edge, + Wall, + Roof, + Ridge, + Tower, + Top, +} + +/** Collects a look's shapes, merged by layer and style. */ +class Picture { + private parts = new Map; d: string }>() + constructor( + /** Variant 1 is the mirror image of variant 0, lit the same way. */ + readonly mirror: boolean, + readonly worn: boolean, + ) {} + x = (x: number) => (this.mirror ? -x : x) + add(layer: L, style: Omit, d: string) { + if (!d) return + const key = `${layer}|${style.fill}|${style.stroke}|${style.width}|${style.dash}` + const part = this.parts.get(key) + if (part) part.d += d + else this.parts.set(key, { layer, order: this.parts.size, style, d }) + } + shapes(shadow: string): MapVillageShape[] { + return [...this.parts.values()] + .sort((a, b) => a.layer - b.layer || a.order - b.order) + .map((p) => ({ d: p.d, ...p.style, ...(p.style.fill === SHADOW ? { fill: shadow } : {}), ...(p.style.stroke === SHADOW ? { stroke: shadow } : {}) })) + } +} + +type Material = 'thatch' | 'tile' | 'shingle' | 'slate' +const MATERIAL: Record = { thatch: C.thatch, tile: C.roofRed, shingle: C.shingle, slate: C.slate } + +interface RoofSpec { + /** Centre on the plot (mirrored in variant 1). */ + at: Pt + /** Size along the ridge and across it. */ + w: number + d: number + /** Turn in degrees, clockwise. */ + turn?: number + material: Material + /** Gable: two halves; hip: four facets. */ + hip?: boolean + /** How high it stands, for its shadow. */ + height?: number + /** In a barbarian village: burnt down to its walls. */ + burnt?: boolean + /** In a barbarian village: a hole in the roof. */ + hole?: boolean +} + +/** A roof seen from above, its shadow on the ground and its ridge. */ +function roof(p: Picture, s: RoofSpec) { + const a = ((p.mirror ? -(s.turn ?? 0) : (s.turn ?? 0)) * Math.PI) / 180 + const cx = p.x(s.at[0]) + const cy = s.at[1] + const at = (x: number, y: number): Pt => { + const [rx, ry] = rotate([x, y], a) + return [cx + rx, cy + ry] + } + const hw = s.w / 2 + const hd = s.d / 2 + const h = s.height ?? Math.min(s.w, s.d) * 0.6 + const corners = [at(-hw, -hd), at(hw, -hd), at(hw, hd), at(-hw, hd)] + p.add(L.Shadow, { fill: SHADOW }, poly(corners.map(([x, y]) => [x + h * 0.42, y + h * 0.3]))) + if (p.worn && s.burnt) { + // Charred walls round the ash, a fallen beam or two across. + p.add(L.Roof, { fill: C.char }, poly(corners)) + p.add(L.Ridge, { fill: C.ash }, poly([at(-hw + 1.6, -hd + 1.6), at(hw - 1.6, -hd + 1.6), at(hw - 1.6, hd - 1.6), at(-hw + 1.6, hd - 1.6)])) + p.add(L.Tower, { stroke: C.char, width: 1.2 }, line([at(-hw + 1, -hd * 0.3), at(hw - 2, hd * 0.5)]) + line([at(-hw * 0.3, -hd + 1), at(hw * 0.1, hd - 1)])) + return + } + const base = p.worn ? scale(mix(MATERIAL[s.material], WEATHER, 0.5), 0.88) : MATERIAL[s.material] + const facet = (pts: Pt[], nx: number, ny: number) => { + const [ex, ey] = rotate([nx, ny], a) + p.add(L.Roof, { fill: tone(base, ex, ey) }, poly(pts)) + } + const ridge = scale(base, 0.56) + if (s.hip) { + const r = Math.max(0, hw - hd) + facet([at(-hw, -hd), at(hw, -hd), at(r, 0), at(-r, 0)], 0, -1) + facet([at(-hw, hd), at(hw, hd), at(r, 0), at(-r, 0)], 0, 1) + facet([at(-hw, -hd), at(-r, 0), at(-hw, hd)], -1, 0) + facet([at(hw, -hd), at(r, 0), at(hw, hd)], 1, 0) + if (r > 0) p.add(L.Ridge, { stroke: ridge, width: 0.9 }, line([at(-r, 0), at(r, 0)])) + } else { + facet([at(-hw, -hd), at(hw, -hd), at(hw, 0), at(-hw, 0)], 0, -1) + facet([at(-hw, 0), at(hw, 0), at(hw, hd), at(-hw, hd)], 0, 1) + p.add(L.Ridge, { stroke: ridge, width: 0.9 }, line([at(-hw, 0), at(hw, 0)])) + } + if (p.worn && s.hole) { + // Fallen in: the rafters show over the dark inside. + p.add(L.Ridge, { fill: C.char }, poly([at(-hw * 0.1, hd * 0.15), at(hw * 0.55, hd * 0.15), at(hw * 0.45, hd * 0.8), at(-hw * 0.05, hd * 0.75)])) + p.add(L.Tower, { stroke: scale(C.wood, 0.8), width: 0.7 }, line([at(hw * 0.12, hd * 0.15), at(hw * 0.12, hd * 0.78)]) + line([at(hw * 0.32, hd * 0.15), at(hw * 0.3, hd * 0.8)])) + } +} + +/** A round tower or a tree seen from above: a cone or a crown, lit half and shadowed half. */ +function round(p: Picture, layer: L, at: Pt, r: number, base: string, height: number) { + const cx = p.x(at[0]) + const cy = at[1] + p.add(L.Shadow, { fill: SHADOW }, circle(cx + height * 0.42, cy + height * 0.3, r)) + // The line between the halves runs across the light. + const dx = 0.8 * r + const dy = -0.6 * r + const half = (sweep: 0 | 1) => `M${f(cx + dx)} ${f(cy + dy)}A${f(r)} ${f(r)} 0 0 ${sweep} ${f(cx - dx)} ${f(cy - dy)}Z` + p.add(layer, { fill: tone(base, -0.6, -0.8) }, half(0)) + p.add(layer, { fill: tone(base, 0.6, 0.8) }, half(1)) +} + +const SLATE = (p: Picture) => (p.worn ? mix(C.slate, WEATHER, 0.4) : C.slate) +const tree = (p: Picture, at: Pt, r: number) => round(p, L.Roof, at, r, p.worn ? C.broadleafDark : C.broadleaf, r * 1.6) +const hay = (p: Picture, at: Pt, r: number) => round(p, L.Roof, at, r, p.worn ? mix(C.hay, WEATHER, 0.5) : C.hay, r) + +/** Paths trodden into the yard, each a run of points. */ +function paths(p: Picture, width: number, ...runs: Pt[][]) { + p.add(L.Ground, { stroke: p.worn ? PATH_WORN : PATH, width }, runs.map((r) => line(r.map(([x, y]) => [p.x(x), y]))).join('')) +} + +/** The plaza: a trodden patch in front of the headquarters. */ +const plaza = (p: Picture, at: Pt, r: number) => p.add(L.Ground, { fill: p.worn ? PATH_WORN : PATH }, circle(p.x(at[0]), at[1], r)) + +/** A garden or a little field: furrows across a patch of greens or wheat; weeds in a barbarian village. */ +function garden(p: Picture, at: Pt, w: number, d: number, turn: number, wheat = false) { + const a = ((p.mirror ? -turn : turn) * Math.PI) / 180 + const cx = p.x(at[0]) + const cy = at[1] + const pt = (x: number, y: number): Pt => { + const [rx, ry] = rotate([x, y], a) + return [cx + rx, cy + ry] + } + p.add(L.Ground, { fill: p.worn ? WEEDS : wheat ? C.wheat : C.field }, poly([pt(-w / 2, -d / 2), pt(w / 2, -d / 2), pt(w / 2, d / 2), pt(-w / 2, d / 2)])) + let rows = '' + for (let y = -d / 2 + 2; y < d / 2 - 1; y += 2.6) rows += line([pt(-w / 2 + 1, y), pt(w / 2 - 1, y)]) + p.add(L.Furrows, { stroke: C.furrow, width: 0.8 }, rows) +} + +/** A well on the plaza: a stone ring round the dark shaft. */ +function well(p: Picture, at: Pt) { + p.add(L.Roof, { fill: C.stone }, circle(p.x(at[0]), at[1], 2.6)) + p.add(L.Ridge, { fill: C.dark }, circle(p.x(at[0]), at[1], 1.3)) +} + +/** Weeds grown over the yard of a barbarian village. */ +function weeds(p: Picture, ...spots: [number, number, number][]) { + if (p.worn) p.add(L.Furrows, { fill: WEEDS }, spots.map(([x, y, r]) => circle(p.x(x), y, r)).join('')) +} + +/** A few graves behind the chapel, the newest still open. */ +function graves(p: Picture, ...at: Pt[]) { + p.add(L.Ridge, { fill: C.stoneDark }, at.slice(1).map(([x, y]) => box(p.x(x), y, 0.8, 1.3)).join('')) + p.add(L.Ridge, { fill: C.dark }, box(p.x(at[0]![0]), at[0]![1], 0.9, 1.6)) +} + +/** Half the gate's width at the bottom of a ring, in radians. */ +const GATE = 0.2 +const TURN = Math.PI * 2 + +/** Runs of a ring from the gate round to the gate, without the gaps (angles, mirrored in variant 1). */ +function ringRuns(p: Picture, gaps: [number, number][]): [number, number][] { + const from = Math.PI / 2 + GATE + const to = from + TURN - GATE * 2 + const runs: [number, number][] = [] + let a = from + const norm = (g: number) => (g < from ? g + TURN : g) + for (const [g0, g1] of gaps.map(([g0, g1]) => (p.mirror ? [Math.PI - g1, Math.PI - g0] : [g0, g1])).map(([g0, g1]) => [norm(g0!), norm(g1!)]).sort((x, y) => x[0]! - y[0]!)) { + runs.push([a, g0!]) + a = g1! + } + runs.push([a, to]) + return runs +} + +/** A stake palisade round the plot, the gate at the bottom: posts, or wooden gate towers. A barbarian's has gaps. */ +function palisade(p: Picture, r: number, towers: boolean) { + const runs = ringRuns(p, p.worn ? [[0.5, 0.75], [2.7, 2.85], [4.3, 4.55]] : []) + const d = runs.map(([a0, a1]) => arc(r, a0, a1)).join('') + p.add(L.Shadow, { stroke: SHADOW, width: 3.2 }, runs.map(([a0, a1]) => arc(r, a0, a1, 1.8, 1.3)).join('')) + p.add(L.Wall, { stroke: p.worn ? mix(C.woodDark, WEATHER, 0.3) : scale(C.woodDark, 0.85), width: 3.4 }, d) + // The stakes' tops, lit. + p.add(L.Ridge, { stroke: p.worn ? mix(C.plank, WEATHER, 0.4) : C.plank, width: 2.2, dash: '1.5 0.9' }, d) + for (const s of [-1, 1]) { + const g = Math.PI / 2 + s * (GATE + 0.05) + // Either side of the gate, the same in both variants. + const at: Pt = [Math.cos(g) * r, Math.sin(g) * r] + if (towers) roof(p, { at, w: 6.5, d: 6.5, material: 'shingle', hip: true, height: 9 }) + else p.add(L.Wall, { fill: C.woodDark }, box(at[0], at[1], 1.7, 1.7)) + } +} + +/** A stone wall round the plot with battlements, round towers and a gate at the bottom. */ +function stoneWall(p: Picture, r: number, towers: number, gatehouse: boolean) { + const stone = p.worn ? scale(mix(C.stone, WEATHER, 0.3), 0.9) : C.stone + const from = Math.PI / 2 + GATE + const to = from + TURN - GATE * 2 + const d = arc(r, from, to) + p.add(L.Shadow, { stroke: SHADOW, width: 4.4 }, arc(r, from + 0.05, to - 0.05, 2, 1.5)) + p.add(L.Wall, { stroke: scale(stone, 0.72), width: 4.6 }, d) + p.add(L.Wall, { stroke: stone, width: 2.8 }, arc(r - 0.5, from, to)) + // Merlons along the outer edge. + p.add(L.Ridge, { stroke: scale(stone, 0.58), width: 1.2, dash: '1.6 1.4' }, arc(r + 1.4, from, to)) + for (let k = 0; k < towers; k++) { + const a = Math.PI / 2 + ((k + 0.5) / towers) * TURN + // Spread evenly from the gate, so the same in both variants. + round(p, L.Tower, [Math.cos(a) * r, Math.sin(a) * r], 4.4, SLATE(p), 12) + } + for (const s of [-1, 1]) { + const g = Math.PI / 2 + s * (GATE + 0.03) + round(p, L.Tower, [Math.cos(g) * r, Math.sin(g) * r], gatehouse ? 4.8 : 3.8, SLATE(p), 13) + } + if (gatehouse) roof(p, { at: [0, r - 0.5], w: 8, d: 6, material: 'slate', hip: true, height: 10 }) +} + +/** The village's flag on a pole at the headquarters, in the relation colour, and its shadow. */ +function flag(p: Picture, at: Pt) { + if (p.worn) return + const x = p.x(at[0]) + const y = at[1] + p.add(L.Top, { fill: SHADOW }, poly([[x + 4, y + 3], [x + 15, y + 5], [x + 5, y + 9.5]])) + p.add(L.Top, { fill: C.woodDark }, circle(x, y, 1.3)) + p.add(L.Top, { fill: OWNER }, poly([[x, y - 1.2], [x + 12, y + 2], [x + 0.6, y + 6.6]])) +} + +// The six pictures. Roofs never overlap, nor trees and roofs, so the layers can merge by colour. + +function tier1(p: Picture) { + plaza(p, [0, 7], 8) + paths(p, 4, [[0, 41], [0, 8]], [[0, 9], [-19, 10]], [[0, 9], [16, 16]]) + garden(p, [-14, 27], 15, 10, -12) + weeds(p, [10, 27, 5], [-25, -6, 4]) + roof(p, { at: [0, -8], w: 27, d: 14, material: 'thatch', height: 10, hole: true }) + roof(p, { at: [-21, 7], w: 15, d: 11, turn: 82, material: 'thatch', height: 7, burnt: true }) + roof(p, { at: [18, 18], w: 14, d: 10, turn: -8, material: 'thatch', height: 7 }) + tree(p, [-19, -22], 6.5) + tree(p, [21, -20], 5.5) + hay(p, [26, 3], 3.4) + flag(p, [12, -15]) +} + +function tier2(p: Picture) { + plaza(p, [0, 7], 10) + paths(p, 4, [[0, 43], [0, 8]], [[0, 8], [-21, 6]], [[0, 8], [21, 9]], [[-6, 14], [-15, 23]], [[6, 14], [16, 25]]) + garden(p, [-24, -21], 14, 10, 32, true) + garden(p, [25, -20], 13, 9, -30) + weeds(p, [-8, 31, 5], [28, 0, 4]) + well(p, [5, 9]) + roof(p, { at: [0, -9], w: 29, d: 15, material: 'thatch', height: 11 }) + roof(p, { at: [-23, 6], w: 15, d: 11, turn: 84, material: 'thatch', height: 7, hole: true }) + roof(p, { at: [23, 8], w: 14, d: 11, turn: -84, material: 'shingle', height: 7 }) + roof(p, { at: [-16, 25], w: 14, d: 9, turn: -12, material: 'thatch', height: 6, burnt: true }) + roof(p, { at: [17, 26], w: 13, d: 9, turn: 14, material: 'thatch', height: 6 }) + tree(p, [-6, -30], 5.5) + tree(p, [9, -31], 5) + hay(p, [33, -5], 3) + flag(p, [13, -16]) +} + +function tier3(p: Picture) { + plaza(p, [0, 7], 10) + paths(p, 4, [[0, 45], [0, 8]], [[-26, 8], [26, 8]]) + garden(p, [-24, -20], 12, 10, 38, true) + weeds(p, [24, 27, 4], [-4, -29, 4]) + well(p, [6, 10]) + roof(p, { at: [0, -9], w: 28, d: 16, material: 'tile', hip: true, height: 12 }) + roof(p, { at: [-22, -3], w: 15, d: 11, turn: 86, material: 'thatch', height: 7, hole: true }) + roof(p, { at: [23, -2], w: 15, d: 11, turn: -86, material: 'tile', height: 7 }) + roof(p, { at: [-17, 21], w: 15, d: 10, turn: -14, material: 'thatch', height: 7, burnt: true }) + roof(p, { at: [17, 21], w: 14, d: 10, turn: 14, material: 'shingle', height: 7 }) + roof(p, { at: [13, -27], w: 17, d: 9, turn: -20, material: 'shingle', height: 7 }) + tree(p, [-8, -29], 5) + hay(p, [-31, 9], 3) + palisade(p, 39.5, false) + flag(p, [12, -17]) +} + +function tier4(p: Picture) { + plaza(p, [0, 8], 11) + paths(p, 4.4, [[0, 46], [0, 9]], [[-28, 9], [28, 9]], [[-14, 9], [-22, 28]], [[14, 9], [22, 28]]) + garden(p, [-26, -16], 11, 9, 50, true) + weeds(p, [-2, 31, 4], [28, -14, 3.5]) + well(p, [6, 11]) + roof(p, { at: [0, -8], w: 30, d: 17, material: 'tile', hip: true, height: 13, hole: true }) + // The chapel: a long slate nave behind the headquarters, its tower at the end. + roof(p, { at: [15, -27], w: 20, d: 9, turn: -22, material: 'slate', height: 10 }) + roof(p, { at: [4, -33], w: 7, d: 7, turn: -22, material: 'slate', hip: true, height: 16 }) + roof(p, { at: [-23, -1], w: 15, d: 11, turn: 86, material: 'thatch', height: 7 }) + roof(p, { at: [24, -2], w: 15, d: 11, turn: -86, material: 'tile', height: 7, hole: true }) + roof(p, { at: [-8, 24], w: 13, d: 9, turn: -64, material: 'tile', height: 7 }) + roof(p, { at: [8, 24], w: 13, d: 9, turn: 64, material: 'thatch', height: 7, burnt: true }) + roof(p, { at: [-29, 18], w: 12, d: 9, turn: 30, material: 'shingle', height: 6 }) + roof(p, { at: [29, 18], w: 12, d: 9, turn: -30, material: 'thatch', height: 6 }) + roof(p, { at: [-12, -28], w: 13, d: 9, turn: 24, material: 'thatch', height: 6 }) + palisade(p, 40.5, true) + flag(p, [13, -17]) +} + +function tier5(p: Picture) { + plaza(p, [0, 8], 11) + paths(p, 4.4, [[0, 47], [0, 9]], [[-28, 9], [28, 9]], [[-14, 9], [-21, 28]], [[14, 9], [21, 28]]) + weeds(p, [0, 31, 4], [-28, -12, 3.5]) + well(p, [6, 11]) + // The headquarters a stone hall with a slate roof; the chapel and its graves behind it. + roof(p, { at: [0, -8], w: 31, d: 17, material: 'slate', hip: true, height: 14 }) + roof(p, { at: [16, -26], w: 20, d: 9, turn: -24, material: 'slate', height: 10, hole: true }) + roof(p, { at: [5, -33], w: 7, d: 7, turn: -24, material: 'slate', hip: true, height: 17 }) + graves(p, [24, -13], [27, -15], [21, -16], [28, -11]) + roof(p, { at: [-23, -2], w: 15, d: 11, turn: 86, material: 'tile', height: 8 }) + roof(p, { at: [-14, -25], w: 14, d: 9, turn: 26, material: 'tile', height: 7 }) + roof(p, { at: [-8, 24], w: 13, d: 9, turn: -64, material: 'tile', height: 7, burnt: true }) + roof(p, { at: [8, 24], w: 13, d: 9, turn: 64, material: 'shingle', height: 7 }) + roof(p, { at: [-28, 18], w: 12, d: 9, turn: 34, material: 'thatch', height: 6, hole: true }) + roof(p, { at: [28, 18], w: 12, d: 9, turn: -34, material: 'tile', height: 6 }) + roof(p, { at: [29, -1], w: 11, d: 9, turn: -88, material: 'thatch', height: 6 }) + stoneWall(p, 41, 4, false) + flag(p, [14, -17]) +} + +function tier6(p: Picture) { + plaza(p, [0, 9], 10) + paths(p, 4.4, [[0, 47], [0, 10]], [[-30, 10], [30, 10]], [[-15, 10], [-23, 29]], [[15, 10], [23, 29]], [[-19, 10], [-30, -10]], [[19, 10], [30, -10]]) + weeds(p, [0, 32, 4], [-31, 0, 3]) + well(p, [6, 12]) + // The headquarters a stone hall round a small court with two towers: the biggest roofs of the town. + roof(p, { at: [0, -14], w: 32, d: 9, material: 'slate', height: 15 }) + roof(p, { at: [-12, -2], w: 13, d: 8, turn: 90, material: 'slate', height: 14 }) + roof(p, { at: [12, -2], w: 13, d: 8, turn: 90, material: 'slate', height: 14, hole: true }) + p.add(L.Ground, { fill: p.worn ? PATH_WORN : PATH }, box(0, -3, 7.5, 6.5)) + round(p, L.Tower, [-16, -18], 3.8, SLATE(p), 18) + round(p, L.Tower, [16, -18], 3.8, SLATE(p), 18) + roof(p, { at: [10, -31], w: 18, d: 8, turn: -16, material: 'slate', height: 10 }) + roof(p, { at: [-12, -31], w: 13, d: 8, turn: 18, material: 'tile', height: 7, burnt: true }) + roof(p, { at: [-26, -16], w: 12, d: 8, turn: 52, material: 'tile', height: 7 }) + roof(p, { at: [26, -16], w: 12, d: 8, turn: -52, material: 'tile', height: 7 }) + roof(p, { at: [-28, 2], w: 11, d: 8, turn: 86, material: 'shingle', height: 7, hole: true }) + roof(p, { at: [28, 2], w: 11, d: 8, turn: -86, material: 'tile', height: 7 }) + roof(p, { at: [-8, 24], w: 13, d: 8, turn: -64, material: 'tile', height: 7 }) + roof(p, { at: [8, 24], w: 13, d: 8, turn: 64, material: 'tile', height: 7 }) + roof(p, { at: [-28, 20], w: 11, d: 8, turn: 36, material: 'thatch', height: 6 }) + roof(p, { at: [28, 20], w: 11, d: 8, turn: -36, material: 'shingle', height: 6 }) + stoneWall(p, 42, 6, true) + flag(p, [16, -24]) +} + +/** The crown fort: a square stone keep with battlements and corner turrets in a walled ring, the gold crown over it. */ +function crownFort(p: Picture, banner: boolean) { + plaza(p, [0, 8], 17) + paths(p, 5, [[0, 47], [0, 18]]) + weeds(p, [-24, 14, 4], [22, -22, 3.5]) + const stone = p.worn ? scale(mix(C.stone, WEATHER, 0.3), 0.9) : C.stone + const s = 30 + const [kx, ky] = [0, -5] + p.add(L.Shadow, { fill: SHADOW }, box(kx + 9, ky + 7, s / 2, s / 2)) + // The keep's flat roof: the wall walk round it lit, the roof inside a step down, merlons on the edge. + p.add(L.Roof, { fill: stone }, box(kx, ky, s / 2, s / 2)) + p.add(L.Ridge, { fill: scale(stone, 0.72) }, box(kx, ky, s / 2 - 4, s / 2 - 4)) + p.add(L.Ridge, { stroke: scale(stone, 0.58), width: 1.3, dash: '2 2' }, box(kx, ky, s / 2 - 0.7, s / 2 - 0.7)) + p.add(L.Tower, { fill: C.dark }, box(p.x(kx + 6), ky + 6, 1.6, 1.6)) + for (const [cx, cy] of [[-1, -1], [1, -1], [1, 1], [-1, 1]] as const) round(p, L.Tower, [kx + (cx * s) / 2, ky + (cy * s) / 2], 4.4, SLATE(p), 20) + roof(p, { at: [-27, 7], w: 13, d: 8, turn: 80, material: 'tile', height: 6, hole: true }) + roof(p, { at: [27, 7], w: 13, d: 8, turn: -80, material: 'shingle', height: 6 }) + roof(p, { at: [-18, 26], w: 12, d: 8, turn: -40, material: 'tile', height: 6, burnt: true }) + stoneWall(p, 42, 6, true) + // A player's flag on the keep's wall walk, clear of the crown. + if (banner) flag(p, [kx + 6, ky - 13]) + const y = ky + 3 + p.add(L.Top, { fill: '#d9b44a' }, poly([[-8, y], [-8, y - 9], [-4, y - 4.5], [0, y - 11], [4, y - 4.5], [8, y - 9], [8, y]])) + p.add(L.Top, { fill: '#a8842e' }, box(0, y - 1.3, 8, 1.3)) +} + +const PICTURES: Record void> = { 1: tier1, 2: tier2, 3: tier3, 4: tier4, 5: tier5, 6: tier6 } +/** The plot's radius per tier: it fills most of the field, more of it as the village grows. */ +const RADIUS: Record = { 1: 42, 2: 44, 3: 45.5, 4: 46.5, 5: 47, 6: 47 } + +function build(id: string, r: number, worn: boolean, mirror: boolean, draw: (p: Picture) => void): MapVillageLook { + const p = new Picture(mirror, worn) + const earth = worn ? EARTH_WORN : EARTH + p.add(L.Base, { fill: RIM }, circle(0, 0, r + 2.5)) + p.add(L.Base, { fill: earth }, circle(0, 0, r)) + // The edge in the relation colour lies over the ground and the shadows, under what stands. + p.add(L.Edge, { stroke: OWNER, width: 5 }, circle(0, 0, r - 0.5)) + draw(p) + return { id, shapes: p.shapes(scale(earth, 0.74)) } +} + +const TIER_LIST: MapTier[] = [1, 2, 3, 4, 5, 6] + +/** Every look, built once: each tier for players and barbarians in two variants, and the crown forts. */ +export const MAP_VILLAGE_LOOKS: MapVillageLook[] = [ + ...(['player', 'barbarian'] as const).flatMap((kind) => + TIER_LIST.flatMap((tier) => [0, 1].map((v) => build(`mv-${kind}-${tier}-${v}`, RADIUS[tier], kind === 'barbarian', v === 1, PICTURES[tier]))), + ), + build('mv-crown', 47, true, false, (p) => crownFort(p, false)), + build('mv-crown-player', 47, false, false, (p) => crownFort(p, true)), +] + +/** The symbol a village wears: its kind and tier, the variant from its id. */ +export function mapVillageSymbol(v: { id: number; points: number; crown: boolean; player: unknown }): string { + if (v.crown) return v.player ? '#mv-crown-player' : '#mv-crown' + return `#mv-${v.player ? 'player' : 'barbarian'}-${mapTier(v.points)}-${Math.abs(v.id) % 2}` +} diff --git a/app/pages/map/[worldId].vue b/app/pages/map/[worldId].vue index 3b410e5..2902887 100644 --- a/app/pages/map/[worldId].vue +++ b/app/pages/map/[worldId].vue @@ -411,15 +411,15 @@ const continent = computed(() => (rounded.value ? continentOf(rounded.value.x, r