You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ygdc/site/models/tournament.php

40 lines
995 B

2 months ago
<?php
class TournamentPage extends Page {
/**
* @kql-allowed
*/
public function getRunningGames() {
return $this->children()->filter(
fn ($child) => $child->enddate()->isEmpty()
);
}
/**
* @kql-allowed
*/
public function getStats($uuid) {
$lol = $this->children()->filter(
fn ($child) => count($child->players()->toPages()->filter( fn ($player) => $player->uuid()->toString() == $uuid ) )
);
$statsSum = [];
foreach ($lol as $key => $value) {
if ($value->stats()->isEmpty()) {
continue;
}
$stats = $value->stats()->parseJSON()["stats"];
if ($stats[0]["player"] == $uuid) {
$i = 0;
} else if ($stats[1]["player"] == $uuid) {
$i = 1;
}
if (count($statsSum) == 0){
$statsSum = $stats[$i];
continue;
}
$statsSum = $value->addStats($statsSum, $stats[$i]);
}
return $statsSum;//$lol;//$stats[1]["player"]$player->uuid()->toString();
}
}