summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2021-02-10 18:59:38 +0100
committeremkael <emkael@tlen.pl>2021-02-10 18:59:38 +0100
commit30d57bb47a2537f02acf338f4be477e0ad359c7d (patch)
treeff93f3dbcc80737ad6fa5df6294a78fc3e32dde4
parent934a81305857d49d1a3168d297a0436524887048 (diff)
Do not restrict BridgeNET tournaments to individual/pairs, but enforce at least 20 boards
-rw-r--r--http/api-inc.php18
-rw-r--r--test/bridgenet.txt18
2 files changed, 25 insertions, 11 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index b9b9cb6..c10d9d2 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -37,7 +37,8 @@ function run($parameters) {
'1' => 'ApiPklV1', // RegKlas 2018.11.01
'2' => 'ApiPklV2', // RegKMP 2020.01.01
'3' => 'ApiPklV3', // local BNET 2020.05.01
- '_default' => 'ApiPklV3'
+ '3.1' => 'ApiPklV3_1', // local BNET changes from 2021.01.10
+ '_default' => 'ApiPklV3_1'
);
$version = isset($parameters['version']) ? $parameters['version'] : '_default';
$apiClass = isset($versionClasses[$version]) ? $versionClasses[$version] : $versionClasses['_default'];
@@ -306,4 +307,19 @@ class ApiPklV3 extends ApiPklV2 {
}
+// 2021.02.10 - do not discard BridgeNET local team tournaments, but check for board count
+class ApiPklV3_1 extends ApiPklV3 {
+
+ protected function _bridgenet_parameters() {
+ $this->ensure_parameters(array('boards'));
+ $this->check_values($this->parameters, array(
+ 'boards' => function($r) { return is_integer_like($r); }
+ ));
+ if (intval($this->parameters['boards']) < 20) {
+ throw new ParametersException('At least 20 boards must be played in BridgeNET tournaments');
+ }
+ }
+
+}
+
?>
diff --git a/test/bridgenet.txt b/test/bridgenet.txt
index 58c92bc..1584b61 100644
--- a/test/bridgenet.txt
+++ b/test/bridgenet.txt
@@ -2,25 +2,23 @@
"Missing parameter: boards"
{"tournament_rank": 102, "contestants": 35, "boards": -1, "title_sum": 400, "type": 2}
"Parameter: boards has incorrect value (-1)"
-{"tournament_rank": 102, "contestants": 35, "boards": 100, "title_sum": 400, "type": 4}
-"Parameter: type has incorrect value (4) for BridgeNET tournament"
+{"tournament_rank": 102, "contestants": 35, "boards": 19, "title_sum": 400, "type": 2}
+"At least 20 boards must be played in BridgeNET tournaments"
{"tournament_rank": 102, "contestants": 35, "boards": 27, "title_sum": 100, "type": 2}
{"sum": 74, "points": {"1": 5, "2": 5, "3": 4, "4": 4, "5": 3, "6": 3, "7": 2, "8": 1, "9": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1}}
{"tournament_rank": 102, "contestants": 35, "boards": 47, "title_sum": 100, "type": 2}
{"sum": 74, "points": {"1": 5, "2": 5, "3": 4, "4": 4, "5": 3, "6": 3, "7": 2, "8": 1, "9": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1}}
-{"tournament_rank": 102, "contestants": 35, "boards": 0, "title_sum": 100, "type": 2}
-{"sum": 0, "points": {}}
-{"tournament_rank": 102, "contestants": 35, "boards": 1, "title_sum": 100, "type": 2}
-{"sum": 36, "points": {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1}}
{"tournament_rank": 102, "contestants": 35, "boards": 20, "title_sum": 100, "type": 2}
{"sum": 62, "points": {"1": 4, "2": 4, "3": 3, "4": 3, "5": 2, "6": 2, "7": 2, "8": 1, "9": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1, "16": 1, "17": 1, "18": 1}}
{"tournament_rank": 102, "contestants": 20, "boards": 27, "title_sum": 50, "type": 1}
{"sum": 19, "points": {"1": 4, "2": 4, "3": 3, "4": 2, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1}}
{"tournament_rank": 102, "contestants": 20, "boards": 47, "title_sum": 50, "type": 1}
{"sum": 19, "points": {"1": 4, "2": 4, "3": 3, "4": 2, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1}}
-{"tournament_rank": 102, "contestants": 20, "boards": 0, "title_sum": 50, "type": 1}
-{"sum": 0, "points": {}}
-{"tournament_rank": 102, "contestants": 20, "boards": 1, "title_sum": 50, "type": 1}
-{"sum": 10, "points": {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1}}
{"tournament_rank": 102, "contestants": 20, "boards": 20, "title_sum": 50, "type": 1}
{"sum": 16, "points": {"1": 3, "2": 3, "3": 2, "4": 2, "5": 1, "6": 1, "7": 1, "8": 1, "9": 1, "10": 1}}
+{"tournament_rank": 102, "contestants": 20, "boards": 27, "title_sum": 200, "type": 4}
+{"sum": 144, "points": {"1": 9, "2": 8, "3": 6, "4": 4, "5": 2, "6": 2, "7": 2, "8": 1, "9": 1, "10": 1}}
+{"tournament_rank": 102, "contestants": 20, "boards": 47, "title_sum": 200, "type": 4}
+{"sum": 144, "points": {"1": 9, "2": 8, "3": 6, "4": 4, "5": 2, "6": 2, "7": 2, "8": 1, "9": 1, "10": 1}}
+{"tournament_rank": 102, "contestants": 20, "boards": 20, "title_sum": 200, "type": 4}
+{"sum": 112, "points": {"1": 7, "2": 6, "3": 4, "4": 3, "5": 2, "6": 2, "7": 1, "8": 1, "9": 1, "10": 1}}