summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-04-28 19:13:19 +0200
committeremkael <emkael@tlen.pl>2018-04-28 19:13:19 +0200
commitbfa5f4c1f9873536fde8bee124c7c6deb17c06a4 (patch)
tree9626657cc5037a19ab51435d33f2ff16dc48a8f5
parent46652656fc42df252cd8cadc82ced2f6e002bdc3 (diff)
Support PBN files not starting from Board 1
-rw-r--r--tdd-bootstrap.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/tdd-bootstrap.php b/tdd-bootstrap.php
index 48b088f..ef3daaa 100644
--- a/tdd-bootstrap.php
+++ b/tdd-bootstrap.php
@@ -183,8 +183,13 @@ function load_deals_for_tables($prefix, $round, $board_in_teamy) {
$file_table = $match[1];
$file_start_board = $match[2];
- // 1 in teamy -> 1 in pbn; 24 in teamy -> 1 in pbn; 25 in teamy -> 1 in pbn
- $num_in_pbn = $board_in_teamy - $file_start_board + 1;
+ $first_num_in_pbn = array();
+ preg_match('/\[Board "(\d+)"\]/', file_get_contents($filename), $first_num_in_pbn);
+ $first_num_in_pbn = $first_num_in_pbn ? intval($first_num_in_pbn[1]) : 1;
+
+ // 1 in teamy -> 1 in pbn; 24 in teamy -> 24 in pbn; 25 in teamy -> 1 in pbn
+ // if PBN doesn't starts with Board 1, it's been adjusted
+ $num_in_pbn = $board_in_teamy - $file_start_board + $first_num_in_pbn;
try {
$deal = new Deal($filename, $num_in_pbn);