feat(SCOPONE-0005): complete iteration 0 — AI mastery levels, score bar fix, difficulty selection

This commit is contained in:
Giancarmine Salucci
2026-03-31 22:22:24 +02:00
parent 6c01044c71
commit 0a030d0f01
5 changed files with 580 additions and 136 deletions

View File

@@ -1,4 +1,5 @@
import Phaser from 'phaser';
import { Difficulty } from '../game/types';
export class MenuScene extends Phaser.Scene {
constructor() {
@@ -13,7 +14,7 @@ export class MenuScene extends Phaser.Scene {
this.add.rectangle(0, 0, W, H, 0x1a5c2a).setOrigin(0);
// Title
this.add.text(W / 2, H * 0.2, 'Scopone Scientifico', {
this.add.text(W / 2, H * 0.18, 'Scopone Scientifico', {
fontFamily: 'Georgia, serif',
fontSize: '52px',
color: '#ffd700',
@@ -22,7 +23,7 @@ export class MenuScene extends Phaser.Scene {
resolution: 2,
}).setOrigin(0.5);
this.add.text(W / 2, H * 0.32, '2 vs 2 · Tu + Compagno vs 2 AI', {
this.add.text(W / 2, H * 0.30, '2 vs 2 · Tu + Compagno vs 2 AI', {
fontFamily: 'serif',
fontSize: '22px',
color: '#ccffcc',
@@ -37,36 +38,63 @@ export class MenuScene extends Phaser.Scene {
'Prima squadra a 11 punti vince',
];
rules.forEach((line, i) => {
this.add.text(W / 2, H * 0.44 + i * 28, line, {
this.add.text(W / 2, H * 0.40 + i * 26, line, {
fontFamily: 'serif',
fontSize: '18px',
fontSize: '17px',
color: '#ffffff',
resolution: 2,
}).setOrigin(0.5);
});
// Start button
const btn = this.add.rectangle(W / 2, H * 0.72, 220, 60, 0xffd700, 1)
.setInteractive({ useHandCursor: true });
const btnText = this.add.text(W / 2, H * 0.72, 'INIZIA PARTITA', {
// Difficulty selection label
this.add.text(W / 2, H * 0.60, 'Scegli la difficoltà:', {
fontFamily: 'Georgia, serif',
fontSize: '22px',
color: '#1a5c2a',
fontSize: '20px',
color: '#ffd700',
resolution: 2,
}).setOrigin(0.5);
btn.on('pointerover', () => btn.setFillStyle(0xffec6e));
btn.on('pointerout', () => btn.setFillStyle(0xffd700));
btn.on('pointerdown', () => {
this.cameras.main.fadeOut(300, 0, 30, 0);
this.cameras.main.once('camerafadeoutcomplete', () => {
this.scene.start('GameScene');
// Difficulty buttons
const difficulties: Array<{ label: string; value: Difficulty; color: number; hoverColor: number }> = [
{ label: 'Principiante', value: 'beginner', color: 0x4caf50, hoverColor: 0x66bb6a },
{ label: 'Avanzato', value: 'advanced', color: 0xff9800, hoverColor: 0xffb74d },
{ label: 'Maestro', value: 'master', color: 0xf44336, hoverColor: 0xef5350 },
];
const btnWidth = 200;
const btnHeight = 50;
const totalWidth = difficulties.length * btnWidth + (difficulties.length - 1) * 20;
const startX = (W - totalWidth) / 2 + btnWidth / 2;
difficulties.forEach((d, i) => {
const x = startX + i * (btnWidth + 20);
const y = H * 0.70;
const btn = this.add.rectangle(x, y, btnWidth, btnHeight, d.color, 1)
.setInteractive({ useHandCursor: true });
this.add.text(x, y, d.label, {
fontFamily: 'Georgia, serif',
fontSize: '20px',
color: '#ffffff',
stroke: '#000000',
strokeThickness: 2,
resolution: 2,
}).setOrigin(0.5);
btn.on('pointerover', () => btn.setFillStyle(d.hoverColor));
btn.on('pointerout', () => btn.setFillStyle(d.color));
btn.on('pointerdown', () => {
this.cameras.main.fadeOut(300, 0, 30, 0);
this.cameras.main.once('camerafadeoutcomplete', () => {
this.scene.start('GameScene', { difficulty: d.value });
});
});
});
// Show some face-down cards decoratively
const positions = [
[W * 0.1, H * 0.5], [W * 0.15, H * 0.52], [W * 0.9, H * 0.5], [W * 0.85, H * 0.52],
[W * 0.08, H * 0.85], [W * 0.14, H * 0.87], [W * 0.92, H * 0.85], [W * 0.86, H * 0.87],
];
for (const [x, y] of positions) {
this.add.image(x, y, 'retro').setScale(0.08).setAngle(Phaser.Math.Between(-15, 15));