Carte che volano: dalla mano al tavolo e, finita la presa, sul mucchietto di chi ha preso (briscola, tressette, scopa; Andrea: «non si capisce quando vengono buttate le carte»). Il valzer della balera ai tavoli da carte (tools/valzer_carte.py: fisarmonica musette, basso, melodia di mandolino col tremolo), musica per primo piano; video «Come si gioca»: cache del Chromium della VM spenta, narratore e personaggi a turno, musica di sottofondo, pronunce del narratore
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1dxvtsZx8NE9fwjXUNDBr
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { canPlay, legal, accuseName, NAMES } from './tressette.js';
|
||||
import { drawCard, drawTable } from './briscola-render.js';
|
||||
import { canPlay, legal, accuseName, team, NAMES, PLAY_TIME, TRICK_HOLD, TRICK_TIME } from './tressette.js';
|
||||
import { drawCard, drawTable, flight } from './briscola-render.js';
|
||||
import { text, panel } from './bocce-render.js';
|
||||
|
||||
// La mano di Andrea a ventaglio, carte a grandezza naturale (42×60): coordinate condivise da disegno e tocco.
|
||||
@@ -19,7 +19,9 @@ export function cardAt(c, [x, y]) {
|
||||
return -1;
|
||||
}
|
||||
// Dove cade la carta di ognuno al centro, e da dove arriva.
|
||||
const SPOT = [[299, 190], [354, 146], [299, 100], [244, 146]], FROM = [[0, 70], [80, 0], [0, -60], [-80, 0]];
|
||||
const SPOT = [[299, 190], [354, 146], [299, 100], [244, 146]];
|
||||
// I mucchietti delle prese: noi in basso a destra, loro in basso a sinistra.
|
||||
const PILE = [[560, 288], [34, 288]];
|
||||
const LABEL = [[320, 280, 'center'], [612, 92, 'right'], [320, 39, 'center'], [28, 92, 'left']];
|
||||
const gold = '#ffe09b', paper = '#fff0cd', ours = '#9fe3ff', theirs = '#ffb0a3';
|
||||
const SAY = { busso: 'BUSSO!', striscio: 'STRISCIO!', volo: 'VOLO!' };
|
||||
@@ -37,6 +39,14 @@ function others(ctx, c, names) {
|
||||
text(ctx, names[seat], x, y, 6, turn ? gold : seat % 2 ? theirs : ours, align);
|
||||
}
|
||||
}
|
||||
function piles(ctx, c) {
|
||||
// Quante prese ha fatto ogni coppia, a mucchietto (una carta coperta ogni due prese).
|
||||
for (const t of [0, 1]) {
|
||||
const n = c.tricks.filter(x => team(x.winner) === t).length, [x, y] = PILE[t];
|
||||
for (let k = 0; k < Math.ceil(n / 2); k++) drawCard(ctx, null, x + k, y - k, 42, 60, true);
|
||||
text(ctx, t ? 'Prese loro' : 'Prese noi', x + 21, y - 8, 5, t ? theirs : ours, 'center');
|
||||
}
|
||||
}
|
||||
function scoreboard(ctx, c) {
|
||||
panel(ctx, 26, 34, 118, 38);
|
||||
text(ctx, `Noi ${c.score[0]}`, 34, 46, 7, ours);
|
||||
@@ -51,10 +61,15 @@ function accuses(ctx, c, names) {
|
||||
c.accuse.forEach((a, i) => text(ctx, `${names[a.who]}: ${accuseName(a)} +${a.points}`, 403, 41 + i * 11, 5, a.who % 2 ? theirs : ours));
|
||||
}
|
||||
function trick(ctx, c, names) {
|
||||
// Da dove parte la carta: la mano di Andrea, o le carte coperte degli altri.
|
||||
const from = p => p.who === 0 ? [handX(c.hands[0].length + 1, p.from ?? 0), CARD.y, CARD.w, CARD.h]
|
||||
: p.who === 2 ? [300, 46, 26, 37] : [p.who === 1 ? 584 : 30, 102 + (p.from ?? 0) * 12, 26, 37];
|
||||
c.table.forEach((p, i) => {
|
||||
const slide = i === c.table.length - 1 && c.step === 'play' ? Math.max(0, 1 - c.t / 0.18) : 0;
|
||||
const [x, y] = SPOT[p.who], [dx, dy] = FROM[p.who];
|
||||
drawCard(ctx, p.card, x + dx * slide, y + dy * slide, CARD.w, CARD.h);
|
||||
const [x, y] = SPOT[p.who];
|
||||
let r = [x, y, CARD.w, CARD.h];
|
||||
if (i === c.table.length - 1 && c.t < PLAY_TIME && (c.step === 'play' || c.step === 'trick')) r = flight(from(p), r, c.t / PLAY_TIME);
|
||||
if (c.step === 'trick' && c.t > TRICK_HOLD) r = flight(r, [...PILE[team(c.last.winner)], 42, 60], (c.t - TRICK_HOLD) / (TRICK_TIME - TRICK_HOLD - 0.05));
|
||||
drawCard(ctx, p.card, ...r);
|
||||
if (p.signal) {
|
||||
const [lx, ly] = p.who === 0 ? [x + 21, y + 70] : p.who === 2 ? [x + 21, y - 8] : p.who === 1 ? [x + 66, y + 30] : [x - 24, y + 30];
|
||||
panel(ctx, lx - 30, ly - 7, 60, 14); text(ctx, SAY[p.signal], lx, ly, 6, gold, 'center');
|
||||
@@ -86,7 +101,7 @@ export function drawTressette(ctx, c, def) {
|
||||
const names = def?.seats ?? NAMES;
|
||||
ctx.save(); ctx.imageSmoothingEnabled = false;
|
||||
drawTable(ctx, 'TRESSETTE AI 21');
|
||||
scoreboard(ctx, c); others(ctx, c, names); accuses(ctx, c, names); trick(ctx, c, names); hand(ctx, c);
|
||||
scoreboard(ctx, c); others(ctx, c, names); piles(ctx, c); accuses(ctx, c, names); hand(ctx, c); trick(ctx, c, names);
|
||||
if (c.step === 'smazzata') summary(ctx, c, `Fine della smazzata ${c.round}`);
|
||||
if (c.step === 'result') summary(ctx, c, c.result.winner === 'player' ? 'Fuori! Avete vinto' : 'Sono fuori loro');
|
||||
ctx.restore();
|
||||
|
||||
Reference in New Issue
Block a user