lib/Traveller/System.pm

filter: Statementstmt 100% 216 / 216 Branchbran 97.6% 164 / 168 Conditioncond 95.2% 180 / 189 MC/DCmcdc 91.4% 96 / 105 Subroutinesub 100% 21 / 21 Podpod 0.0% 0 / 17 totaltotal 94.5% 677 / 716 CC 148 SCAR 31.3
CC
148
Cov
98%
compute_tradecodes
45.0
compute_tech
26.0
check_doom
21.5
CRAP 23.0
« lib/Traveller/Hex.pm ↑ Summary script/traveller »
1 #!/usr/bin/perl
2 # Copyright (C) 2009-2021 Alex Schroeder <alex@gnu.org>
3 # Copyright (C) 2020 Christian Carey
4 #
5 # This program is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
8 # version.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # this program. If not, see <http://www.gnu.org/licenses/>.
16  
17 package Traveller::System;
18 2 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use List::Util qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 has 'name';
22 2 has 'x';
23 2 has 'y';
24 2 has 'starport';
25 2 has 'size';
26 2 has 'atmosphere';
27 2 has 'temperature';
28 2 has 'hydro';
29 2 has 'population';
30 2 has 'government';
31 2 has 'law';
32 2 has 'tech';
33 2 has 'consulate';
34 2 has 'pirate';
35 2 has 'TAS';
36 2 has 'research';
37 2 has 'naval';
38 2 has 'scout';
39 2 has 'gasgiant';
40 2 has 'tradecodes';
41 2 has 'travelzone';
42 2 has 'culture';
43  
44 1506 ▶sub compute_name {
Subroutine compute_name: called CC=2 SCAR=6.9
Pod undocumented
45 1506 my $self = shift;
46 1506 my $digraphs = shift;
47 1506 my $max = scalar(@$digraphs);
48 1506 my $length = 3 + rand(3); # length of name before adding one more
49 1506 my $name = '';
50 1506 ▶ while (length($name) < $length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $name < $length) 3533 1506 5039
51 3533 my $i = 2*int(rand($max/2));
52 3533 $name .= $digraphs->[$i];
53 3533 $name .= $digraphs->[$i+1];
54 }
55 1506 $name =~ s/\.//g;
56 1506 return ucfirst($name);
57 }
58  
59 17837 ▶sub roll1d6 {
Subroutine roll1d6: called CC=1 SCAR=0.0
Pod undocumented
60 17837 return 1+int(rand(6));
61 }
62  
63 8582 ▶sub roll2d6 {
Subroutine roll2d6: called CC=1 SCAR=0.0
Pod undocumented
64 8582 my $self = shift;
65 8582 return $self->roll1d6() + $self->roll1d6();
66 }
67  
68 673 ▶sub compute_starport {
Subroutine compute_starport: called CC=1 SCAR=0.0
Pod undocumented
69 673 my $self = shift;
70 673 my %map = ( 2=>'X', 3=>'E', 4=>'E', 5=>'D', 6=>'D', 7=>'C',
71 8=>'C', 9=>'B', 10=>'B', 11=>'A', 12=>'A' );
72 673 return $map{$self->roll2d6()};
73 }
74  
75 673 ▶sub compute_bases {
Subroutine compute_bases: called CC=6 SCAR=17.9
Pod undocumented
76 673 my $self = shift;
77 673 ▶ if ($self->starport eq 'A') {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->starport eq 'A') { } 54 619 673
elsif ($self->starport eq 'B') { } 136 483 619
elsif ($self->starport eq 'C') { } 202 281 483
elsif ($self->starport eq 'D') { } 167 114 281
elsif ($self->starport eq 'E') { } 95 19 114
78 54 $self->naval($self->roll2d6() >= 8);
79 54 $self->scout($self->roll2d6() >= 10);
80 54 $self->research($self->roll2d6() >= 8);
81 54 $self->TAS($self->roll2d6() >= 4);
82 54 $self->consulate($self->roll2d6() >= 6);
83 } elsif ($self->starport eq 'B') {
84 136 $self->naval($self->roll2d6() >= 8);
85 136 $self->scout($self->roll2d6() >= 8);
86 136 $self->research($self->roll2d6() >= 10);
87 136 $self->TAS($self->roll2d6() >= 6);
88 136 $self->consulate($self->roll2d6() >= 8);
89 136 $self->pirate($self->roll2d6() >= 12);
90 } elsif ($self->starport eq 'C') {
91 202 $self->scout($self->roll2d6() >= 8);
92 202 $self->research($self->roll2d6() >= 10);
93 202 $self->TAS($self->roll2d6() >= 10);
94 202 $self->consulate($self->roll2d6() >= 10);
95 202 $self->pirate($self->roll2d6() >= 10);
96 } elsif ($self->starport eq 'D') {
97 167 $self->scout($self->roll2d6() >= 7);
98 167 $self->pirate($self->roll2d6() >= 12);
99 } elsif ($self->starport eq 'E') {
100 95 $self->pirate($self->roll2d6() >= 12);
101 }
102 673 $self->gasgiant($self->roll2d6() < 10);
103 }
104  
105 673 ▶sub compute_atmosphere {
Subroutine compute_atmosphere: called CC=2 SCAR=6.9
Pod undocumented
106 673 my $self = shift;
107 673 my $atmosphere = $self->roll2d6() -7 + $self->size;
108 673 ▶ $atmosphere = 0 if $atmosphere < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere < 0 31 642 673
109 673 return $atmosphere;
110 }
111  
112 673 ▶sub compute_temperature {
Subroutine compute_temperature: called CC=13 SCAR=25.7
Pod undocumented
113 673 my $self = shift;
114 673 my $temperature = $self->roll2d6();
115 673 my $atmosphere = $self->atmosphere;
116 673 ▶ $temperature -= 2
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere == 2 or $atmosphere == 3 109 564 673
Condition100%3/3
$atmosphere == 2 or $atmosphere == 3
l!l&&r!l&&!r
5257564
MC/DC100%2/2
$atmosphere == 2 or $atmosphere == 3
$atmosphere == 2 $atmosphere == 3
Truth table100%3/3
A or B
A= $atmosphere == 2B= $atmosphere == 3
ABresult
1X1
011
000
117 if $atmosphere == 2
118 or $atmosphere == 3;
119 673 ▶ $temperature -= 1
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere == 3 or $atmosphere == 4 or $atmosphere == 14 137 536 673
Condition100%6/6
$atmosphere == 3 or $atmosphere == 4 or $atmosphere == 14
l!l&&r!l&&!r
1352536
$atmosphere == 3 or $atmosphere == 4
l!l&&r!l&&!r
5778538
MC/DC100%3/3
$atmosphere == 3 or $atmosphere == 4 or $atmosphere == 14
$atmosphere == 3 $atmosphere == 4 $atmosphere == 14
Truth table100%4/4
A or B or C
A= $atmosphere == 3B= $atmosphere == 4C= $atmosphere == 14
ABCresult
1XX1
01X1
0011
0000
120 if $atmosphere == 3
121 or $atmosphere == 4
122 or $atmosphere == 14; # E
123 673 ▶ $temperature += 1
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere == 8 or $atmosphere == 9 89 584 673
Condition100%3/3
$atmosphere == 8 or $atmosphere == 9
l!l&&r!l&&!r
5534584
MC/DC100%2/2
$atmosphere == 8 or $atmosphere == 9
$atmosphere == 8 $atmosphere == 9
Truth table100%3/3
A or B
A= $atmosphere == 8B= $atmosphere == 9
ABresult
1X1
011
000
124 if $atmosphere == 8
125 or $atmosphere == 9;
126 673 ▶ $temperature += 2
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere == 10 or $atmosphere == 13 or $atmosphere == 15 39 634 673
Condition83%5/6
$atmosphere == 10 or $atmosphere == 13 or $atmosphere == 15
l!l&&r!l&&!r
390634
$atmosphere == 10 or $atmosphere == 13
l!l&&r!l&&!r
345634
MC/DC66%2/3
$atmosphere == 10 or $atmosphere == 13 or $atmosphere == 15
$atmosphere == 10 $atmosphere == 13 $atmosphere == 15
Truth table75%3/4
A or B or C
A= $atmosphere == 10B= $atmosphere == 13C= $atmosphere == 15
ABCresult
1XX1
01X1
0011
0000
127 if $atmosphere == 10 # A
128 or $atmosphere == 13 # D
129 or $atmosphere == 15; # F
130 673 ▶ $temperature += 6
Branch: 1 branch
BranchTrueFalseTotal
if $atmosphere == 11 or $atmosphere == 12 29 644 673
Condition100%3/3
$atmosphere == 11 or $atmosphere == 12
l!l&&r!l&&!r
1514644
MC/DC100%2/2
$atmosphere == 11 or $atmosphere == 12
$atmosphere == 11 $atmosphere == 12
Truth table100%3/3
A or B
A= $atmosphere == 11B= $atmosphere == 12
ABresult
1X1
011
000
131 if $atmosphere == 11 # B
132 or $atmosphere == 12; # C
133 673 return $temperature;
134 }
135  
136 673 ▶sub compute_hydro {
Subroutine compute_hydro: called CC=14 SCAR=26.4
Pod undocumented
137 673 my $self = shift;
138 673 my $hydro = $self->roll2d6() - 7 + $self->size;
139 673 ▶ $hydro -= 4
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 0 or $self->atmosphere == 1 or $self->atmosphere == 10 or $self->atmosphere == 11 or $self->atmosphere == 12 165 508 673
Condition100%12/12
$self->atmosphere == 0 or $self->atmosphere == 1 or $self->atmosphere == 10 or $self->atmosphere == 11 or $self->atmosphere == 12
l!l&&r!l&&!r
15114508
$self->atmosphere == 0 or $self->atmosphere == 1 or $self->atmosphere == 10 or $self->atmosphere == 11
l!l&&r!l&&!r
13615522
$self->atmosphere == 0 or $self->atmosphere == 1 or $self->atmosphere == 10
l!l&&r!l&&!r
10234537
$self->atmosphere == 0 or $self->atmosphere == 1
l!l&&r!l&&!r
6141571
MC/DC100%5/5
$self->atmosphere == 0 or $self->atmosphere == 1 or $self->atmosphere == 10 or $self->atmosphere == 11 or $self->atmosphere == 12
$self->atmosphere == 0 $self->atmosphere == 1 $self->atmosphere == 10 $self->atmosphere == 11 $self->atmosphere == 12
Truth table100%6/6
A or B or C or D or E
A= $self->atmosphere == 0B= $self->atmosphere == 1C= $self->atmosphere == 10D= $self->atmosphere == 11E= $self->atmosphere == 12
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
140 if $self->atmosphere == 0
141 or $self->atmosphere == 1
142 or $self->atmosphere == 10 # A
143 or $self->atmosphere == 11 # B
144 or $self->atmosphere == 12; # C
145 673 ▶ $hydro -= 2
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere != 13 and $self->temperature >= 10 and $self->temperature <= 11 74 599 673
Condition100%6/6
$self->atmosphere != 13 and $self->temperature >= 10 and $self->temperature <= 11
!ll&&!rl&&r
5534674
$self->atmosphere != 13 and $self->temperature >= 10
!ll&&!rl&&r
5548120
MC/DC100%3/3
$self->atmosphere != 13 and $self->temperature >= 10 and $self->temperature <= 11
$self->atmosphere != 13 $self->temperature >= 10 $self->temperature <= 11
Truth table100%4/4
A and B and C
A= $self->atmosphere != 13B= $self->temperature >= 10C= $self->temperature <= 11
ABCresult
0XX0
10X0
1100
1111
146 if $self->atmosphere != 13 # D
147 and $self->temperature >= 10
148 and $self->temperature <= 11;
149 673 ▶ $hydro -= 6
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere != 13 and $self->temperature >= 12 46 627 673
Condition100%3/3
$self->atmosphere != 13 and $self->temperature >= 12
!ll&&!rl&&r
562246
MC/DC100%2/2
$self->atmosphere != 13 and $self->temperature >= 12
$self->atmosphere != 13 $self->temperature >= 12
Truth table100%3/3
A and B
A= $self->atmosphere != 13B= $self->temperature >= 12
ABresult
0X0
100
111
150 if $self->atmosphere != 13 # D
151 and $self->temperature >= 12;
152 673 ▶ $hydro = 0
Branch: 1 branch
BranchTrueFalseTotal
if $self->size <= 1 or $hydro < 0 131 542 673
Condition100%3/3
$self->size <= 1 or $hydro < 0
l!l&&r!l&&!r
4685542
MC/DC100%2/2
$self->size <= 1 or $hydro < 0
$self->size <= 1 $hydro < 0
Truth table100%3/3
A or B
A= $self->size <= 1B= $hydro < 0
ABresult
1X1
011
000
153 if $self->size <= 1
154 or $hydro < 0;
155 673 ▶ $hydro = 10 if $hydro > 10;
Branch: 1 branch
BranchTrueFalseTotal
if $hydro > 10 18 655 673
156 673 return $hydro;
157 }
158  
159 673 ▶sub compute_government {
Subroutine compute_government: called CC=3 SCAR=11.0
Pod undocumented
160 673 my $self = shift;
161 673 my $government = $self->roll2d6() - 7 + $self->population; # max 15
162 673 ▶ $government = 0
Branch: 1 branch
BranchTrueFalseTotal
if $government < 0 or $self->population == 0 44 629 673
Condition100%3/3
$government < 0 or $self->population == 0
l!l&&r!l&&!r
3311629
MC/DC100%2/2
$government < 0 or $self->population == 0
$government < 0 $self->population == 0
Truth table100%3/3
A or B
A= $government < 0B= $self->population == 0
ABresult
1X1
011
000
163 if $government < 0
164 or $self->population == 0;
165 673 return $government;
166 }
167  
168 673 ▶sub compute_law {
Subroutine compute_law: called CC=3 SCAR=11.0
Pod undocumented
169 673 my $self = shift;
170 673 my $law = $self->roll2d6()-7+$self->government; # max 20!
171 673 ▶ $law = 0
Branch: 1 branch
BranchTrueFalseTotal
if $law < 0 or $self->population == 0 69 604 673
Condition100%3/3
$law < 0 or $self->population == 0
l!l&&r!l&&!r
5811604
MC/DC100%2/2
$law < 0 or $self->population == 0
$law < 0 $self->population == 0
Truth table100%3/3
A or B
A= $law < 0B= $self->population == 0
ABresult
1X1
011
000
172 if $law < 0
173 or $self->population == 0;
174 673 return $law;
175 }
176  
177 673 ▶sub compute_tech {
Subroutine compute_tech: called CC=26 SCAR=32.6
Pod undocumented
178 673 my $self = shift;
179 673 my $tech = $self->roll1d6();
180 673 ▶ $tech += 6 if $self->starport eq 'A';
Branch: 1 branch
BranchTrueFalseTotal
if $self->starport eq "A" 54 619 673
181 673 ▶ $tech += 4 if $self->starport eq 'B';
Branch: 1 branch
BranchTrueFalseTotal
if $self->starport eq "B" 136 537 673
182 673 ▶ $tech += 2 if $self->starport eq 'C';
Branch: 1 branch
BranchTrueFalseTotal
if $self->starport eq "C" 202 471 673
183 673 ▶ $tech -= 4 if $self->starport eq 'X';
Branch: 1 branch
BranchTrueFalseTotal
if $self->starport eq "X" 19 654 673
184 673 ▶ $tech += 2 if $self->size <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->size <= 1 46 627 673
185 673 ▶ $tech += 1 if $self->size >= 2 and $self->size <= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $self->size >= 2 and $self->size <= 4 218 455 673
Condition100%3/3
$self->size >= 2 and $self->size <= 4
!ll&&!rl&&r
46409218
MC/DC100%2/2
$self->size >= 2 and $self->size <= 4
$self->size >= 2 $self->size <= 4
Truth table100%3/3
A and B
A= $self->size >= 2B= $self->size <= 4
ABresult
0X0
100
111
186 673 ▶ $tech += 1 if $self->atmosphere <= 3 or $self->atmosphere >= 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere <= 3 or $self->atmosphere >= 10 281 392 673
Condition100%3/3
$self->atmosphere <= 3 or $self->atmosphere >= 10
l!l&&r!l&&!r
21170392
MC/DC100%2/2
$self->atmosphere <= 3 or $self->atmosphere >= 10
$self->atmosphere <= 3 $self->atmosphere >= 10
Truth table100%3/3
A or B
A= $self->atmosphere <= 3B= $self->atmosphere >= 10
ABresult
1X1
011
000
187 673 ▶ $tech += 1 if $self->hydro == 0 or $self->hydro == 9;
Branch: 1 branch
BranchTrueFalseTotal
if $self->hydro == 0 or $self->hydro == 9 203 470 673
Condition100%3/3
$self->hydro == 0 or $self->hydro == 9
l!l&&r!l&&!r
16934470
MC/DC100%2/2
$self->hydro == 0 or $self->hydro == 9
$self->hydro == 0 $self->hydro == 9
Truth table100%3/3
A or B
A= $self->hydro == 0B= $self->hydro == 9
ABresult
1X1
011
000
188 673 ▶ $tech += 2 if $self->hydro == 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->hydro == 10 34 639 673
189 673 ▶ $tech += 1 if $self->population >= 1 and $self->population <= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 1 and $self->population <= 5 382 291 673
Condition100%3/3
$self->population >= 1 and $self->population <= 5
!ll&&!rl&&r
17274382
MC/DC100%2/2
$self->population >= 1 and $self->population <= 5
$self->population >= 1 $self->population <= 5
Truth table100%3/3
A and B
A= $self->population >= 1B= $self->population <= 5
ABresult
0X0
100
111
190 673 ▶ $tech += 1 if $self->population == 9;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 9 41 632 673
191 673 ▶ $tech += 2 if $self->population == 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 10 21 652 673
192 673 ▶ $tech += 3 if $self->population == 11; # impossible?
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 11 0 673 673
193 673 ▶ $tech += 4 if $self->population == 12; # impossible?
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 12 0 673 673
194 673 ▶ $tech += 1 if $self->government == 0 or $self->government == 5;
Branch: 1 branch
BranchTrueFalseTotal
if $self->government == 0 or $self->government == 5 137 536 673
Condition100%3/3
$self->government == 0 or $self->government == 5
l!l&&r!l&&!r
6275536
MC/DC100%2/2
$self->government == 0 or $self->government == 5
$self->government == 0 $self->government == 5
Truth table100%3/3
A or B
A= $self->government == 0B= $self->government == 5
ABresult
1X1
011
000
195 673 ▶ $tech += 2 if $self->government == 7;
Branch: 1 branch
BranchTrueFalseTotal
if $self->government == 7 74 599 673
196 673 ▶ $tech -= 2 if $self->government == 13 or $self->government == 14;
Branch: 1 branch
BranchTrueFalseTotal
if $self->government == 13 or $self->government == 14 7 666 673
Condition100%3/3
$self->government == 13 or $self->government == 14
l!l&&r!l&&!r
52666
MC/DC100%2/2
$self->government == 13 or $self->government == 14
$self->government == 13 $self->government == 14
Truth table100%3/3
A or B
A= $self->government == 13B= $self->government == 14
ABresult
1X1
011
000
197 673 ▶ $tech = 0 if $self->population == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 0 17 656 673
198 673 ▶ $tech = 15 if $tech > 15;
Branch: 1 branch
BranchTrueFalseTotal
if $tech > 15 4 669 673
199 673 return $tech;
200 }
201  
202 673 ▶sub check_doom {
Subroutine check_doom: called CC=21 SCAR=30.7
Pod undocumented
203 673 my $self = shift;
204 673 my $doomed = 0;
205 673 ▶ $doomed = 1 if $self->atmosphere <= 1 and $self->tech < 8;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere <= 1 and $self->tech < 8 24 649 673
Condition100%3/3
$self->atmosphere <= 1 and $self->tech < 8
!ll&&!rl&&r
5717824
MC/DC100%2/2
$self->atmosphere <= 1 and $self->tech < 8
$self->atmosphere <= 1 $self->tech < 8
Truth table100%3/3
A and B
A= $self->atmosphere <= 1B= $self->tech < 8
ABresult
0X0
100
111
206 673 ▶ $doomed = 1 if $self->atmosphere <= 3 and $self->tech < 5;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere <= 3 and $self->tech < 5 20 653 673
Condition100%3/3
$self->atmosphere <= 3 and $self->tech < 5
!ll&&!rl&&r
46219120
MC/DC100%2/2
$self->atmosphere <= 3 and $self->tech < 5
$self->atmosphere <= 3 $self->tech < 5
Truth table100%3/3
A and B
A= $self->atmosphere <= 3B= $self->tech < 5
ABresult
0X0
100
111
207 673 ▶ $doomed = 1 if ($self->atmosphere == 4
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 4 || $self->atmosphere == 7 || $self->atmosphere == 9 and $self->tech < 3 13 660 673
Condition100%9/9
$self->atmosphere == 4 || $self->atmosphere == 7 || $self->atmosphere == 9 and $self->tech < 3
!ll&&!rl&&r
49616413
$self->atmosphere == 4 or $self->atmosphere == 7 or $self->atmosphere == 9
l!l&&r!l&&!r
14334496
$self->atmosphere == 4 or $self->atmosphere == 7
l!l&&r!l&&!r
7865530
MC/DC100%4/4
$self->atmosphere == 4 || $self->atmosphere == 7 || $self->atmosphere == 9 and $self->tech < 3
$self->atmosphere == 4 $self->atmosphere == 7 $self->atmosphere == 9 $self->tech < 3
Truth table100%7/7
A or B or C and D
A= $self->atmosphere == 4B= $self->atmosphere == 7C= $self->atmosphere == 9D= $self->tech < 3
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
208 or $self->atmosphere == 7
209 or $self->atmosphere == 9) and $self->tech < 3;
210 673 ▶ $doomed = 1 if $self->atmosphere == 10 and $self->tech < 8;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 10 and $self->tech < 8 20 653 673
Condition100%3/3
$self->atmosphere == 10 and $self->tech < 8
!ll&&!rl&&r
6391420
MC/DC100%2/2
$self->atmosphere == 10 and $self->tech < 8
$self->atmosphere == 10 $self->tech < 8
Truth table100%3/3
A and B
A= $self->atmosphere == 10B= $self->tech < 8
ABresult
0X0
100
111
211 673 ▶ $doomed = 1 if $self->atmosphere == 11 and $self->tech < 9;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 11 and $self->tech < 9 7 666 673
Condition100%3/3
$self->atmosphere == 11 and $self->tech < 9
!ll&&!rl&&r
65887
MC/DC100%2/2
$self->atmosphere == 11 and $self->tech < 9
$self->atmosphere == 11 $self->tech < 9
Truth table100%3/3
A and B
A= $self->atmosphere == 11B= $self->tech < 9
ABresult
0X0
100
111
212 673 ▶ $doomed = 1 if $self->atmosphere == 12 and $self->tech < 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 12 and $self->tech < 10 11 662 673
Condition100%3/3
$self->atmosphere == 12 and $self->tech < 10
!ll&&!rl&&r
659311
MC/DC100%2/2
$self->atmosphere == 12 and $self->tech < 10
$self->atmosphere == 12 $self->tech < 10
Truth table100%3/3
A and B
A= $self->atmosphere == 12B= $self->tech < 10
ABresult
0X0
100
111
213 673 ▶ $doomed = 1 if ($self->atmosphere == 13
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 13 and $self->atmosphere == 14 and $self->tech < 5 0 673 673
Condition50%3/6
$self->atmosphere == 13 and $self->atmosphere == 14 and $self->tech < 5
!ll&&!rl&&r
67300
$self->atmosphere == 13 and $self->atmosphere == 14
!ll&&!rl&&r
66850
MC/DC0%0/3
$self->atmosphere == 13 and $self->atmosphere == 14 and $self->tech < 5
$self->atmosphere == 13 $self->atmosphere == 14 $self->tech < 5
Truth table50%2/4
A and B and C
A= $self->atmosphere == 13B= $self->atmosphere == 14C= $self->tech < 5
ABCresult
0XX0
10X0
1100
1111
214 and $self->atmosphere == 14) and $self->tech < 5;
215 673 ▶ $doomed = 1 if $self->atmosphere == 15 and $self->tech < 8;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 15 and $self->tech < 8 0 673 673
Condition33%1/3
$self->atmosphere == 15 and $self->tech < 8
!ll&&!rl&&r
67300
MC/DC0%0/2
$self->atmosphere == 15 and $self->tech < 8
$self->atmosphere == 15 $self->tech < 8
Truth table33%1/3
A and B
A= $self->atmosphere == 15B= $self->tech < 8
ABresult
0X0
100
111
216 673 ▶ if ($doomed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doomed) 88 585 673
217 88 $self->population(0);
218 88 $self->government(0);
219 88 $self->law(0);
220 88 $self->tech(0);
221 }
222 }
223  
224 673 ▶sub compute_tradecodes {
Subroutine compute_tradecodes: called CC=45 SCAR=38.1
Pod undocumented
225 673 my $self = shift;
226 673 my $tradecodes = '';
227 673 ▶ $tradecodes .= " Ag" if $self->atmosphere >= 4 and $self->atmosphere <= 9
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8 and $self->population >= 5 and $self->population <= 7 100 573 673
Condition100%15/15
$self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8 and $self->population >= 5 and $self->population <= 7
!ll&&!rl&&r
53439100
$self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8 and $self->population >= 5
!ll&&!rl&&r
45084139
$self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8
!ll&&!rl&&r
38961223
$self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4
!ll&&!rl&&r
281108284
$self->atmosphere >= 4 and $self->atmosphere <= 9
!ll&&!rl&&r
21170392
MC/DC100%6/6
$self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8 and $self->population >= 5 and $self->population <= 7
$self->atmosphere >= 4 $self->atmosphere <= 9 $self->hydro >= 4 $self->hydro <= 8 $self->population >= 5 $self->population <= 7
Truth table100%7/7
A and B and C and D and E and F
A= $self->atmosphere >= 4B= $self->atmosphere <= 9C= $self->hydro >= 4D= $self->hydro <= 8E= $self->population >= 5F= $self->population <= 7
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
228 and $self->hydro >= 4 and $self->hydro <= 8
229 and $self->population >= 5 and $self->population <= 7;
230 673 ▶ $tradecodes .= " As" if $self->size == 0 and $self->atmosphere == 0 and $self->hydro == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->size == 0 and $self->atmosphere == 0 and $self->hydro == 0 8 665 673
Condition83%5/6
$self->size == 0 and $self->atmosphere == 0 and $self->hydro == 0
!ll&&!rl&&r
66508
$self->size == 0 and $self->atmosphere == 0
!ll&&!rl&&r
66058
MC/DC66%2/3
$self->size == 0 and $self->atmosphere == 0 and $self->hydro == 0
$self->size == 0 $self->atmosphere == 0 $self->hydro == 0
Truth table75%3/4
A and B and C
A= $self->size == 0B= $self->atmosphere == 0C= $self->hydro == 0
ABCresult
0XX0
10X0
1100
1111
231 673 ▶ $tradecodes .= " Ba" if $self->population == 0 and $self->government == 0 and $self->law == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population == 0 and $self->government == 0 and $self->law == 0 93 580 673
Condition66%4/6
$self->population == 0 and $self->government == 0 and $self->law == 0
!ll&&!rl&&r
580093
$self->population == 0 and $self->government == 0
!ll&&!rl&&r
580093
MC/DC33%1/3
$self->population == 0 and $self->government == 0 and $self->law == 0
$self->population == 0 $self->government == 0 $self->law == 0
Truth table50%2/4
A and B and C
A= $self->population == 0B= $self->government == 0C= $self->law == 0
ABCresult
0XX0
10X0
1100
1111
232 673 ▶ $tradecodes .= " De" if $self->atmosphere >= 2 and $self->hydro == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere >= 2 and $self->hydro == 0 90 583 673
Condition100%3/3
$self->atmosphere >= 2 and $self->hydro == 0
!ll&&!rl&&r
10248190
MC/DC100%2/2
$self->atmosphere >= 2 and $self->hydro == 0
$self->atmosphere >= 2 $self->hydro == 0
Truth table100%3/3
A and B
A= $self->atmosphere >= 2B= $self->hydro == 0
ABresult
0X0
100
111
233 673 ▶ $tradecodes .= " Fl" if $self->atmosphere >= 10 and $self->hydro >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere >= 10 and $self->hydro >= 1 38 635 673
Condition100%3/3
$self->atmosphere >= 10 and $self->hydro >= 1
!ll&&!rl&&r
6033238
MC/DC100%2/2
$self->atmosphere >= 10 and $self->hydro >= 1
$self->atmosphere >= 10 $self->hydro >= 1
Truth table100%3/3
A and B
A= $self->atmosphere >= 10B= $self->hydro >= 1
ABresult
0X0
100
111
234 673 ▶ $tradecodes .= " Ga" if $self->size >= 5
Branch: 1 branch
BranchTrueFalseTotal
if $self->size >= 5 and $self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8 181 492 673
Condition100%12/12
$self->size >= 5 and $self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8
!ll&&!rl&&r
43260181
$self->size >= 5 and $self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4
!ll&&!rl&&r
38250241
$self->size >= 5 and $self->atmosphere >= 4 and $self->atmosphere <= 9
!ll&&!rl&&r
31270291
$self->size >= 5 and $self->atmosphere >= 4
!ll&&!rl&&r
26448361
MC/DC100%5/5
$self->size >= 5 and $self->atmosphere >= 4 and $self->atmosphere <= 9 and $self->hydro >= 4 and $self->hydro <= 8
$self->size >= 5 $self->atmosphere >= 4 $self->atmosphere <= 9 $self->hydro >= 4 $self->hydro <= 8
Truth table100%6/6
A and B and C and D and E
A= $self->size >= 5B= $self->atmosphere >= 4C= $self->atmosphere <= 9D= $self->hydro >= 4E= $self->hydro <= 8
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
235 and $self->atmosphere >= 4 and $self->atmosphere <= 9
236 and $self->hydro >= 4 and $self->hydro <= 8;
237 673 ▶ $tradecodes .= " Hi" if $self->population >= 9;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 9 58 615 673
238 673 ▶ $tradecodes .= " Ht" if $self->tech >= 12;
Branch: 1 branch
BranchTrueFalseTotal
if $self->tech >= 12 76 597 673
239 673 ▶ $tradecodes .= " Ic" if $self->atmosphere <= 1 and $self->hydro >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere <= 1 and $self->hydro >= 1 23 650 673
Condition100%3/3
$self->atmosphere <= 1 and $self->hydro >= 1
!ll&&!rl&&r
5717923
MC/DC100%2/2
$self->atmosphere <= 1 and $self->hydro >= 1
$self->atmosphere <= 1 $self->hydro >= 1
Truth table100%3/3
A and B
A= $self->atmosphere <= 1B= $self->hydro >= 1
ABresult
0X0
100
111
240 673 ▶ $tradecodes .= " In" if $self->population >= 9 and any { $_ == $self->atmosphere } qw(0 1 2 4 7 9);
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 9 and &any(sub { $_ == $self->atmosphere; } , 0, 1, 2, 4, 7, 9) 23 650 673
Condition100%3/3
$self->population >= 9 and &any(sub { $_ == $self->atmosphere; } , 0, 1, 2, 4, 7, 9)
!ll&&!rl&&r
6153523
MC/DC100%2/2
$self->population >= 9 and &any(sub { $_ == $self->atmosphere; } , 0, 1, 2, 4, 7, 9)
$self->population >= 9 &any(sub { $_ == $self->atmosphere; } , 0, 1, 2, 4, 7, 9)
Truth table100%3/3
A and B
A= $self->population >= 9B= &any(sub { $_ == $self->atmosphere; } , 0, 1, 2, 4, 7, 9)
ABresult
0X0
100
111
241 673 ▶ $tradecodes .= " Lo" if $self->population >= 1 and $self->population <= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 1 and $self->population <= 3 161 512 673
Condition100%3/3
$self->population >= 1 and $self->population <= 3
!ll&&!rl&&r
93419161
MC/DC100%2/2
$self->population >= 1 and $self->population <= 3
$self->population >= 1 $self->population <= 3
Truth table100%3/3
A and B
A= $self->population >= 1B= $self->population <= 3
ABresult
0X0
100
111
242 673 ▶ $tradecodes .= " Lt" if $self->tech >= 1 and $self->tech <= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $self->tech >= 1 and $self->tech <= 5 110 563 673
Condition100%3/3
$self->tech >= 1 and $self->tech <= 5
!ll&&!rl&&r
95468110
MC/DC100%2/2
$self->tech >= 1 and $self->tech <= 5
$self->tech >= 1 $self->tech <= 5
Truth table100%3/3
A and B
A= $self->tech >= 1B= $self->tech <= 5
ABresult
0X0
100
111
243 673 ▶ $tradecodes .= " Na" if $self->atmosphere <= 3 and $self->hydro <= 3 and $self->population >= 6;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere <= 3 and $self->hydro <= 3 and $self->population >= 6 45 628 673
Condition100%6/6
$self->atmosphere <= 3 and $self->hydro <= 3 and $self->population >= 6
!ll&&!rl&&r
51611245
$self->atmosphere <= 3 and $self->hydro <= 3
!ll&&!rl&&r
46254157
MC/DC100%3/3
$self->atmosphere <= 3 and $self->hydro <= 3 and $self->population >= 6
$self->atmosphere <= 3 $self->hydro <= 3 $self->population >= 6
Truth table100%4/4
A and B and C
A= $self->atmosphere <= 3B= $self->hydro <= 3C= $self->population >= 6
ABCresult
0XX0
10X0
1100
1111
244 673 ▶ $tradecodes .= " Ni" if $self->population >= 4 and $self->population <= 6;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 4 and $self->population <= 6 261 412 673
Condition100%3/3
$self->population >= 4 and $self->population <= 6
!ll&&!rl&&r
254158261
MC/DC100%2/2
$self->population >= 4 and $self->population <= 6
$self->population >= 4 $self->population <= 6
Truth table100%3/3
A and B
A= $self->population >= 4B= $self->population <= 6
ABresult
0X0
100
111
245 673 ▶ $tradecodes .= " Po" if $self->atmosphere >= 2 and $self->atmosphere <= 5 and $self->hydro <= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere >= 2 and $self->atmosphere <= 5 and $self->hydro <= 3 112 561 673
Condition100%6/6
$self->atmosphere >= 2 and $self->atmosphere <= 5 and $self->hydro <= 3
!ll&&!rl&&r
407154112
$self->atmosphere >= 2 and $self->atmosphere <= 5
!ll&&!rl&&r
102305266
MC/DC100%3/3
$self->atmosphere >= 2 and $self->atmosphere <= 5 and $self->hydro <= 3
$self->atmosphere >= 2 $self->atmosphere <= 5 $self->hydro <= 3
Truth table100%4/4
A and B and C
A= $self->atmosphere >= 2B= $self->atmosphere <= 5C= $self->hydro <= 3
ABCresult
0XX0
10X0
1100
1111
246 673 ▶ $tradecodes .= " Ri" if $self->population >= 6 and $self->population <= 8 and any { $_ == $self->atmosphere } qw(6 8);
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $self->population >= 6 and $self->population <= 8 and &any(sub { $_ == $self->atmosphere; } , 6, 8) 37 636 673
Condition100%6/6
$self->population >= 6 and $self->population <= 8 and &any(sub { $_ == $self->atmosphere; } , 6, 8)
!ll&&!rl&&r
49614037
$self->population >= 6 and $self->population <= 8
!ll&&!rl&&r
43858177
MC/DC100%3/3
$self->population >= 6 and $self->population <= 8 and &any(sub { $_ == $self->atmosphere; } , 6, 8)
$self->population >= 6 $self->population <= 8 &any(sub { $_ == $self->atmosphere; } , 6, 8)
Truth table100%4/4
A and B and C
A= $self->population >= 6B= $self->population <= 8C= &any(sub { $_ == $self->atmosphere; } , 6, 8)
ABCresult
0XX0
10X0
1100
1111
247 673 ▶ $tradecodes .= " Wa" if $self->hydro >= 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->hydro >= 10 34 639 673
248 673 ▶ $tradecodes .= " Va" if $self->atmosphere == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere == 0 61 612 673
249 673 return $tradecodes;
250 }
251  
252 673 ▶sub compute_travelzone {
Subroutine compute_travelzone: called CC=12 SCAR=24.8
Pod undocumented
253 673 my $self = shift;
254 673 my $danger = 0;
255 673 ▶ $danger++ if $self->atmosphere >= 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->atmosphere >= 10 70 603 673
256 673 ▶ $danger++ if $self->population and $self->government == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population and $self->government == 0 43 630 673
Condition100%3/3
$self->population and $self->government == 0
!ll&&!rl&&r
9353743
MC/DC100%2/2
$self->population and $self->government == 0
$self->population $self->government == 0
Truth table100%3/3
A and B
A= $self->populationB= $self->government == 0
ABresult
0X0
100
111
257 673 ▶ $danger++ if $self->government == 7;
Branch: 1 branch
BranchTrueFalseTotal
if $self->government == 7 70 603 673
258 673 ▶ $danger++ if $self->government == 10;
Branch: 1 branch
BranchTrueFalseTotal
if $self->government == 10 29 644 673
259 673 ▶ $danger++ if $self->population and $self->law == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->population and $self->law == 0 73 600 673
Condition100%3/3
$self->population and $self->law == 0
!ll&&!rl&&r
9350773
MC/DC100%2/2
$self->population and $self->law == 0
$self->population $self->law == 0
Truth table100%3/3
A and B
A= $self->populationB= $self->law == 0
ABresult
0X0
100
111
260 673 ▶ $danger++ if $self->law >= 9;
Branch: 1 branch
BranchTrueFalseTotal
if $self->law >= 9 126 547 673
261 673 ▶ return 'R' if $danger and $self->pirate;
Branch: 1 branch
BranchTrueFalseTotal
if $danger and $self->pirate 20 653 673
Condition100%3/3
$danger and $self->pirate
!ll&&!rl&&r
34930420
MC/DC100%2/2
$danger and $self->pirate
$danger $self->pirate
Truth table100%3/3
A and B
A= $dangerB= $self->pirate
ABresult
0X0
100
111
262 653 ▶ return 'A' if $danger;
Branch: 1 branch
BranchTrueFalseTotal
if $danger 304 349 653
263 }
264  
265 673 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
266 673 my $self = shift;
267 673 $self->x(shift);
268 673 $self->y(shift);
269 673 $self->name($self->compute_name(shift));
270 673 $self->starport($self->compute_starport);
271 673 $self->compute_bases;
272 673 $self->size($self->roll2d6()-2);
273 673 $self->atmosphere($self->compute_atmosphere);
274 673 $self->temperature($self->compute_temperature);
275 673 $self->hydro($self->compute_hydro);
276 673 $self->population($self->roll2d6()-2); # How to get to B and C in the table?
277 673 $self->government($self->compute_government);
278 673 $self->law($self->compute_law);
279 673 $self->tech($self->compute_tech);
280 673 $self->check_doom;
281 673 $self->tradecodes($self->compute_tradecodes);
282 673 $self->travelzone($self->compute_travelzone);
283 673 return $self;
284 }
285  
286 4038 ▶sub code {
Subroutine code: called CC=2 SCAR=6.9
Pod undocumented
287 4038 my $num = shift;
288 4038 ▶ return $num if $num < 10;
Branch: 1 branch
BranchTrueFalseTotal
if $num < 10 3763 275 4038
289 275 return chr(65-10+$num);
290 }
291  
292 673 ▶sub str {
Subroutine str: called CC=11 SCAR=24.0
Pod undocumented
293 673 my $self = shift;
294 673 my $uwp = sprintf("%-16s %02d%02d ", $self->name, $self->x, $self->y);
295 673 $uwp .= $self->starport;
296 673 $uwp .= code($self->size);
297 673 $uwp .= code($self->atmosphere);
298 673 $uwp .= code($self->hydro);
299 673 $uwp .= code($self->population);
300 673 $uwp .= code($self->government);
301 673 $uwp .= code($self->law);
302 673 $uwp .= '-';
303 673 $uwp .= sprintf("%-2d", $self->tech);
304 673 my $bases = '';
305 673 ▶ $bases .= 'N' if $self->naval;
Branch: 1 branch
BranchTrueFalseTotal
if $self->naval 72 601 673
306 673 ▶ $bases .= 'S' if $self->scout;
Branch: 1 branch
BranchTrueFalseTotal
if $self->scout 225 448 673
307 673 ▶ $bases .= 'R' if $self->research;
Branch: 1 branch
BranchTrueFalseTotal
if $self->research 84 589 673
308 673 ▶ $bases .= 'T' if $self->TAS;
Branch: 1 branch
BranchTrueFalseTotal
if $self->TAS 181 492 673
309 673 ▶ $bases .= 'C' if $self->consulate;
Branch: 1 branch
BranchTrueFalseTotal
if $self->consulate 130 543 673
310 673 ▶ $bases .= 'P' if $self->pirate;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pirate 46 627 673
311 673 ▶ $bases .= 'G' if $self->gasgiant;
Branch: 1 branch
BranchTrueFalseTotal
if $self->gasgiant 570 103 673
312 673 $uwp .= sprintf("%7s", $bases);
313 673 $uwp .= ' ' . $self->tradecodes;
314 673 ▶ $uwp .= ' ' . $self->travelzone if $self->travelzone;
Branch: 1 branch
BranchTrueFalseTotal
if $self->travelzone 324 349 673
315 673 ▶ if ($self->culture) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->culture) 437 236 673
316 437 my $spaces = 20 - length($self->tradecodes);
317 437 ▶ $spaces -= 1 + length($self->travelzone) if $self->travelzone;
Branch: 1 branch
BranchTrueFalseTotal
if $self->travelzone 217 220 437
318 437 $uwp .= ' ' x $spaces;
319 437 $uwp .= '[' . $self->culture . ']';
320 }
321 673 return $uwp;
322 }
323  
324 2 1;
« lib/Traveller/Hex.pm ↑ Summary script/traveller »