summaryrefslogtreecommitdiff
path: root/tdd-bootstrap.php
diff options
context:
space:
mode:
authorMichal Zimniewicz <michzimny@gmail.com>2018-01-27 16:36:36 +0100
committerMichal Zimniewicz <michzimny@gmail.com>2018-01-27 16:40:39 +0100
commit68d0e18bf222ff6256cf8d2c45d27a5e176c35f3 (patch)
treefc834dc5ea529cf41ad85bf3d7d38568f68950a9 /tdd-bootstrap.php
parent1ee3e135843d037ffc34eac7db062e793094b08a (diff)
show handrecord when both scores are present
Diffstat (limited to 'tdd-bootstrap.php')
-rw-r--r--tdd-bootstrap.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/tdd-bootstrap.php b/tdd-bootstrap.php
index cf62d46..4626f90 100644
--- a/tdd-bootstrap.php
+++ b/tdd-bootstrap.php
@@ -31,17 +31,19 @@ class Protocol {
$header_tr = $header_td1->parent;
$tr = @$header_tr->next_sibling();
while($tr) {
- $td_score1 = $tr->find('td[class="bdc"]', 0);
- $score1 = str_replace('&nbsp;', '', $td_score1->innertext);
-
$td = $tr->find('td/a', 0);
$table = trim($td->innertext);
$table = str_replace('&nbsp;', '', $table);
$table = (int)$table;
- if($table && array_key_exists($table, $this->deals_by_tables)) {
- // if is played on the 1st table
- // TODO check both tables of the match
- if($score1) {
+ if($table && array_key_exists($table, $this->deals_by_tables)) {
+ $contract1 = trim(str_replace('&nbsp;', '', $tr->find('td[class="bdc"]', 0)->innertext));
+ $tricks1 = trim(str_replace('&nbsp;', '', $tr->find('td[class="bdc"]', 3)->innertext));
+ $contract2 = trim(str_replace('&nbsp;', '', $tr->next_sibling()->find('td[class="bdc"]', 0)->innertext));
+ $tricks2 = trim(str_replace('&nbsp;', '', $tr->next_sibling()->find('td[class="bdc"]', 3)->innertext));
+
+ // if is played on both tables of a match
+ if(($tricks1 || $contract1 == 'ARB')
+ && ($tricks2 || $contract2 == 'ARB')) {
$deal = $this->deals_by_tables[$table];
$insert = "<h4>Stół $table &ndash; Rozdanie {$deal->deal_num}</h4>" . $deal->html();
$modified = 1;