sector_maker 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/.ruby-version +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +66 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +12 -0
- data/lib/sector_maker/constants.rb +150 -0
- data/lib/sector_maker/rollable.rb +24 -0
- data/lib/sector_maker/sector.rb +56 -0
- data/lib/sector_maker/system.rb +46 -0
- data/lib/sector_maker/version.rb +5 -0
- data/lib/sector_maker/world.rb +105 -0
- data/lib/sector_maker.rb +11 -0
- data/sig/sector_maker.rbs +4 -0
- metadata +62 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4148fcde17702fad821443b7b52ec2499058af6614c483893fe22db3fa9980ea
|
|
4
|
+
data.tar.gz: 155ab65fcf80c2e70491eac3af3d96fa7cbf5fd1962dad44f941fc2707b9df06
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6fa00d08d44f0aacc979b6f6aed268b8824371b1c372cca4617f5dd5acd56fff7e032759dcb78965a1ed2fb250630bc22a86e514d0211343b16c43c71eababc4
|
|
7
|
+
data.tar.gz: 4e8fab0df6f42ffd44a4a820676829297f7aeca5b828c09c3ec416464e70b77546c9cf2cd67bd6ac374a7bf74123579b262417aa9275fdf49e7a668fc1a14bac
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
NewCops: enable
|
|
7
|
+
TargetRubyVersion: 2.6
|
|
8
|
+
|
|
9
|
+
Style/StringLiterals:
|
|
10
|
+
Enabled: true
|
|
11
|
+
EnforcedStyle: double_quotes
|
|
12
|
+
|
|
13
|
+
Style/StringLiteralsInInterpolation:
|
|
14
|
+
Enabled: true
|
|
15
|
+
EnforcedStyle: double_quotes
|
|
16
|
+
|
|
17
|
+
Layout/LineLength:
|
|
18
|
+
Max: 120
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.2
|
data/Gemfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in sector_maker.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem "rake", "~> 13.0"
|
|
9
|
+
|
|
10
|
+
gem "rspec", "~> 3.0"
|
|
11
|
+
|
|
12
|
+
gem "rubocop", "~> 1.21"
|
|
13
|
+
|
|
14
|
+
gem "markov_namegen", "~> 0.1.4"
|
|
15
|
+
|
|
16
|
+
gem "rubocop-rspec", "~> 2.12"
|
|
17
|
+
|
|
18
|
+
gem "rubocop-rake", "~> 0.6.0"
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
sector_maker (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.2)
|
|
10
|
+
diff-lcs (1.5.0)
|
|
11
|
+
json (2.6.2)
|
|
12
|
+
markov_namegen (0.1.4)
|
|
13
|
+
parallel (1.22.1)
|
|
14
|
+
parser (3.1.2.1)
|
|
15
|
+
ast (~> 2.4.1)
|
|
16
|
+
rainbow (3.1.1)
|
|
17
|
+
rake (13.0.6)
|
|
18
|
+
regexp_parser (2.5.0)
|
|
19
|
+
rexml (3.2.5)
|
|
20
|
+
rspec (3.11.0)
|
|
21
|
+
rspec-core (~> 3.11.0)
|
|
22
|
+
rspec-expectations (~> 3.11.0)
|
|
23
|
+
rspec-mocks (~> 3.11.0)
|
|
24
|
+
rspec-core (3.11.0)
|
|
25
|
+
rspec-support (~> 3.11.0)
|
|
26
|
+
rspec-expectations (3.11.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.11.0)
|
|
29
|
+
rspec-mocks (3.11.1)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.11.0)
|
|
32
|
+
rspec-support (3.11.0)
|
|
33
|
+
rubocop (1.36.0)
|
|
34
|
+
json (~> 2.3)
|
|
35
|
+
parallel (~> 1.10)
|
|
36
|
+
parser (>= 3.1.2.1)
|
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
38
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
39
|
+
rexml (>= 3.2.5, < 4.0)
|
|
40
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
|
41
|
+
ruby-progressbar (~> 1.7)
|
|
42
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
43
|
+
rubocop-ast (1.21.0)
|
|
44
|
+
parser (>= 3.1.1.0)
|
|
45
|
+
rubocop-rake (0.6.0)
|
|
46
|
+
rubocop (~> 1.0)
|
|
47
|
+
rubocop-rspec (2.12.1)
|
|
48
|
+
rubocop (~> 1.31)
|
|
49
|
+
ruby-progressbar (1.11.0)
|
|
50
|
+
unicode-display_width (2.2.0)
|
|
51
|
+
|
|
52
|
+
PLATFORMS
|
|
53
|
+
arm64-darwin-21
|
|
54
|
+
x86_64-linux
|
|
55
|
+
|
|
56
|
+
DEPENDENCIES
|
|
57
|
+
markov_namegen (~> 0.1.4)
|
|
58
|
+
rake (~> 13.0)
|
|
59
|
+
rspec (~> 3.0)
|
|
60
|
+
rubocop (~> 1.21)
|
|
61
|
+
rubocop-rake (~> 0.6.0)
|
|
62
|
+
rubocop-rspec (~> 2.12)
|
|
63
|
+
sector_maker!
|
|
64
|
+
|
|
65
|
+
BUNDLED WITH
|
|
66
|
+
2.3.21
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Jack Kellenberger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# SectorMaker
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sector_maker`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
10
|
+
|
|
11
|
+
$ bundle add sector_maker
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
14
|
+
|
|
15
|
+
$ gem install sector_maker
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
TODO: Write usage instructions here
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
24
|
+
|
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sector_maker.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
|
4
|
+
# Default constants used by SectorMaker
|
|
5
|
+
module SectorMaker
|
|
6
|
+
# Traveller 5 "Expanded Hexadecimal":
|
|
7
|
+
# values 1-33 mapped to 0-9, A-Z, excluding I and O.
|
|
8
|
+
EHEX = [*(0..9)].zip([*("0".."9")]).to_h
|
|
9
|
+
.merge([*(10..33)].zip([*("A".."Z")] - %w[I O]).to_h)
|
|
10
|
+
|
|
11
|
+
# PLACEHOLDER NAMELIST FOR NAMEGENERATOR
|
|
12
|
+
DEFAULT_NAMES = ["Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas",
|
|
13
|
+
"California", "Colorado", "Connecticut", "Delaware",
|
|
14
|
+
"District of Columbia", "Florida", "Georgia", "Guam", "Hawaii",
|
|
15
|
+
"Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
|
|
16
|
+
"Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
|
|
17
|
+
"Minnesota", "Minor Outlying Islands", "Mississippi", "Missouri",
|
|
18
|
+
"Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey",
|
|
19
|
+
"New Mexico", "New York", "North Carolina", "North Dakota",
|
|
20
|
+
"Northern Mariana Islands", "Ohio", "Oklahoma", "Oregon",
|
|
21
|
+
"Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina",
|
|
22
|
+
"South Dakota", "Tennessee", "Texas", "Virgin Islands", "Utah",
|
|
23
|
+
"Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin",
|
|
24
|
+
"Wyoming"].freeze
|
|
25
|
+
|
|
26
|
+
# SECTOR GENERATION VALUES
|
|
27
|
+
|
|
28
|
+
SUBSECTOR_LIST = %i[A B C D
|
|
29
|
+
E F G H
|
|
30
|
+
I J K L
|
|
31
|
+
M N O P].freeze
|
|
32
|
+
|
|
33
|
+
COORDINATE_RANGE = { A: { col_min: 1, row_min: 1 },
|
|
34
|
+
B: { col_min: 9, row_min: 1 },
|
|
35
|
+
C: { col_min: 17, row_min: 1 },
|
|
36
|
+
D: { col_min: 25, row_min: 1 },
|
|
37
|
+
E: { col_min: 1, row_min: 11 },
|
|
38
|
+
F: { col_min: 9, row_min: 11 },
|
|
39
|
+
G: { col_min: 17, row_min: 11 },
|
|
40
|
+
H: { col_min: 25, row_min: 11 },
|
|
41
|
+
I: { col_min: 1, row_min: 21 },
|
|
42
|
+
J: { col_min: 9, row_min: 21 },
|
|
43
|
+
K: { col_min: 17, row_min: 21 },
|
|
44
|
+
L: { col_min: 25, row_min: 21 },
|
|
45
|
+
M: { col_min: 1, row_min: 31 },
|
|
46
|
+
N: { col_min: 9, row_min: 31 },
|
|
47
|
+
O: { col_min: 17, row_min: 31 },
|
|
48
|
+
P: { col_min: 25, row_min: 31 } }.freeze
|
|
49
|
+
|
|
50
|
+
DEFAULT_SYSTEM_PRESENCE = { A: 5, B: 5, C: 5, D: 5,
|
|
51
|
+
E: 5, F: 5, G: 5, H: 5,
|
|
52
|
+
I: 5, J: 5, K: 5, L: 5,
|
|
53
|
+
M: 5, N: 5, O: 5, P: 5 }.freeze
|
|
54
|
+
|
|
55
|
+
# SYSTEM GENERATION VALUES
|
|
56
|
+
|
|
57
|
+
STARPORT_DISTRIBUTION = %w[A A A B B C C D E E X].freeze
|
|
58
|
+
|
|
59
|
+
STARPORT_TECH_MOD = { "X" => -4,
|
|
60
|
+
"C" => 2,
|
|
61
|
+
"B" => 4,
|
|
62
|
+
"A" => 6 }.freeze
|
|
63
|
+
|
|
64
|
+
NAVAL_BASE_CHANCE_BY_PORT_CLASS = { "A" => 8,
|
|
65
|
+
"B" => 8 }.freeze
|
|
66
|
+
|
|
67
|
+
SCOUT_BASE_CHANCE_BY_PORT_CLASS = { "D" => 7,
|
|
68
|
+
"C" => 8,
|
|
69
|
+
"B" => 9,
|
|
70
|
+
"A" => 10 }.freeze
|
|
71
|
+
|
|
72
|
+
SIZE_TECH_MOD = { 0 => 2,
|
|
73
|
+
1 => 2,
|
|
74
|
+
2 => 1,
|
|
75
|
+
3 => 1,
|
|
76
|
+
4 => 1 }.freeze
|
|
77
|
+
|
|
78
|
+
SIZE_DESCRIPTION = { 0 => "Asteroid or planetoid belt",
|
|
79
|
+
32 => "Stellar-scale construct" }.freeze
|
|
80
|
+
|
|
81
|
+
ATMOSPHERE_TECH_MOD = { 0 => 1,
|
|
82
|
+
1 => 1,
|
|
83
|
+
2 => 1,
|
|
84
|
+
3 => 1,
|
|
85
|
+
10 => 1,
|
|
86
|
+
11 => 1,
|
|
87
|
+
12 => 1,
|
|
88
|
+
13 => 1,
|
|
89
|
+
14 => 1,
|
|
90
|
+
15 => 1 }.freeze
|
|
91
|
+
|
|
92
|
+
ATMOSPHERE_DESCRIPTION = ["No atmosphere",
|
|
93
|
+
"Trace",
|
|
94
|
+
"Very thin, tainted",
|
|
95
|
+
"Very thin",
|
|
96
|
+
"Thin, tainted",
|
|
97
|
+
"Standard",
|
|
98
|
+
"Standard, tainted",
|
|
99
|
+
"Dense",
|
|
100
|
+
"Dense, tainted",
|
|
101
|
+
"Exotic",
|
|
102
|
+
"Corrosive",
|
|
103
|
+
"Insidious",
|
|
104
|
+
"Dense, high",
|
|
105
|
+
"Ellipsoid",
|
|
106
|
+
"Thin, low"].freeze
|
|
107
|
+
|
|
108
|
+
HYDROGRAPHICS_TECH_MOD = { 9 => 1,
|
|
109
|
+
10 => 2 }.freeze
|
|
110
|
+
|
|
111
|
+
HYDROGRAPHICS_DESCRIPTION = { 0 => "No free standing water",
|
|
112
|
+
10 => "No land masses" }.freeze
|
|
113
|
+
|
|
114
|
+
POPULATION_TECH_MOD = { 1 => 1,
|
|
115
|
+
2 => 1,
|
|
116
|
+
3 => 1,
|
|
117
|
+
4 => 1,
|
|
118
|
+
5 => 1,
|
|
119
|
+
9 => 2,
|
|
120
|
+
10 => 4,
|
|
121
|
+
11 => 4,
|
|
122
|
+
12 => 4,
|
|
123
|
+
13 => 4,
|
|
124
|
+
14 => 4,
|
|
125
|
+
15 => 4 }.freeze
|
|
126
|
+
|
|
127
|
+
POPULATION_MODIFIER_DISTRIBUTION = [1, 7, 5, 3, 1, 2, 1, 4, 6, 8, 9].freeze
|
|
128
|
+
|
|
129
|
+
GOVERNMENT_TECH_MOD = { 0 => 1,
|
|
130
|
+
5 => 1,
|
|
131
|
+
13 => -2 }.freeze
|
|
132
|
+
|
|
133
|
+
GOVERNMENT_DESCRIPTION_SHORT = ["No govenrment/structure",
|
|
134
|
+
"Company/Corporation",
|
|
135
|
+
"Participating Democracy",
|
|
136
|
+
"Self-perpetuating Oligarchy",
|
|
137
|
+
"Representative Democracy",
|
|
138
|
+
"Feudal Technocracy",
|
|
139
|
+
"Captive Government",
|
|
140
|
+
"Balkanization",
|
|
141
|
+
"Civil Service Bureaucracy",
|
|
142
|
+
"Impersonal Bureaucracy",
|
|
143
|
+
"Charismatic Dictator",
|
|
144
|
+
"Non-charismatic Leader",
|
|
145
|
+
"Charismatic Oligarchy",
|
|
146
|
+
"Religious Dictatorship",
|
|
147
|
+
"Religious Autocracy",
|
|
148
|
+
"Totalitarian Oligarchy"].freeze
|
|
149
|
+
end
|
|
150
|
+
# rubocop:enable Metrics/ModuleLength
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SectorMaker
|
|
4
|
+
# Dice rolling methods
|
|
5
|
+
module Rollable
|
|
6
|
+
def roll(dice_quantity = 1)
|
|
7
|
+
Array.new(dice_quantity) { rand(1..6) }.sum
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
|
11
|
+
def flux
|
|
12
|
+
roll - roll
|
|
13
|
+
end
|
|
14
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
|
15
|
+
|
|
16
|
+
def roll_over?(target = 8)
|
|
17
|
+
roll(2) >= target
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def roll_under?(target = 8)
|
|
21
|
+
roll(2) <= target
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SectorMaker
|
|
4
|
+
# A Traveller5 sector
|
|
5
|
+
class Sector
|
|
6
|
+
include Rollable
|
|
7
|
+
def initialize(system_chance = DEFAULT_SYSTEM_PRESENCE)
|
|
8
|
+
@namegen = MarkovNameGen.new(DEFAULT_NAMES)
|
|
9
|
+
@sector_name = "New Sector"
|
|
10
|
+
@system_chances = system_chance
|
|
11
|
+
@systems = []
|
|
12
|
+
@hexes = {}
|
|
13
|
+
generate_sector
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
"#{@sector_name.upcase} \n #{"-" * @sector_name.length}\n" \
|
|
18
|
+
"#{@systems.compact.map(&:to_s).join("\n")}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_txt(filename = @sector_name)
|
|
22
|
+
File.write("#{filename}.txt", to_s)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def generate_sector
|
|
26
|
+
SUBSECTOR_LIST.each do |letter|
|
|
27
|
+
generate_subsector(letter)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def generate_subsector(letter = A)
|
|
32
|
+
col_min = COORDINATE_RANGE[letter][:col_min]
|
|
33
|
+
row_min = COORDINATE_RANGE[letter][:row_min]
|
|
34
|
+
col_min.upto(col_min + 7) do |col|
|
|
35
|
+
row_min.upto(row_min + 9) do |row|
|
|
36
|
+
hex = [col, row]
|
|
37
|
+
world = check_system_presence(hex, letter)
|
|
38
|
+
@hexes[hex] = world
|
|
39
|
+
@systems.push(world)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def format_hex(coordinate)
|
|
45
|
+
coordinate.map { |pair| pair.to_s.rjust(2, "0") }.join
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def check_system_presence(hex, letter = A)
|
|
49
|
+
return unless roll(1) >= @system_chances[letter]
|
|
50
|
+
|
|
51
|
+
System.new(sector_name: @sector_name,
|
|
52
|
+
mainworld_name: @namegen.new_name,
|
|
53
|
+
hex: format_hex(hex))
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SectorMaker
|
|
4
|
+
# A Traveller5 star system
|
|
5
|
+
class System
|
|
6
|
+
include Rollable
|
|
7
|
+
attr_reader :name, :hex, :uwp, :bases, :trade_codes, :travel_code, :pbg,
|
|
8
|
+
:allegiance
|
|
9
|
+
|
|
10
|
+
def initialize(sector_name: "----", mainworld_name: "blank", hex: "0101",
|
|
11
|
+
uwp: World.new(main: true), pbg: random_pbg)
|
|
12
|
+
@name = { sector: sector_name,
|
|
13
|
+
main_world: mainworld_name }
|
|
14
|
+
@hex = hex
|
|
15
|
+
@uwp = uwp
|
|
16
|
+
@pbg = pbg
|
|
17
|
+
@trade_codes = "Ag Ni"
|
|
18
|
+
@bases = "N"
|
|
19
|
+
@allegiance = "Nebay"
|
|
20
|
+
@travel_code = [" ", "A", "R"].sample
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_s
|
|
24
|
+
"#{name[:main_world].ljust(17)} #{hex} #{uwp} #{bases} " \
|
|
25
|
+
"#{trade_codes.ljust(19)} #{travel_code} #{pbg} #{allegiance[0..1]}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def random_pbg
|
|
29
|
+
[random_population_modifier,
|
|
30
|
+
random_number_of_planetoid_belts,
|
|
31
|
+
random_number_of_gas_giants].map(&:to_s).join
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def random_population_modifier
|
|
35
|
+
POPULATION_MODIFIER_DISTRIBUTION[roll(2) - 2]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def random_number_of_planetoid_belts
|
|
39
|
+
[roll - 3, 0].max
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def random_number_of_gas_giants
|
|
43
|
+
[(roll(2) / 2) - 2, 0].max
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SectorMaker
|
|
4
|
+
# Represents Traveller5 worlds
|
|
5
|
+
class World
|
|
6
|
+
include Rollable
|
|
7
|
+
attr_reader :starport, :size, :atmosphere, :hydrographics,
|
|
8
|
+
:population, :government, :law_level, :tech_level
|
|
9
|
+
|
|
10
|
+
def initialize(_)
|
|
11
|
+
@starport = random_starport
|
|
12
|
+
@size = random_size
|
|
13
|
+
@atmosphere = random_atmosphere
|
|
14
|
+
@hydrographics = random_hydrographics
|
|
15
|
+
@population = random_population
|
|
16
|
+
@government = random_government
|
|
17
|
+
@law_level = random_law_level
|
|
18
|
+
@tech_level = random_tech_level
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_s
|
|
22
|
+
starport + attributes_to_ehex
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def attributes_to_ehex
|
|
26
|
+
[@size,
|
|
27
|
+
@atmosphere,
|
|
28
|
+
@hydrographics,
|
|
29
|
+
@population,
|
|
30
|
+
@government,
|
|
31
|
+
@law_level,
|
|
32
|
+
@tech_level].map { |value| EHEX[value] }.join.insert(6, "-")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def adjust_to_range(number, min_value: 0, max_value: 10)
|
|
36
|
+
[[number, min_value].max, max_value].min
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def random_starport
|
|
40
|
+
STARPORT_DISTRIBUTION[roll(2) - 2]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def random_size
|
|
44
|
+
result = roll(2) - 2
|
|
45
|
+
|
|
46
|
+
if result == 10
|
|
47
|
+
9 + roll
|
|
48
|
+
else
|
|
49
|
+
result
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def random_atmosphere
|
|
54
|
+
return 0 if @size < 2
|
|
55
|
+
|
|
56
|
+
result = flux + @size
|
|
57
|
+
|
|
58
|
+
adjust_to_range(result, max_value: 15)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def atmosphere_mod
|
|
62
|
+
return @atmosphere unless @atmosphere < 2 || @atmosphere > 9
|
|
63
|
+
|
|
64
|
+
@atmosphere - 4
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def random_hydrographics
|
|
68
|
+
return 0 if @size < 2
|
|
69
|
+
|
|
70
|
+
adjust_to_range(flux + atmosphere_mod)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def random_population
|
|
74
|
+
result = roll(2) - 2
|
|
75
|
+
|
|
76
|
+
if result == 10
|
|
77
|
+
roll(2) + 3
|
|
78
|
+
else
|
|
79
|
+
result
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def random_government
|
|
84
|
+
return 0 if @population.zero?
|
|
85
|
+
|
|
86
|
+
adjust_to_range(flux + @population, max_value: 15)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def random_law_level
|
|
90
|
+
adjust_to_range(flux + @government, max_value: 18)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def random_tech_level
|
|
94
|
+
calculation = [roll,
|
|
95
|
+
STARPORT_TECH_MOD.fetch(@starport, 0),
|
|
96
|
+
SIZE_TECH_MOD.fetch(@size, 0),
|
|
97
|
+
ATMOSPHERE_TECH_MOD.fetch(@atmosphere, 0),
|
|
98
|
+
HYDROGRAPHICS_TECH_MOD.fetch(@hydrographics, 0),
|
|
99
|
+
POPULATION_TECH_MOD.fetch(@population, 0),
|
|
100
|
+
GOVERNMENT_TECH_MOD.fetch(@government, 0)].sum
|
|
101
|
+
|
|
102
|
+
adjust_to_range(calculation, max_value: 33)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
data/lib/sector_maker.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SectorMaker
|
|
4
|
+
require "markov_namegen"
|
|
5
|
+
require "sector_maker/constants"
|
|
6
|
+
require "sector_maker/rollable"
|
|
7
|
+
require "sector_maker/world"
|
|
8
|
+
require "sector_maker/system"
|
|
9
|
+
require "sector_maker/sector"
|
|
10
|
+
require "sector_maker/version"
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sector_maker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jack Kellenberger
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-09-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- jackson@kellenberger.io
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".rspec"
|
|
21
|
+
- ".rubocop.yml"
|
|
22
|
+
- ".ruby-version"
|
|
23
|
+
- Gemfile
|
|
24
|
+
- Gemfile.lock
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- lib/sector_maker.rb
|
|
29
|
+
- lib/sector_maker/constants.rb
|
|
30
|
+
- lib/sector_maker/rollable.rb
|
|
31
|
+
- lib/sector_maker/sector.rb
|
|
32
|
+
- lib/sector_maker/system.rb
|
|
33
|
+
- lib/sector_maker/version.rb
|
|
34
|
+
- lib/sector_maker/world.rb
|
|
35
|
+
- sig/sector_maker.rbs
|
|
36
|
+
homepage: https://github.com/jmkellenberger
|
|
37
|
+
licenses:
|
|
38
|
+
- MIT
|
|
39
|
+
metadata:
|
|
40
|
+
homepage_uri: https://github.com/jmkellenberger
|
|
41
|
+
source_code_uri: https://github.com/jmkellenberger
|
|
42
|
+
rubygems_mfa_required: 'true'
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: 2.6.0
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubygems_version: 3.3.7
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 4
|
|
61
|
+
summary: A Traveller Sector generator inspired by Traveller5.
|
|
62
|
+
test_files: []
|