mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +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
|
* @param array $maze Maze to render
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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 ($maze as $y => $row) {
|
||||||
foreach ($row as $x => $column) {
|
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
|
public function testMazeRender() : void
|
||||||
{
|
{
|
||||||
\ob_start();
|
$ob = MazeGenerator::render(MazeGenerator::random(10, 7));
|
||||||
MazeGenerator::render(MazeGenerator::random(10, 7));
|
|
||||||
$ob = \ob_get_clean();
|
|
||||||
\ob_clean();
|
|
||||||
|
|
||||||
$maze = \explode("\n", $ob);
|
$maze = \explode("\n", $ob);
|
||||||
|
|
||||||
// correct top
|
// correct top
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user