| 1 | # Copyright (C) 2009-2021 Alex Schroeder <alex@gnu.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (C) 2020 Christian Carey | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This program is free software: you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Foundation, either version 3 of the License, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Algorithms based on Traveller ©2008 Mongoose Publishing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | package Traveller::Mapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use List::Util qw(shuffle reduce); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Traveller::Util qw(nearby distance in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Traveller::Hex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | has 'hexes' => sub { [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | has 'routes' => sub { [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | has 'comm_set'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | has 'trade_set'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | has 'source'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | has 'width'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | has 'height'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | my $colour_re = qr/#([0-9a-f]{3}){1,2}/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $example = q!Inedgeus 0101 D7A5579-8 G Fl Ni A | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Geaan 0102 E66A999-7 G Hi Wa A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | Orgemaso 0103 C555875-5 SG Ga Lt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Veesso 0105 C5A0369-8 G De Lo A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Ticezale 0106 B769799-7 T SG Ri A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | Maatonte 0107 C6B3544-8 C G Fl Ni A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | Diesra 0109 D510522-8 SG Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | Esarra 0204 E869100-8 G Lo A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Rience 0205 C687267-8 G Ga Lo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | Rearreso 0208 C655432-5 C G Ga Lt Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | Laisbe 0210 E354663-3 Ag Lt Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Biveer 0302 C646576-9 C G Ag Ga Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Labeveri 0303 A796100-9 CT N G Ga Lo A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | Sotexe 0408 E544778-3 G Ag Ga Lt A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | Zamala 0409 A544658-13 T N G Ag Ga Ht Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Sogeeran 0502 A200443-14 CT N G Ht Ni Va | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | Aanbi 0503 E697102-7 G Ga Lo A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | Bemaat 0504 C643384-9 C R G Lo Po | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Diare 0505 A254430-11 TRN G Ni A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | Esgeed 0507 A8B1579-11 RN G Fl Ni A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | Leonbi 0510 B365789-9 T SG Ag Ri A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Reisbeon 0604 C561526-8 R G Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Atcevein 0605 A231313-11 CT G Lo Po | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | Usmabe 0607 A540A84-15 T G De Hi Ht In Po | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | Onbebior 0608 B220530-10 G De Ni Po A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | Raraxema 0609 B421768-8 T NSG Na Po | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Xeerri 0610 C210862-9 G Na | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | Onreon 0702 D8838A9-2 S Lt Ri A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | Ismave 0703 E272654-4 Lt Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | Lara 0704 C0008D9-5 SG As Lt Na Va A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | Lalala 0705 C140473-9 R G De Ni Po | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | Maxereis 0707 A55A747-12 CT NSG Ht Wa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | Requbire 0802 C9B4200-10 G Fl Lo A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | Azaxe 0804 B6746B9-8 C G Ag Ga Ni A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | Rieddige 0805 B355578-7 G Ag Ni A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | Usorce 0806 E736110-3 G Lo Lt A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | Solacexe 0810 D342635-4 P S Lt Ni Po R | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | !; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub example { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
example: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | return $example; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # The empty hex is centered around 0,0 and has a side length of 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # a maximum diameter of 2, and a minimum diameter of √3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my @hex = ( -1, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | -0.5, sqrt(3)/2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0.5, sqrt(3)/2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0.5, -sqrt(3)/2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | -0.5, -sqrt(3)/2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($self, $width, $height) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # TO DO: support an option for North American “A” paper dimensions (width 215.9 mm, length 279.4 mm) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $width //= 210; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$width //= 210
MC/DC0%0/1
$width //= 210
$width
Truth table0%0/2
A
A= $width
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $height //= 297; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$height //= 297
MC/DC0%0/1
$height //= 297
$height
Truth table0%0/2
A
A= $height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $template = <<EOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | xmlns:xlink="http://www.w3.org/1999/xlink" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | width="${width}mm" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | height="${height}mm" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | viewBox="%s %s %s %s"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | <desc>Traveller Subsector</desc> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | <defs> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | <style type="text/css"><![CDATA[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | font-size: 16pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | font-family: Optima, "Optima Regular", Optima-Regular, Helvetica, sans-serif; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | text-anchor: middle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | text a { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | fill: blue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | text-decoration: underline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | .coordinates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | fill-opacity: 0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | .starport, .base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | font-size: 20pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | .direction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | font-size: 24pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | .legend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | text-anchor: start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | font-size: 14pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | tspan.comm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | fill: #ff6347; /* tomato */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | line.comm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | stroke-width: 10pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | stroke: #ff6347; /* tomato */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | tspan.trade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | fill: #afeeee; /* pale turquoise */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | line.trade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | stroke-width: 6pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | stroke: #afeeee; /* pale turquoise */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | fill: none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | .travelzone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | opacity: 0.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | .amber { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | fill: none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | stroke-width: 1pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | stroke: black; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | .red { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | fill: red; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | #hex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | stroke-width: 3pt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | fill: none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | stroke: black; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | #background { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | fill: inherit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | #bg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | fill: inherit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ]]></style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | <polygon id="hex" points="%s,%s %s,%s %s,%s %s,%s %s,%s %s,%s" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | <polygon id="bg" points="%s,%s %s,%s %s,%s %s,%s %s,%s %s,%s" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | </defs> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | <rect fill="white" stroke="black" stroke-width="10" id="frame" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | x="%s" y="%s" width="%s" height="%s" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $scale = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | return sprintf($template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | map { sprintf("%.3f", $_ * $scale) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # viewport | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | -0.5, -0.5, 3 + ($self->width - 1) * 1.5, ($self->height + 1.5) * sqrt(3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # empty hex, once for the backgrounds and once for the stroke | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | @hex, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | @hex, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # framing rectangle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | -0.5, -0.5, 3 + ($self->width - 1) * 1.5, ($self->height + 1.5) * sqrt(3)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub colour { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colour: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | my $culture = shift or return "white"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # The same colours result from the same names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my @colours = ("#d3d3d3", "#f5f5f5", "#eaeaea", "#fffeb0", "#fff0f5", "#eee0e5", "#ffe1ff", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | "#eed2ee", "#c6e2ff", "#fdf5e6", "#e0ffff", "#d1eeee", "#c5fff5", "#eeeee0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | "#fff68f", "#eee685", "#fffacd", "#eee9bf", "#ffe7ba", "#ffefdb", "#ffe4e1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | "#eed5d2", "#e6e6fa", "#f0ffff", "#c5ffd5", "#e6ffe6", "#d5ffc5", "#f5f5dc"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $i = unpack("%32W*", lc $culture) % @colours; # checksum | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return $colours[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub background { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
background: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $scale = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | return join("\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $hex = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $x = $hex->x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $y = $hex->y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $c = $hex->colour || $self->colour($hex->culture); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$hex->colour || $self->colour($hex->culture)
MC/DC0%0/2
$hex->colour || $self->colour($hex->culture)
$hex->colour
$self->colour($hex->culture)
Truth table0%0/3
A || B
A= $hex->colourB= $self->colour($hex->culture)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | sprintf(qq{ <use xlink:href="#bg" x="%.3f" y="%.3f" fill="$c"/>}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | (1 + ($x-1) * 1.5) * $scale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ($y - $x%2/2) * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | } @{$self->hexes}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub grid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grid: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $scale = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | $doc .= join("\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $x = int($_/$self->height+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $y = $_ % $self->height + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $svg = sprintf(qq{ <use xlink:href="#hex" x="%.3f" y="%.3f"/>\n}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | (1 + ($x-1) * 1.5) * $scale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ($y - $x%2/2) * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $svg .= sprintf(qq{ <text class="coordinates" x="%.3f" y="%.3f">} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | . qq{%02d%02d</text>\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | (1 + ($x-1) * 1.5) * $scale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | ($y - $x%2/2) * sqrt(3) * $scale - 0.6 * $scale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $x, $y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } (0 .. $self->width * $self->height - 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub legend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legend: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $scale = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $uwp = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ($self->source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $uwp = ' – <a xlink:href="' . $self->source . '">UWP</a>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $doc .= sprintf(qq{ <text class="legend" x="%.3f" y="%.3f">◉ gas giant} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | . qq{ – ■ Imperial consulate – ☼ TAS facility – ▲ scout base} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | . qq{ – ★ naval base – π research station – ☠ pirate base} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | . qq{ – <tspan class="comm">▮</tspan> communication} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | . qq{ – <tspan class="trade">▮</tspan> trade$uwp</text>\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | -10, ($self->height + 1) * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $doc .= sprintf(qq{ <text class="direction" x="%.3f" y="%.3f">coreward</text>\n}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $self->width/2 * 1.5 * $scale, -0.13 * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $doc .= sprintf(qq{ <text transform="translate(%.3f,%.3f) rotate(90)"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | . qq{ class="direction">trailing</text>\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ($self->width + 0.4) * 1.5 * $scale, $self->height/2 * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $doc .= sprintf(qq{ <text class="direction" x="%.3f" y="%.3f">rimward</text>\n}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $self->width/2 * 1.5 * $scale, ($self->height + 0.7) * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $doc .= sprintf(qq{ <text transform="translate(%.3f,%.3f) rotate(-90)"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | . qq{ class="direction">spinward</text>\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | -0.1 * $scale, $self->height/2 * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub footer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
footer: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $y = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $debug = ''; # for developers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | for my $line (split(/\n/, $debug)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $doc .= qq{<text xml:space="preserve" class="legend" y="$y" stroke="red">} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | . $line . qq{</text>\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $y += 20; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $doc .= qq{</svg>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my ($self, $map, $wiki, $source) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->source($source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->width(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->height(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my @lines = split(/\n/, $map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->initialize_map($wiki, \@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $self->initialize_routes(\@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub initialize_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_map: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($self, $wiki, $lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | foreach (@$lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # parse Traveller UWP, with optional name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ($name, $x, $y, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $starport, $size, $atmosphere, $hydrographic, $population, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $government, $law, $tech, $bases, $rest) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | /(?:([^>\r\n\t]*?)\s+)?(\d\d)(\d\d)\s+([A-EX])([\dA])([\dA-F])([\dA])([\dA-C])([\dA-F])([\dA-L])-(\d{1,2}|[\dA-HJ-NP-Z])(?:\s+([PCTRNSG ]+)\b)?(.*)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # alternative super simple name, coordinates, optional size (0-9), optional bases (PCTRNSG), optional travel zones (AR) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | ($name, $x, $y, $size, $bases, $rest) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x and $y
MC/DC0%0/2
$x and $y
$x
$y
Truth table0%0/3
A and B
A= $xB= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | /([^>\r\n\t]*?)\s+(\d\d)(\d\d)(?:\s+(\d)\b)?(?:\s+([PCTRNSG ]+)\b)?(.*)/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | unless $x and $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | next unless $x and $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x and $y
MC/DC0%0/2
$x and $y
$x
$y
Truth table0%0/3
A and B
A= $xB= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | $self->width($x) if $x > $self->width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $self->height($y) if $y > $self->height; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my @tokens = split(' ', $rest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my @colours = grep(/^$colour_re$/, @tokens); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my %trade = map { $_ => 1 } grep(/^[A-Z][A-Za-z]$/, @tokens); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my ($culture) = grep /^\[.*\]$/, @tokens; # culture in square brackets | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my ($travelzone) = grep /^([AR])$/, @tokens; # amber or red travel zone | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # avoid uninitialized values warnings in the rest of the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | map { $$_ //= '' } (\$size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$_ //= ""
MC/DC0%0/1
$$_ //= ""
$$_
Truth table0%0/2
A
A= $$_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | \$atmosphere, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | \$hydrographic, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | \$population, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | \$government, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | \$law, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | \$starport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | \$travelzone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # get "hex" values, but accept letters beyond F! (excepting I and O) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | map { $$_ = $$_ ge 'P' and $$_ le 'Z' ? 23 + ord($$_) - 80 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/9
($$_ = $$_ ge 'P') && ($$_ le 'Z' ? 23 + ord($$_) - 80 : $$_ ge 'J') && ($$_ le 'N' ? 18 + ord($$_) - 74 : $$_ ge 'A') && ($$_ le 'H' ? 10 + ord($$_) - 65 : ($$_ eq '' ? 0 : $$_))
$$_ = $$_ ge "P" and $$_ le "Z" ? 23 + ord($$_) - 80 : $$_ ge "J" and $$_ le "N" ? 18 + ord($$_) - 74 : $$_ ge "A"
$$_ = $$_ ge "P" and $$_ le "Z" ? 23 + ord($$_) - 80 : $$_ ge "J"
MC/DC0%0/4
($$_ = $$_ ge 'P') && ($$_ le 'Z' ? 23 + ord($$_) - 80 : $$_ ge 'J') && ($$_ le 'N' ? 18 + ord($$_) - 74 : $$_ ge 'A') && ($$_ le 'H' ? 10 + ord($$_) - 65 : ($$_ eq '' ? 0 : $$_))
$$_ = $$_ ge "P"
$$_ le "Z" ? 23 + ord($$_) - 80 : $$_ ge "J"
$$_ le "N" ? 18 + ord($$_) - 74 : $$_ ge "A"
($$_ le 'H' ? 10 + ord($$_) - 65 : ($$_ eq '' ? 0 : $$_))
Truth table0%0/5
A and B and C && D
A= $$_ = $$_ ge "P"B= $$_ le "Z" ? 23 + ord($$_) - 80 : $$_ ge "J"C= $$_ le "N" ? 18 + ord($$_) - 74 : $$_ ge "A"D= ($$_ le 'H' ? 10 + ord($$_) - 65 : ($$_ eq '' ? 0 : $$_))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | : $$_ ge 'J' and $$_ le 'N' ? 18 + ord($$_) - 74 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | : $$_ ge 'A' and $$_ le 'H' ? 10 + ord($$_) - 65 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | : $$_ eq '' ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | : $$_ } (\$size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | \$atmosphere, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | \$hydrographic, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | \$population, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | \$government, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | \$law); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $hex = Traveller::Hex->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$culture // ""
shift @colours || $self->colour($culture)
MC/DC0%0/1
$culture // ""
$culture
MC/DC0%0/2
shift @colours || $self->colour($culture)
shift @colours
$self->colour($culture)
Truth table0%0/2
A
A= $culture
Truth table0%0/3
A || B
A= shift @coloursB= $self->colour($culture)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | starport => $starport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | population => $population, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | travelzone => $travelzone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | trade => \%trade, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | culture => $culture // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | colour => shift(@colours) || $self->colour($culture)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $hex->url("$wiki$name") if $wiki; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ($bases) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | for my $base (split(//, $bases)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $hex->base($base); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->add($hex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my ($self, $hex) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | push(@{$self->hexes}, $hex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub initialize_routes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_routes: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my ($self, $lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | foreach (@$lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # parse non-standard routes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my ($from, $to, $type, $colour) = /^(\d\d\d\d)-(\d\d\d\d)\s+(C|T)\b\s*($colour_re)?/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | next unless $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if (lc($type) eq 'c') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->comm_set(1); # at least one hex here has comm | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | push(@{$self->at($from)->comm}, $self->at($to)); # a property of the hex | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->trade_set(1); # at least one hex here has trade | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $from_hex = $self->at($from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $to_hex = $self->at($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | push(@{$self->routes}, [$from_hex, $to_hex]); # a property of the mapper | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my ($self, $coord) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ($x, $y) = $coord =~ /(\d\d)(\d\d)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return $hex if $hex->x == $x and $hex->y == $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hex->x == $x and $hex->y == $y
MC/DC0%0/2
$hex->x == $x and $hex->y == $y
$hex->x == $x
$hex->y == $y
Truth table0%0/3
A and B
A= $hex->x == $xB= $hex->y == $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub communications { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
communications: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # connect all the class A starports, naval bases, and Imperial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # consulates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | return if $self->comm_set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my @candidates = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | push(@candidates, $hex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hex->starport eq "A" or $hex->naval or $hex->consulate
$hex->starport eq "A" or $hex->naval
MC/DC0%0/3
$hex->starport eq "A" or $hex->naval or $hex->consulate
$hex->starport eq "A"
$hex->naval
$hex->consulate
Truth table0%0/4
A or B or C
A= $hex->starport eq "A"B= $hex->navalC= $hex->consulate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | if $hex->starport eq 'A' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | or $hex->naval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | or $hex->consulate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # every system has a link to its neighbours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | foreach my $hex (@candidates) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my @ar = nearby($hex, 2, \@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $hex->comm(\@ar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # eliminate all but the best connections if the system has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # amber or red travel zone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | foreach my $hex (@candidates) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | next unless $hex->travelzone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | foreach my $other (@{$hex->comm}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if (not $best | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not $best or $other->starport lt $best->starport or $other->starport eq $best->starport and distance($hex, $other) < distance($hex, $best)
not $best or $other->starport lt $best->starport
$other->starport eq $best->starport and distance($hex, $other) < distance($hex, $best)
MC/DC0%0/4
not $best or $other->starport lt $best->starport or $other->starport eq $best->starport and distance($hex, $other) < distance($hex, $best)
not $best
$other->starport lt $best->starport
$other->starport eq $best->starport
distance($hex, $other) < distance($hex, $best)
Truth table0%0/5
not(A) or B or C and D
A= not $bestB= $other->starport lt $best->starportC= $other->starport eq $best->starportD= distance($hex, $other) < distance($hex, $best)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | or $other->starport lt $best->starport | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | or $other->starport eq $best->starport | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | and distance($hex, $other) < distance($hex, $best)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $best = $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $hex->eliminate(grep { $_ != $best } @{$hex->comm}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub trade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trade: not called CC=23 SCAR=63.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # connect In or Ht with As, De, Ic, Ni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # connect Hi or Ri with Ag, Ga, Wa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | return if $self->trade_set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # candidates need to be on a travel route, i.e. must have fuel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # available; skip worlds with a red travel zone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my @candidates = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | push(@candidates, $hex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | if ($hex->starport =~ /^[A-D]$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | or $hex->gasgiant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | or $hex->trade->{Wa}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | and $hex->travelzone ne 'R'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$hex->starport =~ /^[A-D]$/u || $hex->gasgiant || $hex->trade->{"Wa"} and $hex->travelzone ne "R"
$hex->starport =~ /^[A-D]$/u or $hex->gasgiant or $hex->trade->{"Wa"}
$hex->starport =~ /^[A-D]$/u or $hex->gasgiant
MC/DC0%0/4
$hex->starport =~ /^[A-D]$/u || $hex->gasgiant || $hex->trade->{"Wa"} and $hex->travelzone ne "R"
$hex->starport =~ /^[A-D]$/u
$hex->gasgiant
$hex->trade->{"Wa"}
$hex->travelzone ne "R"
Truth table0%0/7
A or B or C and D
A= $hex->starport =~ /^[A-D]$/uB= $hex->gasgiantC= $hex->trade->{"Wa"}D= $hex->travelzone ne "R"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # every system has a link to its partners | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | foreach my $hex (@candidates) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my @routes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if ($hex->trade->{In} or $hex->trade->{Ht}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$hex->trade->{"In"} or $hex->trade->{"Ht"}
MC/DC0%0/2
$hex->trade->{"In"} or $hex->trade->{"Ht"}
$hex->trade->{"In"}
$hex->trade->{"Ht"}
Truth table0%0/3
A or B
A= $hex->trade->{"In"}B= $hex->trade->{"Ht"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | foreach my $other (nearby($hex, 4, \@candidates)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | if ($other->trade->{As} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$other->trade->{"As"} or $other->trade->{"De"} or $other->trade->{"Ic"} or $other->trade->{"Ni"}
$other->trade->{"As"} or $other->trade->{"De"} or $other->trade->{"Ic"}
$other->trade->{"As"} or $other->trade->{"De"}
MC/DC0%0/4
$other->trade->{"As"} or $other->trade->{"De"} or $other->trade->{"Ic"} or $other->trade->{"Ni"}
$other->trade->{"As"}
$other->trade->{"De"}
$other->trade->{"Ic"}
$other->trade->{"Ni"}
Truth table0%0/5
A or B or C or D
A= $other->trade->{"As"}B= $other->trade->{"De"}C= $other->trade->{"Ic"}D= $other->trade->{"Ni"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | or $other->trade->{De} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | or $other->trade->{Ic} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | or $other->trade->{Ni}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my @route = $self->route($hex, $other, 4, \@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | push(@routes, \@route) if @route; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | ▶ | } elsif ($hex->trade->{Hi} or $hex->trade->{Ri}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$hex->trade->{"Hi"} or $hex->trade->{"Ri"}
MC/DC0%0/2
$hex->trade->{"Hi"} or $hex->trade->{"Ri"}
$hex->trade->{"Hi"}
$hex->trade->{"Ri"}
Truth table0%0/3
A or B
A= $hex->trade->{"Hi"}B= $hex->trade->{"Ri"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | foreach my $other (nearby($hex, 4, \@candidates)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($other->trade->{Ag} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$other->trade->{"Ag"} or $other->trade->{"Ga"} or $other->trade->{"Wa"}
$other->trade->{"Ag"} or $other->trade->{"Ga"}
MC/DC0%0/3
$other->trade->{"Ag"} or $other->trade->{"Ga"} or $other->trade->{"Wa"}
$other->trade->{"Ag"}
$other->trade->{"Ga"}
$other->trade->{"Wa"}
Truth table0%0/4
A or B or C
A= $other->trade->{"Ag"}B= $other->trade->{"Ga"}C= $other->trade->{"Wa"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | or $other->trade->{Ga} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | or $other->trade->{Wa}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my @route = $self->route($hex, $other, 4, \@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | push(@routes, \@route) if @route; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $hex->routes(\@routes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->routes($self->minimal_spanning_tree($self->edges(@candidates))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | sub edges { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
edges: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my @edges; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | foreach my $hex (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | foreach my $route (@{$hex->routes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my ($start, @route) = @{$route}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | foreach my $end (@route) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # keep everything unidirectional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | next if exists $seen{$start}{$end} or exists $seen{$end}{$start}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $seen{$start}{$end} or exists $seen{$end}{$start}
MC/DC0%0/2
exists $seen{$start}{$end} or exists $seen{$end}{$start}
exists $seen{$start}{$end}
exists $seen{$end}{$start}
Truth table0%0/3
A or B
A= exists $seen{$start}{$end}B= exists $seen{$end}{$start}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | push(@edges, [$start, $end, distance($start,$end)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $seen{$start}{$end} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $start = $end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return @edges; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub minimal_spanning_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minimal_spanning_tree: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # http://en.wikipedia.org/wiki/Kruskal%27s_algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # Initialize a priority queue Q to contain all edges in G, using the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # weights as keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my @Q = sort { @{$a}[2] <=> @{$b}[2] } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # Define a forest T ← Ø; T will ultimately contain the edges of the MST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my @T; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # Define an elementary cluster C(v) ← {v}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | my %C; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | foreach my $edge (@Q) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # edge u,v is the minimum weighted route from u to v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my ($u, $v) = @{$edge}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # $u = $u->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # $v = $v->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # prevent cycles in T; add u,v only if T does not already contain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # a path between u and v; also silence warnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if (not $C{$u} or not $C{$v} or $C{$u} != $C{$v}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $C{$u} && $C{$v} or $C{$u} != $C{$v}
$C{$u} && $C{$v}
MC/DC0%0/3
not $C{$u} && $C{$v} or $C{$u} != $C{$v}
$C{$u}
$C{$v}
$C{$u} != $C{$v}
Truth table0%0/4
not(A && B) or C
A= $C{$u}B= $C{$v}C= $C{$u} != $C{$v}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # Add edge (v,u) to T. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | push(@T, $edge); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # Merge C(v) and C(u) into one cluster, that is, union C(v) and C(u). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if ($C{$u} and $C{$v}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$C{$u} and $C{$v}
MC/DC0%0/2
$C{$u} and $C{$v}
$C{$u}
$C{$v}
Truth table0%0/3
A and B
A= $C{$u}B= $C{$v}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my @group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | foreach (keys %C) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | push(@group, $_) if $C{$_} == $C{$v}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $C{$_} = $C{$u} foreach @group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ▶ | } elsif ($C{$v} and not $C{$u}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$C{$v} and not $C{$u}
MC/DC0%0/2
$C{$v} and not $C{$u}
$C{$v}
not $C{$u}
Truth table0%0/3
A and not(B)
A= $C{$v}B= not $C{$u}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $C{$u} = $C{$v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | ▶ | } elsif ($C{$u} and not $C{$v}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$C{$u} and not $C{$v}
MC/DC0%0/2
$C{$u} and not $C{$v}
$C{$u}
not $C{$v}
Truth table0%0/3
A and not(B)
A= $C{$u}B= not $C{$v}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $C{$v} = $C{$u}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ▶ | } elsif (not $C{$u} and not $C{$v}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$C{$u} || $C{$v}
MC/DC0%0/2
$C{$u} || $C{$v}
$C{$u}
$C{$v}
Truth table0%0/3
A || B
A= $C{$u}B= $C{$v}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $C{$v} = $C{$u} = ++$id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | return \@T; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | sub route { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
route: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # Compute the shortest route between two hexes no longer than a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # certain distance and choosing intermediary steps from the array of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # possible candidates. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my ($self, $from, $to, $distance, $candidatesref, @seen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # my $indent = ' ' x (4-$distance); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my @options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | foreach my $hex (nearby($from, $distance < 2 ? $distance : 2, $candidatesref)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | push (@options, $hex) unless in($hex, @seen); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | return unless @options and $distance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@options and $distance
MC/DC0%0/2
@options and $distance
@options
$distance
Truth table0%0/3
A and B
A= @optionsB= $distance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if (in($to, @options)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | return @seen, $from, $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my @routes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | foreach my $hex (@options) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my @route = $self->route($hex, $to, $distance - distance($from, $hex), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | $candidatesref, @seen, $from); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if (@route) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | push(@routes, \@route); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | return unless @routes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # return the shortest one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my @shortest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | foreach my $route (@routes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if ($#{$route} < $#shortest or not @shortest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$#{$route;} < $#shortest or not @shortest
MC/DC0%0/2
$#{$route;} < $#shortest or not @shortest
$#{$route;} < $#shortest
not @shortest
Truth table0%0/3
A or not(B)
A= $#{$route;} < $#shortestB= not @shortest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | @shortest = @{$route}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | return @shortest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | sub trade_svg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trade_svg: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | my $scale = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | foreach my $edge (@{$self->routes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $u = @{$edge}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | my $v = @{$edge}[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my ($x1, $y1) = ($u->x, $u->y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my ($x2, $y2) = ($v->x, $v->y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $data .= sprintf(qq{ <line class="trade" x1="%.3f" y1="%.3f" x2="%.3f" y2="%.3f" />\n}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | (1 + ($x1-1) * 1.5) * $scale, ($y1 - $x1%2/2) * sqrt(3) * $scale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | (1 + ($x2-1) * 1.5) * $scale, ($y2 - $x2%2/2) * sqrt(3) * $scale); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | sub svg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
svg: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my ($self, $width, $height) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my $data = $self->header($width, $height); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $data .= qq{ <g id='background'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $data .= $self->background; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $data .= qq{ </g>\n\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $data .= qq{ <g id='comm'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $data .= $hex->comm_svg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $data .= qq{ </g>\n\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $data .= qq{ <g id='routes'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $data .= $self->trade_svg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $data .= qq{ </g>\n\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $data .= qq{ <g id='grid'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $data .= $self->grid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $data .= qq{ </g>\n\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $data .= qq{ <g id='legend'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $data .= $self->legend(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $data .= qq{ </g>\n\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $data .= qq{ <g id='system'>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $data .= $hex->system_svg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $data .= qq{ </g>\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $data .= $self->footer(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $data = "Trade Routes:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | foreach my $edge (@{$self->routes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my $u = @{$edge}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $v = @{$edge}[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $data .= $u->name . " - " . $v->name . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $data .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $data .= "Raw Data:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | foreach my $routeref (@{$hex->routes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $data .= join(' - ', map {$_->name} @{$routeref}) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $data .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $data .= "Communications:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | foreach my $hex (@{$self->hexes}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | foreach my $comm (@{$hex->comm}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $data .= $hex->name . " - " . $comm->name . "\n";; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||