Phase 2: client military/social screens, WebSocket push, trade + endgame, review findings pending
Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push (docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels. Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js, rankings DoS, static headers, ...): fixes follow in the next commit. NOT done: bots/balance, e2e suite, real-device checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
249818a7aa
commit
b18645dca1
87 changed files with 10201 additions and 71 deletions
|
|
@ -6,6 +6,8 @@
|
|||
* source.forEachSpecial(x0, y0, x1, y1, fn(special)) rural + incumbent tiles in the rect
|
||||
* source.townsInRect(x0, y0, x1, y1) -> [town] POPs in the rect
|
||||
* source.isOwn(town) -> bool
|
||||
* source.movements() -> [{ from: {x,y}, to: {x,y}, kind: 'out' | 'in' | 'ret' | 'ally', p: 0..1 }] optional: lines with a marker at progress p
|
||||
* source.threatened(town) -> bool optional: an incoming movement is heading for this own POP (red ring)
|
||||
* onTap(x, y) a finger lift / click that was not a drag or a pinch (act on lift)
|
||||
* onMoveEnd(view) debounced after the camera stopped; view = { x0, y0, x1, y1, cx, cy, zoom }
|
||||
*
|
||||
|
|
@ -292,6 +294,7 @@
|
|||
}
|
||||
ctx.restore();
|
||||
}
|
||||
if (this.src.movements) this._movements(this.src.movements());
|
||||
for (const t of towns) this._pop(t);
|
||||
|
||||
// world border
|
||||
|
|
@ -365,6 +368,10 @@
|
|||
ctx.beginPath(); ctx.arc(s.x, s.y, Math.max(1.5, rad * (t.isCapital ? 0.38 : 0.22)), 0, Math.PI * 2); ctx.fill();
|
||||
if (t.isCapital) { ctx.strokeStyle = col.stroke; ctx.lineWidth = 1; this._hex(s.x, s.y, rad * 0.68); ctx.stroke(); }
|
||||
}
|
||||
if (own && this.src.threatened && this.src.threatened(t)) {
|
||||
ctx.strokeStyle = '#ff6b87'; ctx.lineWidth = Math.max(2, z * 0.08);
|
||||
this._hex(s.x, s.y, rad + Math.max(4, z * 0.2)); ctx.stroke();
|
||||
}
|
||||
if (z >= 18 && t.owner.protected) {
|
||||
ctx.strokeStyle = COLORS.select; ctx.lineWidth = Math.max(1, z * 0.05); ctx.setLineDash([3, 3]);
|
||||
this._hex(s.x, s.y, rad + z * 0.12); ctx.stroke(); ctx.setLineDash([]);
|
||||
|
|
@ -380,6 +387,35 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Movement lines: dashed, cyan outgoing, red incoming, dim return legs, green allied traffic; a marker sits at progress p.
|
||||
_movements(list) {
|
||||
const { ctx, zoom: z } = this;
|
||||
const col = { out: COLORS.own, in: '#ff6b87', ret: 'rgba(155,178,214,0.8)', ally: '#35e0a1' };
|
||||
ctx.save();
|
||||
ctx.lineCap = 'round';
|
||||
for (const m of list) {
|
||||
const a = this.toScreen(m.from.x, m.from.y), b = this.toScreen(m.to.x, m.to.y);
|
||||
if (Math.max(a.x, b.x) < -20 || Math.min(a.x, b.x) > this.w + 20 || Math.max(a.y, b.y) < -20 || Math.min(a.y, b.y) > this.h + 20) continue;
|
||||
const c = col[m.kind] || COLORS.own;
|
||||
ctx.strokeStyle = c; ctx.fillStyle = c;
|
||||
ctx.globalAlpha = m.kind === 'ret' ? 0.55 : 0.85;
|
||||
ctx.lineWidth = m.kind === 'in' ? 2.4 : 1.6;
|
||||
ctx.setLineDash(m.kind === 'in' ? [3, 5] : [7, 6]);
|
||||
ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
const p = Math.max(0, Math.min(1, m.p));
|
||||
const px = a.x + (b.x - a.x) * p, py = a.y + (b.y - a.y) * p;
|
||||
const ang = Math.atan2(b.y - a.y, b.x - a.x), r = Math.max(4, Math.min(8, z * 0.3));
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(px + Math.cos(ang) * r, py + Math.sin(ang) * r);
|
||||
ctx.lineTo(px + Math.cos(ang + 2.5) * r, py + Math.sin(ang + 2.5) * r);
|
||||
ctx.lineTo(px + Math.cos(ang - 2.5) * r, py + Math.sin(ang - 2.5) * r);
|
||||
ctx.closePath(); ctx.fill();
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
_selection(sel) {
|
||||
const { ctx, zoom: z } = this;
|
||||
const s = this.toScreen(sel.x, sel.y);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue