Briscola all'oratorio: alle tavolate il giocatore di carte (segnaposto, sprite di Codex) sfida Andrea a briscola in due. Si sceglie il mazzo, toscane (cuori, mattoni, fiori, picche; gobbo, donna e regio) o napoletane, e il livello: «Alla bona», «Seria», «A fassi male» (conta le carte uscite, finale perfetto a mazzo finito, mai la mano altrui). Regole fedeli, conteggio delle prese a fine partita, rivincita, suoni di carte, comandi con mouse, tocco e tastiera. Carte e dorso col Regolo serpentello disegnati da Codex; motore e prove nel browser rivisti da Claude
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1dxvtsZx8NE9fwjXUNDBr
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { drawBriscola, cardAt, HAND } from '../src/engine/briscola-render.js';
|
||||
import { newBriscola } from '../src/engine/briscola.js';
|
||||
import { story } from '../src/story/story.js';
|
||||
import { simulate } from '../tools/calibrate_briscola.mjs';
|
||||
|
||||
function context() {
|
||||
const labels = [], rects = [];
|
||||
return { labels, rects, save() {}, restore() {}, translate() {}, scale() {}, rotate() {}, beginPath() {}, closePath() {}, moveTo() {}, lineTo() {}, fill() {}, strokeRect() {},
|
||||
fillRect(...args) { rects.push(args); }, fillText(text) { labels.push(text); } };
|
||||
}
|
||||
test('renderer puro: durante la partita nasconde punteggi e carte avversarie', () => {
|
||||
const c = newBriscola(91421), before = JSON.stringify(c), ctx = context();
|
||||
drawBriscola(ctx, c, story.closeups.briscola); assert.equal(JSON.stringify(c), before);
|
||||
assert.ok(ctx.labels.includes('Mazzo: 34'));
|
||||
assert.ok(!ctx.labels.some(t => /punti|Vince|Totale/.test(t)));
|
||||
c.hands.cpu = c.hands.cpu.map(a => new Proxy(a, { get() { throw new Error('Il disegno legge una carta coperta'); } }));
|
||||
assert.doesNotThrow(() => drawBriscola(context(), c, story.closeups.briscola));
|
||||
});
|
||||
test('bersagli delle carte: bordi, spazi vuoti e input fuori turno', () => {
|
||||
const c = newBriscola(4); c.current = 'player';
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const x = HAND.x + i * HAND.gap;
|
||||
assert.equal(cardAt(c, [x, HAND.y]), i);
|
||||
assert.equal(cardAt(c, [x + HAND.w - 1, HAND.y + HAND.h - 1]), i);
|
||||
assert.equal(cardAt(c, [x + HAND.w + 1, HAND.y + 20]), -1);
|
||||
}
|
||||
c.hands.player.pop(); assert.equal(cardAt(c, [HAND.x + 2 * HAND.gap + 10, HAND.y + 10]), -1);
|
||||
c.current = 'cpu'; assert.equal(cardAt(c, [HAND.x + 10, HAND.y + 10]), -1);
|
||||
});
|
||||
test('conteggio e risultato mostrano ogni carta conquistata e i totali solo alla fine', () => {
|
||||
const c = simulate(91421, 'male'), ctx = context(), before = JSON.stringify(c);
|
||||
drawBriscola(ctx, c, story.closeups.briscola);
|
||||
assert.equal(ctx.labels.filter(t => /^\+\d/.test(t)).length, 40);
|
||||
assert.ok(ctx.labels.includes(`${c.result.player} punti`)); assert.ok(ctx.labels.includes(`${c.result.cpu} punti`));
|
||||
assert.equal(JSON.stringify(c), before);
|
||||
c.step = 'count'; c.count = 3;
|
||||
const partial = context(); drawBriscola(partial, c, story.closeups.briscola);
|
||||
assert.equal(partial.labels.filter(t => /^\+\d/.test(t)).length, 3);
|
||||
});
|
||||
Reference in New Issue
Block a user