feat(SCOPONE-0002): rotate starting player clockwise each round
This commit is contained in:
@@ -81,7 +81,7 @@ export function canCapture(played: Card, table: Card[]): boolean {
|
||||
// Game state initialisation
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function createInitialState(): GameState {
|
||||
export function createInitialState(startingPlayer: PlayerIndex = 0): GameState {
|
||||
const deck = shuffle(buildDeck());
|
||||
|
||||
const players: [Player, Player, Player, Player] = [
|
||||
@@ -106,7 +106,7 @@ export function createInitialState(): GameState {
|
||||
return {
|
||||
players,
|
||||
table,
|
||||
currentPlayer: 0,
|
||||
currentPlayer: startingPlayer,
|
||||
roundOver: false,
|
||||
gameOver: false,
|
||||
teamScores: [emptyTeamScore(), emptyTeamScore()],
|
||||
|
||||
@@ -1301,9 +1301,10 @@ export class GameScene extends Phaser.Scene {
|
||||
private startNewRound(): void {
|
||||
const totals = this.state.teamScores.map(t => t.totalPoints);
|
||||
const nextRound = (this.state.roundNumber ?? 1) + 1;
|
||||
const startingPlayer = ((nextRound - 1) % 4) as PlayerIndex;
|
||||
for (const img of this.cardImages.values()) img.destroy();
|
||||
this.cardImages.clear();
|
||||
this.state = createInitialState();
|
||||
this.state = createInitialState(startingPlayer);
|
||||
this.state.teamScores[0].totalPoints = totals[0];
|
||||
this.state.teamScores[1].totalPoints = totals[1];
|
||||
this.state.roundNumber = nextRound;
|
||||
|
||||
Reference in New Issue
Block a user