From 9cea2d2c76e75068f8b13ff4421912624a169856 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Wed, 26 Jan 2011 23:24:27 +0200 Subject: [PATCH] Do not allow using same word number cell --- demo.php | 2 +- index.php | 12 +----------- lib/php_crossword.class.php | 2 +- lib/php_crossword_grid.class.php | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/demo.php b/demo.php index e1aa05d..e6132ea 100644 --- a/demo.php +++ b/demo.php @@ -43,7 +43,7 @@ - Colors: + Debug: /> Big blocks?: diff --git a/index.php b/index.php index 439c013..a8e5a04 100644 --- a/index.php +++ b/index.php @@ -53,20 +53,10 @@
  • Colored debugging
  • -

    TODO

    - - - -
    © Laurynas Butkus (laurynas.butkus at gmail.com), 2005 - \ No newline at end of file + diff --git a/lib/php_crossword.class.php b/lib/php_crossword.class.php index 689f8a9..1ea0df7 100644 --- a/lib/php_crossword.class.php +++ b/lib/php_crossword.class.php @@ -811,4 +811,4 @@ function generateFromWords($words_list) } } -?> \ No newline at end of file +?> diff --git a/lib/php_crossword_grid.class.php b/lib/php_crossword_grid.class.php index 32b1d43..5614ae0 100644 --- a/lib/php_crossword_grid.class.php +++ b/lib/php_crossword_grid.class.php @@ -118,11 +118,13 @@ function placeWord($word, $x, $y, $axis) { $s = $x; $c =& $cx; + $t =& $cy; } else { $s = $y; $c =& $cy; + $t =& $cx; } // dump( "PLACING WORD: $cx x $cy - {$w->word}" ); @@ -139,15 +141,21 @@ function placeWord($word, $x, $y, $axis) // disable cell before first cell $c = $s - 1; if ($c >= 0 ) - $this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE); + $this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE); $this->cells[$cx][$cy]->number = $w->inum; // sandy addition - // disable cell after first cell + // disable cell after last cell $c = $s + strlen($word); if (is_object($this->cells[$cx][$cy])) - $this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE); + $this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE); + // avoid starting "corner word" - which would use the same + // number cell as this word + $c = $s - 1; + $t = $t + 1; + if ($c >= 0 && is_object($this->cells[$cx][$cy])) + $this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE); } /** @@ -387,4 +395,4 @@ function getHTML($params = array()) return $html; } } -?> \ No newline at end of file +?>