feat(packages): ludic.session - a party's roster (slot 0 a port, the others as reported), the roles and who owns the world, the shared night, votes and a world-changing act asking the party; joins, leaves, roles, votes and the night as facts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 07:45:26 +03:00
parent 12172d7b75
commit 79ed7a335b
12 changed files with 707 additions and 0 deletions

View file

@ -0,0 +1,30 @@
# near.ludic - the world asks who is nearest, never "the player": an animal notices whoever is
# closest, a camper keeps clear of everyone
export function ply_near_d2(x: float, z: float) -> float {
session__near_i = 0
var best = 0.0
var first = true
for p in 0 .. PLY_MAX {
if not ply_on(p) { continue }
let dx = x - ply_x(p)
let dz = z - ply_z(p)
let d2 = dx * dx + dz * dz
if first or d2 < best {
best = d2
session__near_i = p
first = false
}
}
return best
}
# the distance to the nearest player, in metres; ply_near_i() says which
export function ply_near(x: float, z: float) -> float { return Math.sqrt(ply_near_d2(x, z)) }
export function ply_near_i() -> int { return session__near_i }
export function ply_dist(p: int, x: float, z: float) -> float {
let dx = x - ply_x(p)
let dz = z - ply_z(p)
return Math.sqrt(dx * dx + dz * dz)
}