feat(rust): Dynamic PVP's zones on the feed and the map (PLAN_REDESIGNS §14.3.3)
Stage 4 of the §14.3 integration plan, on protocol 14 (docs rust-link/PROTOCOL.md §20.7). - pvp.zone.created is a public kind, pvp.zone.deleted a staff kind. Each row is read per viewer by the new dynamicPvp.js: grid for everyone, the event's name only for Dynamic PVP's own vanilla events, position and zone id for staff only. - The feed's world filter carries the opening: "A PvP zone opened around the downed patrol helicopter · G7 · for 10 min". It names nobody. - The map gains a fifth layer, `pvp` (PvP zones), public by default with its own audience in Admin → Rust visibility, drawn as a red ring with its event's name. - Server settings' plugin line names Dynamic PVP; the swagger schemas and route descriptions carry the layer and the integration (fragment regenerated); ci/bundle.json ships dynamicPvp.js; README lists it. Tests: server 611/611 (dynamicPvp.test.js new, catalogue and map extended) and every check; client 89/89 (feed and map tooltip), build and externals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -21,7 +21,7 @@ import Empty from './Empty.jsx'
|
||||
import usePolled from '../hooks/usePolled.js'
|
||||
import { ago } from '../lib/format.js'
|
||||
import { boundsOf, countdown, fromLatLng, grid, gridLabel, toLatLng } from '../lib/mapGeometry.js'
|
||||
import { eventTip, isBoss, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
|
||||
import { eventTip, isBoss, pvpTip, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
|
||||
import api, { BASE } from '../api.js'
|
||||
|
||||
const STYLE_ID = 'rust-leaflet-css'
|
||||
@@ -35,6 +35,7 @@ const LAYERS = [
|
||||
{ id: 'events', label: 'Site events' },
|
||||
{ id: 'players', label: 'Players' },
|
||||
{ id: 'bases', label: 'Bases' },
|
||||
{ id: 'pvp', label: 'PvP zones' },
|
||||
]
|
||||
|
||||
const COLOURS = {
|
||||
@@ -53,6 +54,7 @@ const COLOURS = {
|
||||
vending: '#26a69a',
|
||||
self: '#00e5ff',
|
||||
mate: '#7cffb2',
|
||||
pvp: '#ff1744',
|
||||
}
|
||||
|
||||
const WORLD_NAMES = {
|
||||
@@ -79,7 +81,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
|
||||
|
||||
const [leaflet, setLeaflet] = useState(null)
|
||||
const [leafletError, setLeafletError] = useState(null)
|
||||
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, mates: true })
|
||||
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, pvp: true, mates: true })
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
@@ -160,7 +162,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
|
||||
map.fitBounds(bounds)
|
||||
|
||||
const made = {}
|
||||
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
|
||||
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'pvp', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
|
||||
// The labels are a layer of their own inside the grid's, shown only when a cell
|
||||
// is wide enough on screen to hold one: at the fitted zoom a 20-cell map's
|
||||
// labels overlap into a wall of text (found on the phase 14 walk).
|
||||
@@ -238,7 +240,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
|
||||
const { L } = leaflet
|
||||
const answer = live.data || {}
|
||||
const at = (p) => toLatLng(geometry, p.x, p.z)
|
||||
for (const id of ['world', 'events', 'players', 'bases', 'mates']) made[id].clearLayers()
|
||||
for (const id of ['world', 'events', 'players', 'bases', 'pvp', 'mates']) made[id].clearLayers()
|
||||
|
||||
for (const w of answer.world || []) {
|
||||
let tip = WORLD_NAMES[w.kind] || w.kind
|
||||
@@ -274,6 +276,13 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
|
||||
dot(L, at(b), COLOURS[b.kind] || COLOURS.tc, 4).bindTooltip(b.kind === 'tc' ? 'Tool cupboard' : 'Vending machine').addTo(made.bases)
|
||||
}
|
||||
|
||||
// Dynamic PVP's own zones (§14.3.3): a red ring with its event's name.
|
||||
for (const z of answer.pvp || []) {
|
||||
L.circle(at(z), { radius: px(Number(z.radius) || 0), color: COLOURS.pvp, weight: 2, fillOpacity: 0.1 })
|
||||
.bindTooltip(escape(pvpTip(z)))
|
||||
.addTo(made.pvp)
|
||||
}
|
||||
|
||||
for (const m of answer.mates || []) {
|
||||
dot(L, at(m), m.self ? COLOURS.self : COLOURS.mate, m.self ? 8 : 6, 2)
|
||||
.bindTooltip(escape(m.self ? `You${m.online ? '' : ' (asleep, offline)'}` : m.name || 'Clan mate'))
|
||||
@@ -299,7 +308,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
|
||||
const map = mapRef.current
|
||||
const made = groups.current
|
||||
if (!map || !made) return
|
||||
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, mates: shown.mates }
|
||||
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, pvp: shown.pvp, mates: shown.mates }
|
||||
for (const [id, on] of Object.entries(want)) {
|
||||
if (on && !map.hasLayer(made[id])) made[id].addTo(map)
|
||||
if (!on && map.hasLayer(made[id])) map.removeLayer(made[id])
|
||||
@@ -381,6 +390,7 @@ function Legend({ meta, live, shown, onToggle }) {
|
||||
events: [COLOURS.event],
|
||||
players: [COLOURS.online, COLOURS.sleeping],
|
||||
bases: [COLOURS.tc, COLOURS.vending],
|
||||
pvp: [COLOURS.pvp],
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user