line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# Copyright (C) 2009-2021 Alex Schroeder |
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 . |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Traveller::System::Classic; |
18
|
2
|
|
|
2
|
|
1136
|
use List::Util qw(min max); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
133
|
|
19
|
2
|
|
|
2
|
|
11
|
use Mojo::Base 'Traveller::System'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub compute_starport { |
22
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
23
|
0
|
|
|
|
|
|
my %map = ( 2=>'A', 3=>'A', 4=>'A', 5=>'B', 6=>'B', 7=>'C', |
24
|
|
|
|
|
|
|
8=>'C', 9=>'D', 10=>'E', 11=>'E', 12=>'X' ); |
25
|
0
|
|
|
|
|
|
return $map{$self->roll2d6()}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub compute_bases { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
0
|
|
|
|
|
if ($self->starport =~ /^[AB]$/) { |
31
|
0
|
|
|
|
|
|
$self->naval($self->roll2d6() >= 8); |
32
|
|
|
|
|
|
|
} |
33
|
0
|
0
|
|
|
|
|
if ($self->starport eq 'A') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->scout($self->roll2d6() >= 10); |
35
|
|
|
|
|
|
|
} elsif ($self->starport eq 'B') { |
36
|
0
|
|
|
|
|
|
$self->scout($self->roll2d6() >= 9); |
37
|
|
|
|
|
|
|
} elsif ($self->starport eq 'C') { |
38
|
0
|
|
|
|
|
|
$self->scout($self->roll2d6() >= 8); |
39
|
|
|
|
|
|
|
} elsif ($self->starport eq 'D') { |
40
|
0
|
|
|
|
|
|
$self->scout($self->roll2d6() >= 7); |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
$self->gasgiant($self->roll2d6() < 10); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub compute_atmosphere { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
0
|
|
|
|
|
my $atmosphere = $self->size == 0 ? 0 : ($self->roll2d6() - 7 + $self->size); |
48
|
0
|
|
|
|
|
|
$atmosphere = min(max($atmosphere, 0), 15); |
49
|
0
|
|
|
|
|
|
return $atmosphere; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
0
|
0
|
|
sub compute_temperature { |
53
|
|
|
|
|
|
|
# do nothing |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub compute_hydro { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
my $hydro = $self->roll2d6() - 7 + $self->atmosphere; # erratum |
59
|
0
|
0
|
0
|
|
|
|
$hydro -= 4 |
60
|
|
|
|
|
|
|
if $self->atmosphere <= 1 |
61
|
|
|
|
|
|
|
or $self->atmosphere >= 10; |
62
|
0
|
0
|
|
|
|
|
$hydro = 0 if $self->size <= 1; |
63
|
0
|
|
|
|
|
|
$hydro = min(max($hydro, 0), 10); |
64
|
0
|
|
|
|
|
|
return $hydro; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub compute_tech { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $tech = $self->roll1d6(); |
70
|
0
|
0
|
|
|
|
|
$tech += 6 if $self->starport eq 'A'; |
71
|
0
|
0
|
|
|
|
|
$tech += 4 if $self->starport eq 'B'; |
72
|
0
|
0
|
|
|
|
|
$tech += 2 if $self->starport eq 'C'; |
73
|
0
|
0
|
|
|
|
|
$tech -= 4 if $self->starport eq 'X'; |
74
|
0
|
0
|
|
|
|
|
$tech += 2 if $self->size <= 1; |
75
|
0
|
0
|
0
|
|
|
|
$tech += 1 if $self->size >= 2 and $self->size <= 4; |
76
|
0
|
0
|
0
|
|
|
|
$tech += 1 if $self->atmosphere <= 3 or $self->atmosphere >= 10; |
77
|
0
|
0
|
|
|
|
|
$tech += 1 if $self->hydro == 9; |
78
|
0
|
0
|
|
|
|
|
$tech += 2 if $self->hydro == 10; |
79
|
0
|
0
|
0
|
|
|
|
$tech += 1 if $self->population >= 1 and $self->population <= 5; |
80
|
0
|
0
|
|
|
|
|
$tech += 2 if $self->population == 9; |
81
|
0
|
0
|
|
|
|
|
$tech += 4 if $self->population == 10; |
82
|
0
|
0
|
0
|
|
|
|
$tech += 1 if $self->government == 0 or $self->government == 5; |
83
|
0
|
0
|
|
|
|
|
$tech -= 2 if $self->government == 13; |
84
|
0
|
|
|
|
|
|
return $tech; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
0
|
0
|
|
sub check_doom { |
88
|
|
|
|
|
|
|
# do nothing |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
0
|
0
|
|
sub compute_travelzone { |
92
|
|
|
|
|
|
|
# do nothing |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub compute_tradecodes { |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
0
|
|
|
|
|
|
my $tradecodes = ''; |
98
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' Ri' if $self->atmosphere =~ /^[68]$/ |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
99
|
|
|
|
|
|
|
and $self->population >= 6 and $self->population <= 8 |
100
|
|
|
|
|
|
|
and $self->government >= 4 and $self->government <= 9; |
101
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' Po' if $self->atmosphere >= 2 and $self->atmosphere <= 5 |
|
|
|
0
|
|
|
|
|
102
|
|
|
|
|
|
|
and $self->hydro <= 3; |
103
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' Ag' if $self->atmosphere >= 4 and $self->atmosphere <= 9 |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
104
|
|
|
|
|
|
|
and $self->hydro >= 4 and $self->hydro <= 8 |
105
|
|
|
|
|
|
|
and $self->population >= 5 and $self->population <= 7; |
106
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' Na' if $self->atmosphere <= 3 and $self->hydro <= 3 |
|
|
|
0
|
|
|
|
|
107
|
|
|
|
|
|
|
and $self->population >= 6; |
108
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' In' if $self->atmosphere =~ /^[012479]$/ and $self->population >= 9; |
109
|
0
|
0
|
|
|
|
|
$tradecodes .= ' Ni' if $self->population <= 6; |
110
|
0
|
0
|
|
|
|
|
$tradecodes .= ' Wa' if $self->hydro == 10; |
111
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' De' if $self->atmosphere >= 2 and $self->hydro == 0; |
112
|
0
|
0
|
|
|
|
|
$tradecodes .= ' Va' if $self->atmosphere == 0; |
113
|
0
|
0
|
|
|
|
|
$tradecodes .= ' As' if $self->size == 0; |
114
|
0
|
0
|
0
|
|
|
|
$tradecodes .= ' Ic' if $self->atmosphere <= 1 and $self->hydro >= 1; |
115
|
0
|
|
|
|
|
|
return $tradecodes; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub code { |
119
|
0
|
|
|
0
|
0
|
|
my $num = shift; |
120
|
0
|
|
|
|
|
|
my $code = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZ'; # 'I' and 'O' are omitted |
121
|
0
|
0
|
0
|
|
|
|
return '?' if !defined $num or $num !~ /^\d{1,2}$/ or $num >= length($code); |
|
|
|
0
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return substr($code, $num, 1); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub str { |
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
127
|
0
|
|
|
|
|
|
my $uwp = sprintf('%-16s %02u%02u ', $self->name, $self->x, $self->y); |
128
|
0
|
|
|
|
|
|
$uwp .= $self->starport; |
129
|
0
|
|
|
|
|
|
$uwp .= code($self->size); |
130
|
0
|
|
|
|
|
|
$uwp .= code($self->atmosphere); |
131
|
0
|
|
|
|
|
|
$uwp .= code($self->hydro); |
132
|
0
|
|
|
|
|
|
$uwp .= code($self->population); |
133
|
0
|
|
|
|
|
|
$uwp .= code($self->government); |
134
|
0
|
|
|
|
|
|
$uwp .= code($self->law); |
135
|
0
|
|
|
|
|
|
$uwp .= '-'; |
136
|
0
|
|
|
|
|
|
$uwp .= code($self->tech); |
137
|
0
|
|
|
|
|
|
my $bases = ''; |
138
|
0
|
0
|
|
|
|
|
$bases .= 'N' if $self->naval; |
139
|
0
|
0
|
|
|
|
|
$bases .= 'S' if $self->scout; |
140
|
0
|
0
|
|
|
|
|
$bases .= 'R' if $self->research; |
141
|
0
|
0
|
|
|
|
|
$bases .= 'T' if $self->TAS; |
142
|
0
|
0
|
|
|
|
|
$bases .= 'C' if $self->consulate; |
143
|
0
|
0
|
|
|
|
|
$bases .= 'P' if $self->pirate; |
144
|
0
|
0
|
|
|
|
|
$bases .= 'G' if $self->gasgiant; |
145
|
0
|
|
|
|
|
|
$uwp .= sprintf('%7s', $bases); |
146
|
0
|
|
|
|
|
|
$uwp .= ' ' . $self->tradecodes; |
147
|
0
|
0
|
|
|
|
|
$uwp .= ' ' . $self->travelzone if $self->travelzone; |
148
|
0
|
0
|
|
|
|
|
if ($self->culture) { |
149
|
0
|
|
|
|
|
|
my $spaces = 20 - length($self->tradecodes); |
150
|
0
|
0
|
|
|
|
|
$spaces -= 1 + length($self->travelzone) if $self->travelzone; |
151
|
0
|
|
|
|
|
|
$uwp .= ' ' x $spaces; |
152
|
0
|
|
|
|
|
|
$uwp .= '[' . $self->culture . ']'; |
153
|
|
|
|
|
|
|
} |
154
|
0
|
|
|
|
|
|
return $uwp; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |