summaryrefslogtreecommitdiff
path: root/http/api.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-01-20 13:20:52 +0100
committeremkael <emkael@tlen.pl>2019-01-20 13:20:52 +0100
commit080dea366e57db032e1928019f7ea599f11dabea (patch)
tree4c5dcc0b577521d842ee65f5cd9ee96487a41ce8 /http/api.php
parent8227f1561781e8ed1b3acca140bb611559e25a98 (diff)
Detailed output structure
Diffstat (limited to 'http/api.php')
-rw-r--r--http/api.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/http/api.php b/http/api.php
index e83420b..a3f155d 100644
--- a/http/api.php
+++ b/http/api.php
@@ -11,7 +11,7 @@ Parametry:
- ręczna waga (opcjonalny)
- ręczny współczynnik zawodniczy (opcjonalny)
- ręczne progi (opcjonalne)
-
+
{
"type": 2,
"contestants": 20,
@@ -73,7 +73,7 @@ function check_parameters($parameters) {
if (isset($parameters['players'])) {
check_values($parameters, array(
'players' => function($r) { return ctype_digit($r) && intval($r) > 0; }
- ));
+ ));
}
if (!isset($parameters['manual']) || !isset($parameters['manual']['min_points']) || !isset($parameters['manual']['tournament_weight'])) {
ensure_parameters($parameters, array('tournament_rank', 'over39_boards'));
@@ -174,12 +174,12 @@ function calculate_points($parameters) {
(1 + 0.25 * ($parameters['type'] > 2)) * (max(0.15, $parameters['title_sum'] / $parameters['players']) * $parameters['tournament_weight'] + $parameters['players_coefficient'] * $parameters['contestants'] * $parameters['type'])
));
$min_points = 1;
- $result = array("sum" => 0);
+ $result = array("sum" => 0, "points" => array());
for ($place = 1; $place <= $parameters['contestants']; $place++) {
$percentage = get_percentage_from_position($place, $parameters['contestants'], $parameters['points_cutoffs']);
$points = safe_ceil(floatval($max_points) * $percentage);
- $result[$place] = max($min_points, intval($points));
- $result['sum'] += $parameters['type'] * $result[$place];
+ $result['points'][$place] = max($min_points, intval($points));
+ $result['sum'] += $parameters['type'] * $result['points'][$place];
}
return $result;
}