summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-11-13 22:17:50 +0100
committeremkael <emkael@tlen.pl>2018-11-13 22:17:50 +0100
commit6a675104a9c61ff128fb46b0e471894c4423c1bb (patch)
tree5313a564c93aedfd7ce8cf1424915b7af6a6dd9d
parent7efac0bbb4d10ea6635ed0c0534b3cb08fc21520 (diff)
Changing Deal constructor to accept PBN strings, not PBN file paths
-rw-r--r--tdd/tdd-bootstrap.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/tdd/tdd-bootstrap.php b/tdd/tdd-bootstrap.php
index 88f8752..c01a553 100644
--- a/tdd/tdd-bootstrap.php
+++ b/tdd/tdd-bootstrap.php
@@ -100,13 +100,12 @@ class NoSuchDealNumber extends Exception {
class Deal {
- function __construct($filename, $num_in_pbn) {
+ function __construct($pbnfile, $num_in_pbn) {
$this->deal_num = $num_in_pbn;
- $this->_parse($filename, $num_in_pbn);
+ $this->_parse($pbnfile, $num_in_pbn);
}
- function _parse($filename, $num_in_pbn) {
- $pbn = file_get_contents($filename);
+ function _parse($pbn, $num_in_pbn) {
$start = strpos($pbn, '[Board "' . $num_in_pbn . '"]');
if($start === false) {
throw new NoSuchDealNumber($num_in_pbn);
@@ -207,7 +206,7 @@ function load_deals_for_tables($prefix, $round, $board_in_teamy) {
$num_in_pbn = $board_in_teamy - $file_start_board + $first_num_in_pbn;
try {
- $deal = new Deal($filename, $num_in_pbn);
+ $deal = new Deal(file_get_contents($filename), $num_in_pbn);
$deals_by_tables[$file_table] = $deal;
} catch (NoSuchDealNumber $e) {
// ignore if the deal does not exist in the file