From c851224e62eade465a434ff3ad00f73c91ef7679 Mon Sep 17 00:00:00 2001 From: Thomas David Baker Date: Wed, 20 Nov 2024 21:03:53 -0800 Subject: [PATCH] Types for medallists --- gatherling/Models/Event.php | 4 ++-- .../Views/Components/{HostActiveEvents.php => HostEvents.php} | 0 gatherling/event.php | 4 ++-- .../{hostActiveEvents.mustache => hostEvents.mustache} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename gatherling/Views/Components/{HostActiveEvents.php => HostEvents.php} (100%) rename gatherling/templates/partials/{hostActiveEvents.mustache => hostEvents.mustache} (100%) diff --git a/gatherling/Models/Event.php b/gatherling/Models/Event.php index 5a4bb473a..c0d31140a 100644 --- a/gatherling/Models/Event.php +++ b/gatherling/Models/Event.php @@ -1638,10 +1638,10 @@ public function assignMedalsByStandings(): void $t8 = $t4 = []; if ($medalCount >= 8) { - $t8 = array_map(fn($i) => $players[$i]->player, [4, 5, 6, 7]); + $t8 = array_values(array_filter(array_map(fn($i) => $players[$i]->player ?? null, [4, 5, 6, 7]))); } if ($medalCount >= 4) { - $t4 = array_map(fn($i) => $players[$i]->player, [2, 3]); + $t4 = array_values(array_filter(array_map(fn($i) => $players[$i]->player ?? null, [2, 3]))); } $sec = $players[1]->player ?? null; $win = $players[0]->player; diff --git a/gatherling/Views/Components/HostActiveEvents.php b/gatherling/Views/Components/HostEvents.php similarity index 100% rename from gatherling/Views/Components/HostActiveEvents.php rename to gatherling/Views/Components/HostEvents.php diff --git a/gatherling/event.php b/gatherling/event.php index b09938b23..e7b7abdcd 100644 --- a/gatherling/event.php +++ b/gatherling/event.php @@ -528,8 +528,8 @@ function updateMedals(): void $winner = post()->string('newmatchplayer1'); $second = post()->optionalString('newmatchplayer2'); - $t4 = [post()->optionalString('newmatchplayer3'), post()->optionalString('newmatchplayer4')]; - $t8 = [post()->optionalString('newmatchplayer5'), post()->optionalString('newmatchplayer6'), post()->optionalString('newmatchplayer7'), post()->optionalString('newmatchplayer8')]; + $t4 = array_values(array_filter([post()->optionalString('newmatchplayer3'), post()->optionalString('newmatchplayer4')])); + $t8 = array_values(array_filter([post()->optionalString('newmatchplayer5'), post()->optionalString('newmatchplayer6'), post()->optionalString('newmatchplayer7'), post()->optionalString('newmatchplayer8')])); $event->setFinalists($winner, $second, $t4, $t8); } diff --git a/gatherling/templates/partials/hostActiveEvents.mustache b/gatherling/templates/partials/hostEvents.mustache similarity index 100% rename from gatherling/templates/partials/hostActiveEvents.mustache rename to gatherling/templates/partials/hostEvents.mustache