Skip to content

Commit 85a9e5f

Browse files
committed
games: UGO points awarded to non-DQed players if end by DQ
1 parent 50c4fb8 commit 85a9e5f

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/ps/games/game.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -561,21 +561,25 @@ export class BaseGame<State extends BaseState> {
561561

562562
// UGO-CODE
563563
if (checkUGO(this) && this.winCtx) {
564-
if (this.winCtx.type === 'win' || this.winCtx.type === 'draw') {
565-
const winners = !('type' in this.winCtx)
566-
? []
567-
: this.winCtx.type === 'win'
568-
? 'winner' in this.winCtx
569-
? [this.winCtx.winner.turn]
570-
: 'winnerIds' in this.winCtx
571-
? (this.winCtx.winnerIds as string[])
572-
: []
573-
: this.winCtx.type === 'draw'
574-
? Object.values(this.players).map(player => player.turn)
575-
: [];
564+
if (this.winCtx.type === 'win' || this.winCtx.type === 'draw' || type === 'dq') {
576565
const allPlayers = Object.values(this.players);
577566
const players = allPlayers.filter(player => !player.out).map(player => player.turn);
578567

568+
const winners =
569+
type === 'dq' && players.length === 1
570+
? players
571+
: !('type' in this.winCtx)
572+
? []
573+
: this.winCtx.type === 'win'
574+
? 'winner' in this.winCtx
575+
? [this.winCtx.winner.turn]
576+
: 'winnerIds' in this.winCtx
577+
? (this.winCtx.winnerIds as string[])
578+
: []
579+
: this.winCtx.type === 'draw'
580+
? Object.values(this.players).map(player => player.turn)
581+
: [];
582+
579583
const pointsToAdd: Record<string, number> = {};
580584

581585
if (winners.length === 1) {
@@ -601,7 +605,7 @@ export class BaseGame<State extends BaseState> {
601605

602606
addUGOPoints.call(this.parent, pointsToAdd, this.meta.id);
603607
} else {
604-
if (type === 'dq' || type === 'force') {
608+
if (type === 'force') {
605609
Object.values(this.players).forEach(player => {
606610
if (!player.out) {
607611
this.room.privateSend(player.id, 'This game will not count towards your daily cap.' as NoTranslate);

0 commit comments

Comments
 (0)