summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--tdd-bootstrap.php16
2 files changed, 11 insertions, 8 deletions
diff --git a/README.md b/README.md
index 1f58982..af71cbc 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
Program umożliwia wyświetlenie w protokole JFR Teamy na stronie wielu rozkładów rozdań, tj. innego rozkładu dla każdego stołu (lub tylko dla wybranych stołów).
-Program wyświetla rozkład rozdania przy danym stole, jeśli co najmniej jeden z dwóch zapisów z tego meczu został już wprowadzony (choćby jako zapis częściowy, tj. bez ostatecznej liczby lew).
+Program wyświetla rozkład rozdania przy danym stole, jeśli oba zapisy z tego meczu widnieją już w protokole.
+Może to być zachowanie niewystarczające, gdy rozkład jest przeznaczony nie tylko dla tego jednego meczu, ale również dla kolejnych, widniejących niżej w protokole.
## Instalacja
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(' ', '', $td_score1->innertext);
-
$td = $tr->find('td/a', 0);
$table = trim($td->innertext);
$table = str_replace(' ', '', $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(' ', '', $tr->find('td[class="bdc"]', 0)->innertext));
+ $tricks1 = trim(str_replace(' ', '', $tr->find('td[class="bdc"]', 3)->innertext));
+ $contract2 = trim(str_replace(' ', '', $tr->next_sibling()->find('td[class="bdc"]', 0)->innertext));
+ $tricks2 = trim(str_replace(' ', '', $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;