##############
# Area::Maze #
##############

package Roguelike::Area::Maze;

use strict;
use warnings;
use Roguelike::Game;
use Roguelike::Utility;

use Roguelike::Area::Dungeon;
use Roguelike::Area;

sub generate {
  shift;  # We aren't a class.
  my $map = Roguelike::Area::Dungeon->generate(@_);
  transform($map, ".", " ");
  transform($map, "#", ".");
  transform($map, " ", "#");
  # Hotspots!
  $_->{Hotspots} = [] foreach @{ $map->{Exits} };
  foreach (1 .. 50) { # Zzz
    while (1) {
      my $y = random(1, $map->height);
      my $x = random(1, $map->width);
      next unless $map->{Map}[$y][$x]{_} eq ".";
      next if $map->{Map}[$y][$x]{Hotspot};
      $map->{Map}[$y][$x]{Hotspot} = 1;
      push @{ $map->{Exits}[0]{Hotspots} }, [$y, $x];
      last;
    }
  }
  $map->refresh;
  return $map;
}

42;
