elite_universe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a36098d3714f0989351399192412e66461c346b
4
- data.tar.gz: 49403e254030ca2d188b6b28b1d4de962347f4b1
3
+ metadata.gz: aeae0817d0eb3a393d6eb176b80274f27a50d2fc
4
+ data.tar.gz: 96764c38588ae0bf2107ac5b893b3547aad2ba20
5
5
  SHA512:
6
- metadata.gz: 6d248e1f21f0c6f454c262336d02422afbe3dfe1d251e47570d58b7038a2f636cab6d62d1fcac1f17b55b91fdf9a2624969fd63adb2b29a1ee28b0527914829d
7
- data.tar.gz: 31587a0a59e301c7b2f682e88da0cf8ff0db0fdc79f879f9f4798339315cb82dd4c430613c669c70adf0100693892271c4f2969bfa5fc5f05a606c579ab252b0
6
+ metadata.gz: 34eed350615fc8132c8c797d00377691b06d576eb9ac391f3682459aed6fe35697efb850b122f3c4acb6a1aa13d5056322a7360ab7128a6d59eabbe20af1106f
7
+ data.tar.gz: 003911f126b120009fc4b2ed6e923a394a3f95f4f3decbf87b59697639bd66423938e05775c9d0ab1a51f36e8fccbfe66b76a7a6e337097fd2700d436ad22747
data/README.md CHANGED
@@ -31,4 +31,4 @@ Take a look at the LICENSE file in the code.
31
31
  The Elite planet generation algorithm is copyright (c) 1984 of David Braben and
32
32
  Ian Bell.
33
33
 
34
- This ruby implementation is copyright (c) 2015 BBC
34
+ This ruby implementation is copyright (c) 2015 Joe Haig
@@ -53,6 +53,12 @@ module EliteUniverse
53
53
  [ @w[1] >> 8, @w[0] >> 8 ]
54
54
  end
55
55
 
56
+ def technology
57
+ t = ((@w[1] >> 8 ) & 3) + ( econ_n ^ 7 ) + (gov_n >> 1) + 1
58
+ t += 1 if ((gov_n & 1) == 1)
59
+ t
60
+ end
61
+
56
62
  def next
57
63
  EliteUniverse::Planet.new *(twist twist twist twist @w)
58
64
  end
