66 lines
2.1 KiB
JavaScript
66 lines
2.1 KiB
JavaScript
// Blackjack table art. The shared casino kit (src/ui/casino/CasinoArt.js) bakes
|
||
// the rail, felt, lighting, cards, chips and dock; this file only supplies
|
||
// Blackjack's felt colour, markings, lettering and furniture.
|
||
|
||
import { feltCircle } from '../../ui/casino/CasinoGeometry.js';
|
||
import { prepareCasinoArt, bakeCasinoTable, poly, rr, CARD_W, CARD_H } from '../../ui/casino/CasinoArt.js';
|
||
import {
|
||
polar, SEAT_ANGLES, BET_R, BET_SPOT_R, cardPose, VIEW,
|
||
FELT_TEXT, INSURANCE_LINES, TRAY, SHOE, DISCARD, PLACARD,
|
||
} from './BlackjackTable.js';
|
||
|
||
export { CARD_W, CARD_H, ensureCardBack } from '../../ui/casino/CasinoArt.js';
|
||
|
||
function drawMarkings(ctx) {
|
||
// Card spots + betting circles for all seven seats
|
||
SEAT_ANGLES.forEach((theta, seat) => {
|
||
const t = (theta * Math.PI) / 180;
|
||
const u = BET_R * Math.sin(t), v = BET_R * Math.cos(t);
|
||
poly(ctx, feltCircle(u, v, BET_SPOT_R));
|
||
ctx.fillStyle = 'rgba(0,0,0,0.13)';
|
||
ctx.fill();
|
||
ctx.lineWidth = 3;
|
||
ctx.strokeStyle = 'rgba(217,180,90,0.85)';
|
||
ctx.stroke();
|
||
poly(ctx, feltCircle(u, v, BET_SPOT_R * 0.8));
|
||
ctx.lineWidth = 1.5;
|
||
ctx.strokeStyle = 'rgba(242,234,216,0.4)';
|
||
ctx.stroke();
|
||
|
||
const pose = cardPose(seat, 0, 1, null, CARD_W);
|
||
ctx.save();
|
||
ctx.translate(pose.x, pose.y);
|
||
ctx.rotate(pose.rot);
|
||
ctx.scale(pose.s, pose.s * VIEW.squash);
|
||
rr(ctx, -CARD_W / 2 - 14, -CARD_H / 2 - 8, CARD_W + 28, CARD_H + 16, 12);
|
||
ctx.lineWidth = 2 / pose.s;
|
||
ctx.strokeStyle = 'rgba(242,234,216,0.32)';
|
||
ctx.stroke();
|
||
ctx.restore();
|
||
});
|
||
|
||
// Insurance band
|
||
const { r0, r1, span } = INSURANCE_LINES;
|
||
for (const r of [r0, r1]) {
|
||
const pts = [];
|
||
for (let d = -span; d <= span; d += 1) pts.push(polar(r, d));
|
||
poly(ctx, pts, false);
|
||
ctx.lineWidth = 2.5;
|
||
ctx.strokeStyle = 'rgba(242,234,216,0.5)';
|
||
ctx.stroke();
|
||
}
|
||
}
|
||
|
||
export async function prepareBlackjackArt(scene) {
|
||
await prepareCasinoArt(scene);
|
||
bakeCasinoTable(scene, 'bj-table', {
|
||
felt: '#0d5a2c',
|
||
markings: drawMarkings,
|
||
text: FELT_TEXT,
|
||
tray: TRAY,
|
||
shoe: SHOE,
|
||
discard: DISCARD,
|
||
placard: { ...PLACARD, lines: ['TABLE LIMITS', '$5 – $100'] },
|
||
});
|
||
}
|