mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
maze render functions generates string
This commit is contained in:
parent
6bb827e97a
commit
3a8a783804
|
|
@ -143,18 +143,21 @@ class MazeGenerator
|
|||
*
|
||||
* @param array $maze Maze to render
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function render(array $maze) : void
|
||||
public static function render(array $maze) : string
|
||||
{
|
||||
$rendered = '';
|
||||
foreach ($maze as $y => $row) {
|
||||
foreach ($row as $x => $column) {
|
||||
echo $column;
|
||||
$rendered .= $column;
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
$rendered .= "\n";
|
||||
}
|
||||
|
||||
return $rendered;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,11 +66,7 @@ class MazeGeneratorTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testMazeRender() : void
|
||||
{
|
||||
\ob_start();
|
||||
MazeGenerator::render(MazeGenerator::random(10, 7));
|
||||
$ob = \ob_get_clean();
|
||||
\ob_clean();
|
||||
|
||||
$ob = MazeGenerator::render(MazeGenerator::random(10, 7));
|
||||
$maze = \explode("\n", $ob);
|
||||
|
||||
// correct top
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user