fix: correct score display and selection logic in FarkelGame

- Fix turn score display to show kept dice separately from selected dice
- Update selection scoring to only evaluate currently selected dice, not combined with set aside dice
- Add validation check for empty selections
This commit is contained in:
Brian Fertig 2026-06-13 11:34:36 -06:00
parent d34ab83b39
commit d82a8d676f
1 changed files with 9 additions and 6 deletions

View File

@ -425,7 +425,9 @@ export default class FarkelGame extends Phaser.Scene {
const hasPending = this.gs.turn.kept > 0 || (this.gs.phase === 'awaitPick' && this.selectionScore() > 0); const hasPending = this.gs.turn.kept > 0 || (this.gs.phase === 'awaitPick' && this.selectionScore() > 0);
const showTurn = (seat === cur && !isGameOver(this.gs) && hasPending); const showTurn = (seat === cur && !isGameOver(this.gs) && hasPending);
if (showTurn) { if (showTurn) {
const total = (this.gs.phase === 'awaitPick') ? this.selectionScore() : this.gs.turn.kept; const total = (this.gs.phase === 'awaitPick')
? this.gs.turn.kept + this.selectionScore()
: this.gs.turn.kept;
row.score.setText(`${p.score} +${total}`); row.score.setText(`${p.score} +${total}`);
} else { } else {
row.score.setText(String(p.score)); row.score.setText(String(p.score));
@ -499,13 +501,14 @@ export default class FarkelGame extends Phaser.Scene {
// ── selection helpers ───────────────────────────────────────────────────────── // ── selection helpers ─────────────────────────────────────────────────────────
selectionValues() { return [...this.selected].map((i) => this.gs.turn.rolled[i]); } selectionValues() { return [...this.selected].map((i) => this.gs.turn.rolled[i]); }
selectionValid() { selectionValid() {
const combined = [...this.gs.turn.setAsideDice, ...this.selectionValues()]; const values = this.selectionValues();
return scoreSelection(combined).valid; if (values.length === 0) return false;
return scoreSelection(values).valid;
} }
selectionScore() { selectionScore() {
const combined = [...this.gs.turn.setAsideDice, ...this.selectionValues()]; const values = this.selectionValues();
if (combined.length === 0) return 0; if (values.length === 0) return 0;
const r = scoreSelection(combined); const r = scoreSelection(values);
return r.valid ? r.points : 0; return r.valid ? r.points : 0;
} }