@@ -0,0 +1,178 @@
1
+ module EliteUniverse
2
+ class Planet
3
+ CHARS = '..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion'.scan(/../)
4
+ CHARS2 = 'abouseitiletstonlonothno'.scan(/../) + CHARS
5
+
6
+ GOVS = [
7
+ 'Anarchy',
8
+ 'Feudal',
9
+ 'Multi-Government',
10
+ 'Dictatorship',
11
+ 'Communist',
12
+ 'Confederate',
13
+ 'Democratic',
14
+ 'Corporate',
15
+ ]
16
+
17
+ ECONS = [
18
+ 'Rich Industrial',
19
+ 'Average Industrial',
20
+ 'Poor Industrial',
21
+ 'Mainly Industrial',
22
+ 'Mainly Agricultural',
23
+ 'Rich Agricultural',
24
+ 'Average Agricultural',
25
+ 'Poor Agricultural',
26
+ ]
27
+ DESC_LIST = [
28
+ ["fabled", "notable", "well known", "famous", "noted"],
29
+ ["very", "mildly", "most", "reasonably", ""],
30
+ ["ancient", "\x95", "great", "vast", "pink"],
31
+ ["\x9E \x9D plantations", "mountains", "\x9C", "\x94 forests", "oceans"],
32
+ ["shyness", "silliness", "mating traditions", "loathing of \x86", "love for \x86"],
33
+ ["food blenders", "tourists", "poetry", "discos", "\x8E"],
34
+ ["talking tree", "crab", "bat", "lobst", "\xB2"],
35
+ ["beset", "plagued", "ravaged", "cursed", "scourged"],
36
+ ["\x96 civil war", "\x9B \x98 \x99s", "a \x9B disease", "\x96 earthquakes", "\x96 solar activity"],
37
+ ["its \x83 \x84", "the \xB1 \x98 \x99","its inhabitants' \x9A \x85", "\xA1", "its \x8D \x8E"],
38
+ ["juice", "brandy", "water", "brew", "gargle blasters"],
39
+ ["\xB2", "\xB1 \x99", "\xB1 \xB2", "\xB1 \x9B", "\x9B \xB2"],
40
+ ["fabulous", "exotic", "hoopy", "unusual", "exciting"],
41
+ ["cuisine", "night life", "casinos", "sit coms", " \xA1 "],
42
+ ["\xB0", "The planet \xB0", "The world \xB0", "This planet", "This world"],
43
+ ["n unremarkable", " boring", " dull", " tedious", " revolting"],
44
+ ["planet", "world", "place", "little planet", "dump"],
45
+ ["wasp", "moth", "grub", "ant", "\xB2"],
46
+ ["poet", "arts graduate", "yak", "snail", "slug"],
47
+ ["tropical", "dense", "rain", "impenetrable", "exuberant"],
48
+ ["funny", "wierd", "unusual", "strange", "peculiar"],
49
+ ["frequent", "occasional", "unpredictable", "dreadful", "deadly"],
50
+ ["\x82 \x81 for \x8A", "\x82 \x81 for \x8A and \x8A", "\x88 by \x89", "\x82 \x81 for \x8A but \x88 by \x89","a\x90 \x91"],
51
+ ["\x9B", "mountain", "edible", "tree", "spotted"],
52
+ ["\x9F", "\xA0", "\x87oid", "\x93", "\x92"],
53
+ ["ancient", "exceptional", "eccentric", "ingrained", "\x95"],
54
+ ["killer", "deadly", "evil", "lethal", "vicious"],
55
+ ["parking meters", "dust clouds", "ice bergs", "rock formations", "volcanoes"],
56
+ ["plant", "tulip", "banana", "corn", "\xB2weed"],
57
+ ["\xB2", "\xB1 \xB2", "\xB1 \x9B", "inhabitant", "\xB1 \xB2"],
58
+ ["shrew", "beast", "bison", "snake", "wolf"],
59
+ ["leopard", "cat", "monkey", "goat", "fish"],
60
+ ["\x8C \x8B", "\xB1 \x9F \xA2","its \x8D \xA0 \xA2", "\xA3 \xA4", "\x8C \x8B"],
61
+ ["meat", "cutlet", "steak", "burgers", "soup"],
62
+ ["ice", "mud", "Zero-G", "vacuum", "\xB1 ultra"],
63
+ ["hockey", "cricket", "karate", "polo", "tennis"]
64
+ ]
65
+
66
+ def initialize a, b, c
67
+ @w = [ a, b, c ]
68
+ end
69
+
70
+ def name
71
+ name = ''
72
+ v = @w
73
+ l = v[0] & 64
74
+ 4.times do |i|
75
+ if i < 3 or l > 0
76
+ n = ( v[2] >> 8 ) & 31
77
+ name += CHARS[n]
78
+ end
79
+ v = twist v
80
+ end
81
+ name.gsub('.', '').capitalize
82
+ end
83
+
84
+ def government
85
+ GOVS[ gov_n ]
86
+ end
87
+
88
+ def economy
89
+ ECONS[ econ_n ]
90
+ end
91
+
92
+ def location
93
+ [ @w[1] >> 8, @w[0] >> 8 ]
94
+ end
95
+
96
+ def description
97
+ @gs = [
98
+ @w[1] & 0xFF,
99
+ @w[1] >> 8,
100
+ @w[2] & 0xFF,
101
+ @w[2] >> 8
102
+ ]
103
+ goatsoup("\x8F is \x97.")
104
+ end
105
+
106
+ def next
107
+ EliteUniverse::Planet.new *(twist twist twist twist @w)
108
+ end
109
+
110
+ private
111
+ def twist arr
112
+ [ arr[1], arr[2], arr.inject(:+) % 65536 ]
113
+ end
114
+
115
+ def gov_n
116
+ ( @w[1] >> 3 ) & 7
117
+ end
118
+
119
+ def econ_n
120
+ e = ( @w[0] >> 8 ) & 7
121
+ gov_n <= 1 ? e | 2 : e
122
+ end
123
+
124
+ def goatsoup(source)
125
+ result = ''
126
+ source.force_encoding('ISO-8859-1').split(//).each do |c|
127
+ o = c.ord
128
+ if o < 128
129
+ result += c
130
+ else
131
+ if o <= 164
132
+ rnd = gen_rnd_number
133
+ pos = 0
134
+ pos += 1 if rnd >= 51
135
+ pos += 1 if rnd >= 102
136
+ pos += 1 if rnd >= 153
137
+ pos += 1 if rnd >= 204
138
+ result += goatsoup(DESC_LIST[o-129][pos])
139
+ else
140
+ case o
141
+ when 176
142
+ result += self.name
143
+ when 177
144
+ nm = self.name
145
+ result += "#{(['i', 'e'].include?(nm[-1]) ? nm.chop : nm)}ian"
146
+ when 178
147
+ l = gen_rnd_number & 3
148
+ new_name = ''
149
+ (0..l).each do |i|
150
+ x = gen_rnd_number & 0x3E
151
+ new_name += CHARS2[x/2]
152
+ end
153
+ result += new_name.capitalize
154
+ else
155
+ result += "[BOOM - #{o}]"
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ result
162
+ end
163
+
164
+ def gen_rnd_number
165
+ x = (@gs[0] * 2 ) & 0xFF
166
+ a = x + @gs[2]
167
+ a += 1 if @gs[0] > 127
168
+ @gs[0] = a & 0xFF
169
+ @gs[2] = x
170
+ a = a / 256
171
+ x = @gs[1]
172
+ a = ( a + x + @gs[3]) & 0xFF
173
+ @gs[1] = a
174
+ @gs[3] = x
175
+ a
176
+ end
177
+ end
178
+ end
@@ -1,3 +1,3 @@
1
1
  module EliteUniverse
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elite_universe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Haig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -35,6 +35,7 @@ files:
35
35
  - README.md
36
36
  - lib/elite_universe/galaxy.rb
37
37
  - lib/elite_universe/planet.rb
38
+ - lib/elite_universe/planet_working.rb
38
39
  - lib/elite_universe/version.rb
39
40
  homepage: https://github.com/jrmhaig/elite_universe
40
41
  licenses:
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
57
  version: '0'
57
58
  requirements: []
58
59
  rubyforge_project:
59
- rubygems_version: 2.4.8
60
+ rubygems_version: 2.5.0
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  summary: Elite Universe