You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
wiki-map/parse-regions.pl

82 lines
3.2 KiB

use v5.30;
use HexGrid;
use Carp;
use Data::Dumper;
my $grid = HexGrid->new(defaults => { style => { 'stroke-width' => 1, 'stroke' => 'black' }, show_coords => 1 });
$grid->make_region("Viper's Gate", colour => 'red');
my $adderwall = $grid->make_region('Adderwall', colour => 'orange');
# $adderwall->make_subregion('Adderwall foothills', colour => 'moccasin');
$grid->make_region('Adderwall foothills', colour => 'moccasin');
$grid->make_region('Midhills', colour => 'moccasin');
# $grid->make_region('Minev', colour => 'green', images => ["forest-tile.png"]);
$grid->make_region('Minev', colour => 'green');
$grid->make_region('Barrowcross', colour => 'darkgreen');
$grid->make_region('Shinei Mavet', colour => 'orange');
$grid->make_region('Jagged Shinei Mavet', colour => 'orange');
$grid->make_region('Shinei Mavet waters', colour => 'lightcyan');
# $grid->make_region('Shinei Mavet', colour => 'orange', image => 'mountain.svg');
# $grid->make_region('Jagged Shinei Mavet', colour => 'orange', images => ['mountain.svg', 'jagged.svg']);
# $grid->make_region('Shinei Mavet waters', colour => 'lightcyan', image => 'foo.png');
$grid->make_region('Southern Ocean', colour => 'skyblue');
$grid->make_region('A volcano', colour => 'orange');
$grid->make_region('Buslish Scrubs', colour => 'beige');
$grid->make_region('The Blasted Metropolis', colour => 'gray');
$grid->make_region('The sprawling grasses', colour => 'beige');
$grid->make_region('Something sandy?', colour => 'navajowhite');
$grid->make_region('Necromancer', colour => 'orange');
$grid->make_region('The Narrow Sea', colour => 'skyblue');
$grid->make_region('Naurardhon', colour => 'palegoldenrod');
$grid->make_region('The Glades of Leamingbury', colour => 'lightgreen');
$grid->make_region('Cape of Lost Causes', colour => 'gray');
$grid->make_region('Deadlands', colour => 'black');
$grid->make_region('Deadlands', colour => 'black');
$grid->make_region('Glade borders', colour => 'mediumaquamarine');
$grid->make_region('Thicket', colour => 'darkgreen');
$grid->make_region('Random house', colour => 'darkgreen');
$grid->make_region('Abbey of Plendor', colour => 'beige');
$grid->make_region('Khulanu', opacity => '0', style => { 'stroke-width' => 5, 'stroke' => 'black' });
my $tiles;
open $tiles, "$ENV{HOME}/RPG-stuff/WestOfVipers/coordinate-mapping";
my $region;
my $region_file;
start_region();
while(my $coords = <$tiles>)
{
if ($coords =~ /^\s*$/)
{
start_region();
next;
}
print $region_file $coords if $coords;
}
close $region_file if $region_file;
sub start_region
{
close $region_file if $region_file;
$region = <$tiles>;
chomp($region);
my $encoded_region = $region;
$encoded_region =~ s/\W/_/g;
open $region_file, ">region_files/$encoded_region" || croak "Can't open file for $region: $!";
say $region_file "== Style ==";
foreach my $key (keys %{$grid->{regions}{$region}{defaults}})
{
next if $key eq 'style';
say $region_file "$key: $grid->{regions}{$region}{defaults}{$key}";
}
if(my $css = $grid->{regions}{$region}{defaults}{style})
{
say $region_file "\n=== CSS ===";
foreach my $key (keys %{$grid->{regions}{$region}{defaults}{style}})
{
say $region_file "$key: $grid->{regions}{$region}{defaults}{style}{$key}";
}
}
say $region_file "\n== Tiles ==";
}