feat(SCOPONE-0009): complete iteration 0 dealer AI

This commit is contained in:
Giancarmine Salucci
2026-04-08 21:50:40 +02:00
parent c9accb7ae4
commit d0a44d295a
7 changed files with 597 additions and 174 deletions

View File

@@ -1,7 +1,8 @@
import Phaser from 'phaser';
import { Card, PlayerIndex, GameState, Difficulty } from '../game/types';
import {
createInitialState, applyMove, findCaptures, getScoreBreakdown, teamOf, calcPrimiera, getMatchOutcome
createInitialState, applyMove, findCaptures, getScoreBreakdown, teamOf, calcPrimiera, getMatchOutcome,
nextPlayer
} from '../game/engine';
import { AIDecisionProgress } from '../game/ai';
import { AIWorkerClient, AIWorkerClientLike } from '../game/ai-worker-client';
@@ -130,8 +131,8 @@ export class GameScene extends Phaser.Scene {
this.input.once('pointerdown', () => this.startMusic());
const startingPlayer = Phaser.Math.Between(0, 3) as PlayerIndex;
this.state = createInitialState(startingPlayer);
const initialDealer = Phaser.Math.Between(0, 3) as PlayerIndex;
this.state = createInitialState(initialDealer);
this.dealAnimation(() => {
this.updateScoreBar();
this.nextTurn();
@@ -1434,11 +1435,11 @@ export class GameScene extends Phaser.Scene {
const totals = this.state.teamScores.map(t => t.totalPoints);
const nextRound = (this.state.roundNumber ?? 1) + 1;
const matchStartingPlayer = this.state.matchStartingPlayer;
const startingPlayer = ((matchStartingPlayer + nextRound - 1) % 4) as PlayerIndex;
const nextDealer = nextPlayer(this.state.dealer);
for (const img of this.cardImages.values()) img.destroy();
this.cardImages.clear();
this.tracker.reset();
this.state = createInitialState(startingPlayer);
this.state = createInitialState(nextDealer);
this.state.matchStartingPlayer = matchStartingPlayer;
this.state.teamScores[0].totalPoints = totals[0];
this.state.teamScores[1].totalPoints = totals[1];