greyhawkweather 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/History.txt +5 -0
- data/Manifest.txt +16 -14
- data/Rakefile +10 -22
- data/bin/greyweathergen +6 -2
- data/greyhawkweather.gemspec +33 -0
- data/lib/baselinedata.rb +1 -3
- data/lib/greyhawkweather.rb +2 -3
- data/lib/greyhawkweather/version.rb +4 -0
- data/lib/greyhawkweathergenerator.rb +4 -6
- data/lib/options.rb +15 -0
- data/lib/precipitationoccurance.rb +8 -4
- data/lib/singledayweather.rb +11 -3
- data/lib/skyconditions.rb +1 -1
- data/lib/temperaturerange.rb +10 -2
- data/lib/util/dieroller.rb +3 -3
- data/lib/weathergenerator.rb +15 -9
- data/lib/wind.rb +3 -1
- data/spec/acceptance_spec.rb +52 -0
- data/spec/dieroller_spec.rb +22 -0
- data/spec/latitude_spec.rb +25 -0
- data/spec/month_spec.rb +34 -0
- data/spec/options_spec.rb +25 -0
- data/spec/precipation_spec.rb +23 -0
- data/spec/precipitation_occurance_spec.rb +114 -0
- data/spec/singledayweather_spec.rb +44 -0
- data/spec/sky_conditions_spec.rb +20 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/temperature_range_spec.rb +27 -0
- data/spec/weathergenerator_spec.rb +63 -0
- data/spec/wind_spec.rb +8 -0
- data/todo.org +3 -2
- metadata +67 -80
- data.tar.gz.sig +0 -1
- data/.gemtest +0 -0
- data/test/rollers/avgroller.rb +0 -7
- data/test/rollers/riggedroller.rb +0 -11
- data/test/test_acceptance.rb +0 -36
- data/test/test_dieroller.rb +0 -30
- data/test/test_greyhawkweather.rb +0 -11
- data/test/test_helper.rb +0 -3
- data/test/test_month.rb +0 -36
- data/test/test_precipitation.rb +0 -26
- data/test/test_precipitation_occurance.rb +0 -93
- data/test/test_singledayweather.rb +0 -61
- data/test/test_sky_conditions.rb +0 -23
- data/test/test_temperature_range.rb +0 -30
- data/test/test_weather_generator.rb +0 -59
- data/test/test_wind.rb +0 -11
- metadata.gz.sig +0 -1
data/todo.org
CHANGED
@@ -28,9 +28,9 @@ Minimum features needed to let me use the tool in my own game
|
|
28
28
|
** DONE clean up after gem-ify work, and removal of rangehash
|
29
29
|
** DONE rearrange code a bit (helper classes in subdirectories etc.)
|
30
30
|
* Release #1.5
|
31
|
-
**
|
31
|
+
** DONE Switch to rspec
|
32
32
|
* Release #2
|
33
|
-
** need to calc diff in base temp caused by latitude
|
33
|
+
** TODO need to calc diff in base temp caused by latitude
|
34
34
|
** modify weather given terrain
|
35
35
|
** duration of record high/low
|
36
36
|
** determine windspeed from precipitation
|
@@ -38,6 +38,7 @@ Minimum features needed to let me use the tool in my own game
|
|
38
38
|
** report affects of precip (duration etc.)
|
39
39
|
** greyhawk calendar festivals
|
40
40
|
|
41
|
+
* rearrange code to go into greyhawkweather directory
|
41
42
|
* humidity
|
42
43
|
* report wind chill temp
|
43
44
|
* report high wind effect table
|
metadata
CHANGED
@@ -1,42 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greyhawkweather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mark Simpson
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
|
-
cert_chain:
|
17
|
-
- |
|
18
|
-
-----BEGIN CERTIFICATE-----
|
19
|
-
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDAp2ZXJk
|
20
|
-
YW1tZWx0MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
21
|
-
b20wHhcNMTAxMjI5MjAxNjI3WhcNMTExMjI5MjAxNjI3WjBBMRMwEQYDVQQDDAp2
|
22
|
-
ZXJkYW1tZWx0MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
23
|
-
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQQsRTtwd0rN0X
|
24
|
-
ffw6plu3tUBiGXpRGWOlIZq6xjyAjjvmwMWnmwU5juNBlPJZzYiMmCIC821s3fgb
|
25
|
-
TM69f/cgqeevyI/h4Soxl2Le8NVGSeyvaZSNM8s1n9EQ5kN7VogYD0DbB4kHlfCM
|
26
|
-
JgD72juXiAKXnsXH8NvcBXCkoPiq7CjDJCmrqilTu1atELmP5RJ/Vm+Nt2odVDF5
|
27
|
-
t2x2ANmLVOZn59BTvHNXYbwrCIs82W4SwOSF4wL/I5ElH7dzr8PZN1yNBZPHtxpe
|
28
|
-
+4eTt6c4+DSP+rCOjLxBQxGPemY54zVawVtg4LjE/oOaAri99hz1Nl+PLgXg+oEP
|
29
|
-
veV2pcnDAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
30
|
-
BBTJ6wHlTv0Ievjg5o1zGil1w639SjANBgkqhkiG9w0BAQUFAAOCAQEAfXKfM9vA
|
31
|
-
u1ukuGjhd4mej3Daw8bnaX2URwy5/4ogP5+9rK+WTni5UpS09ksvN/I/PWnfwNWE
|
32
|
-
kzV0tl0DvQMpz+obpw02pt1uEzAHyPOYDGrgRweVaJbvrH2G3xAkSBwfkaDlzSrk
|
33
|
-
KomP5Nct1Nnkmg0mAAGjvS/ib3GbEANt8qSP6hfn6vEXMUnhnCmo69dbdqDwVDOJ
|
34
|
-
FVV9Kd1o7T8NmmDdn+G26uPPAX5EeJtyB1rV6pSPkQW99opIKcz6iEPNkAtVniwM
|
35
|
-
AM5LT+EO74YD568fpYjJUw+T4/TsPJBWyU/f21QoaRXI+x3VNSEqDZEf67Lsp2Ew
|
36
|
-
rPnJW2hNpPLFrA==
|
37
|
-
-----END CERTIFICATE-----
|
16
|
+
cert_chain: []
|
38
17
|
|
39
|
-
date: 2011-
|
18
|
+
date: 2011-08-14 00:00:00 -04:00
|
40
19
|
default_executable:
|
41
20
|
dependencies:
|
42
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,49 +26,56 @@ dependencies:
|
|
47
26
|
requirements:
|
48
27
|
- - ">="
|
49
28
|
- !ruby/object:Gem::Version
|
50
|
-
hash:
|
29
|
+
hash: 21
|
51
30
|
segments:
|
52
31
|
- 0
|
53
32
|
- 0
|
54
|
-
-
|
55
|
-
version: 0.0.
|
33
|
+
- 5
|
34
|
+
version: 0.0.5
|
56
35
|
type: :runtime
|
57
36
|
version_requirements: *id001
|
58
37
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
38
|
+
name: rspec
|
60
39
|
prerelease: false
|
61
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
62
41
|
none: false
|
63
42
|
requirements:
|
64
43
|
- - ">="
|
65
44
|
- !ruby/object:Gem::Version
|
66
|
-
hash:
|
45
|
+
hash: 3
|
67
46
|
segments:
|
68
|
-
-
|
69
|
-
|
70
|
-
- 4
|
71
|
-
version: 2.9.4
|
47
|
+
- 0
|
48
|
+
version: "0"
|
72
49
|
type: :development
|
73
50
|
version_requirements: *id002
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rcov
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
description: " Using this gem one can generate randomized weather based upon the \n rules found in the 1983 boxed set.\n\n Currently not all features of those rules are applied.\n\n Future plans include the ability to choose different months and \n weather chances instead of only those from Greyhawk.\n"
|
81
66
|
email:
|
82
67
|
- verdammelt@gmail.com
|
83
68
|
executables:
|
84
69
|
- greyweathergen
|
85
70
|
extensions: []
|
86
71
|
|
87
|
-
extra_rdoc_files:
|
88
|
-
|
89
|
-
- Manifest.txt
|
90
|
-
- PostInstall.txt
|
91
|
-
- README.rdoc
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
92
74
|
files:
|
75
|
+
- .gitignore
|
76
|
+
- .rspec
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
93
79
|
- History.txt
|
94
80
|
- Manifest.txt
|
95
81
|
- PostInstall.txt
|
@@ -98,10 +84,13 @@ files:
|
|
98
84
|
- bin/greyweathergen
|
99
85
|
- data/baselinedata.yml
|
100
86
|
- data/precipitationoccurance.yml
|
87
|
+
- greyhawkweather.gemspec
|
101
88
|
- lib/baselinedata.rb
|
102
89
|
- lib/greyhawkweather.rb
|
90
|
+
- lib/greyhawkweather/version.rb
|
103
91
|
- lib/greyhawkweathergenerator.rb
|
104
92
|
- lib/month.rb
|
93
|
+
- lib/options.rb
|
105
94
|
- lib/precipitation.rb
|
106
95
|
- lib/precipitationinfo.rb
|
107
96
|
- lib/precipitationoccurance.rb
|
@@ -114,30 +103,27 @@ files:
|
|
114
103
|
- script/console
|
115
104
|
- script/destroy
|
116
105
|
- script/generate
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
- test/test_wind.rb
|
106
|
+
- spec/acceptance_spec.rb
|
107
|
+
- spec/dieroller_spec.rb
|
108
|
+
- spec/latitude_spec.rb
|
109
|
+
- spec/month_spec.rb
|
110
|
+
- spec/options_spec.rb
|
111
|
+
- spec/precipation_spec.rb
|
112
|
+
- spec/precipitation_occurance_spec.rb
|
113
|
+
- spec/singledayweather_spec.rb
|
114
|
+
- spec/sky_conditions_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/temperature_range_spec.rb
|
117
|
+
- spec/weathergenerator_spec.rb
|
118
|
+
- spec/wind_spec.rb
|
131
119
|
- todo.org
|
132
|
-
- .gemtest
|
133
120
|
has_rdoc: true
|
134
|
-
homepage:
|
121
|
+
homepage: ""
|
135
122
|
licenses: []
|
136
123
|
|
137
|
-
post_install_message:
|
138
|
-
rdoc_options:
|
139
|
-
|
140
|
-
- README.rdoc
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
|
141
127
|
require_paths:
|
142
128
|
- lib
|
143
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -164,17 +150,18 @@ rubyforge_project: greyhawkweather
|
|
164
150
|
rubygems_version: 1.5.0
|
165
151
|
signing_key:
|
166
152
|
specification_version: 3
|
167
|
-
summary:
|
153
|
+
summary: Generates randomized weather based upon the 1983 Greyhawk boxed set.
|
168
154
|
test_files:
|
169
|
-
-
|
170
|
-
-
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
176
|
-
-
|
177
|
-
-
|
178
|
-
-
|
179
|
-
-
|
180
|
-
-
|
155
|
+
- spec/acceptance_spec.rb
|
156
|
+
- spec/dieroller_spec.rb
|
157
|
+
- spec/latitude_spec.rb
|
158
|
+
- spec/month_spec.rb
|
159
|
+
- spec/options_spec.rb
|
160
|
+
- spec/precipation_spec.rb
|
161
|
+
- spec/precipitation_occurance_spec.rb
|
162
|
+
- spec/singledayweather_spec.rb
|
163
|
+
- spec/sky_conditions_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/temperature_range_spec.rb
|
166
|
+
- spec/weathergenerator_spec.rb
|
167
|
+
- spec/wind_spec.rb
|
data.tar.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
WMA�U������P�rɕ��c�����*��e�x����8����`�+�U����YFnf�43uٜYl��ڒƠ�c��˞�λ�/�fب����;_��NU��V������ةQ�蔹J��e�YPf��hL���dFU�-��FPL�F�ߝj�
|
data/.gemtest
DELETED
File without changes
|
data/test/rollers/avgroller.rb
DELETED
data/test/test_acceptance.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'rollers/avgroller'
|
4
|
-
require 'rollers/riggedroller'
|
5
|
-
|
6
|
-
require 'greyhawkweathergenerator'
|
7
|
-
|
8
|
-
class TestAcceptanceTests < Test::Unit::TestCase
|
9
|
-
def test_generate_weather_for_three_days_in_planting
|
10
|
-
weather_generator = GreyhawkWeatherGenerator.create_weather_generator(4, 3, AvgRoller.new)
|
11
|
-
assert_equal(3, weather_generator.days.length, "should have generated 3 days")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_generate_weather_for_planting
|
15
|
-
weather_generator = GreyhawkWeatherGenerator.create_weather_generator(4, 1, AvgRoller.new)
|
16
|
-
weather = weather_generator.days[0]
|
17
|
-
assert_equal(44..63, weather.temperature_range)
|
18
|
-
assert_equal(:partly_cloudy, weather.sky_conditions)
|
19
|
-
assert_equal(NullPrecipitationInfo.new().name, weather.precipitation[0].name)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_generate_weather_for_goodmonth
|
23
|
-
weather_generator = GreyhawkWeatherGenerator.create_weather_generator(8, 1, AvgRoller.new)
|
24
|
-
weather = weather_generator.days[0]
|
25
|
-
assert_equal(66..83, weather.temperature_range)
|
26
|
-
assert_equal(:partly_cloudy, weather.sky_conditions)
|
27
|
-
assert_equal(NullPrecipitationInfo.new().name, weather.precipitation[0].name)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_generate_weather_with_terrain
|
31
|
-
weather_generator = GreyhawkWeatherGenerator.create_weather_generator(1, 1, RiggedRoller.new(30), :desert)
|
32
|
-
weather = weather_generator.days[0]
|
33
|
-
# without terrain the above would generate "Fog, Heavy" for precipitation
|
34
|
-
assert_equal(NullPrecipitationInfo.new().name, weather.precipitation[0].name)
|
35
|
-
end
|
36
|
-
end
|
data/test/test_dieroller.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'util/dieroller'
|
4
|
-
|
5
|
-
$next_defined_random_number = 0
|
6
|
-
$max_arg_to_rand = -1
|
7
|
-
|
8
|
-
def rand (max=0)
|
9
|
-
$max_arg_to_rand = max
|
10
|
-
$next_defined_random_number
|
11
|
-
end
|
12
|
-
|
13
|
-
class TestDieRoller < Test::Unit::TestCase
|
14
|
-
def test_D6
|
15
|
-
$next_defined_random_number = 3
|
16
|
-
assert_equal(4, DieRoller.new.roll(6), "should return random number (+1)")
|
17
|
-
assert_equal(6, $max_arg_to_rand, "should have defined 6 as maximum number to rand")
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_is_1_to_N_range
|
21
|
-
$next_defined_random_number = 0
|
22
|
-
assert_equal(1, DieRoller.new.roll(6), "should use 1..N range")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_applies_modifier_if_given
|
26
|
-
$next_defined_random_number = 1
|
27
|
-
assert_equal(4, DieRoller.new.roll(6, +2), "Should have added the +2")
|
28
|
-
assert_equal(-1, DieRoller.new.roll(6, -3), "Should have added the -3")
|
29
|
-
end
|
30
|
-
end
|
data/test/test_helper.rb
DELETED
data/test/test_month.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'rollers/riggedroller'
|
4
|
-
|
5
|
-
require 'month'
|
6
|
-
|
7
|
-
class TestMonth < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@null_temp_range = TemperatureRange.new(0, [0, 0], [0, 0])
|
11
|
-
@null_sky_conditions = SkyConditions.new((0..0), (0..0), (0..0))
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_uses_sky_condition_data_to_determine_current_conditions
|
15
|
-
month = Month.new(@null_temp_range, SkyConditions.new((0..34), (35..65), (66..100)))
|
16
|
-
assert_equal(:clear, month.sky_conditions(RiggedRoller.new(25)))
|
17
|
-
assert_equal(:partly_cloudy, month.sky_conditions(RiggedRoller.new(50)))
|
18
|
-
assert_equal(:cloudy, month.sky_conditions(RiggedRoller.new(75)))
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_uses_temp_range_data_to_determine_current_conditions
|
22
|
-
month = Month.new(TemperatureRange.new(10, [8, 2], [20, 5]), @null_sky_conditions)
|
23
|
-
assert_equal((0..17), month.temp_range(RiggedRoller.new(5)))
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_handles_record_high
|
27
|
-
month = Month.new(TemperatureRange.new(10, [8, 2], [20, 5]), @null_sky_conditions)
|
28
|
-
assert_equal((14..23), month.temp_range(RiggedRoller.new(1), :high))
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_determines_precipitation
|
32
|
-
month = Month.new(@null_temp_range, @null_sky_conditions, 50)
|
33
|
-
assert_equal(true, month.has_precipitation(RiggedRoller.new(10)))
|
34
|
-
assert_equal(false, month.has_precipitation(RiggedRoller.new(70)))
|
35
|
-
end
|
36
|
-
end
|
data/test/test_precipitation.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'precipitationinfo'
|
4
|
-
require 'precipitation'
|
5
|
-
|
6
|
-
require 'rollers/riggedroller'
|
7
|
-
|
8
|
-
class TestPrecipitation < Test::Unit::TestCase
|
9
|
-
def test_has_rainbow
|
10
|
-
precip = Precipitation.new(PrecipitationInfo.create_from_data({ :name => "foo", :chance_of_rainbow => 30}),
|
11
|
-
RiggedRoller.new(10))
|
12
|
-
assert_equal(true, precip.rainbow?)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_no_rainbow
|
16
|
-
precip = Precipitation.new(PrecipitationInfo.create_from_data({ :name => "foo", :chance_of_rainbow => 30}),
|
17
|
-
RiggedRoller.new(40))
|
18
|
-
assert_equal(false, precip.rainbow?)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_no_rainbow_if_no_chance_of_it
|
22
|
-
precip = Precipitation.new(PrecipitationInfo.create_from_data({ :name => "foo", :chance_of_rainbow => 0}),
|
23
|
-
RiggedRoller.new(0))
|
24
|
-
assert_equal(false, precip.rainbow?)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'rollers/riggedroller'
|
4
|
-
|
5
|
-
require 'precipitationoccurance'
|
6
|
-
require 'precipitationinfo'
|
7
|
-
|
8
|
-
class TestPrecipitationOccurance < Test::Unit::TestCase
|
9
|
-
def test_returns_array_of_precipitation
|
10
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :light_snowstorm}),
|
11
|
-
(21..100) => create_precip_info({ :name => :light_rainstorm})})
|
12
|
-
assert_instance_of(Array, precip_occur.type(RiggedRoller.new(13)))
|
13
|
-
assert_instance_of(Precipitation, precip_occur.type(RiggedRoller.new(13))[0])
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_determines_precipitation
|
17
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :light_snowstorm}),
|
18
|
-
(21..100) => create_precip_info({ :name => :light_rainstorm})})
|
19
|
-
assert_equal(:light_snowstorm, precip_occur.type(RiggedRoller.new(13))[0].name)
|
20
|
-
assert_equal(:light_rainstorm, precip_occur.type(RiggedRoller.new(57))[0].name)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_load_from_file
|
24
|
-
precip_occur = PrecipitationOccurance.load("data/precipitationoccurance.yml")
|
25
|
-
assert_equal("Sleetstorm", precip_occur.type(RiggedRoller.new(22))[0].name)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_default_value_is_null_precipitation
|
29
|
-
precip_occur = PrecipitationOccurance.new()
|
30
|
-
assert_equal(NullPrecipitationInfo.new().name, precip_occur.type(RiggedRoller.new(13))[0].name)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_checks_for_and_computes_continuing_precipitation
|
34
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :light_snowstorm, :chance_to_continue => 10}),
|
35
|
-
(21..100) => create_precip_info({ :name => :light_rainstorm, :chance_to_continue => 10})})
|
36
|
-
assert_equal([:light_rainstorm, :light_snowstorm, :light_rainstorm, :light_rainstorm],
|
37
|
-
precip_occur.type(RiggedRoller.new(35, 5, 1, 5, 10, 5, 5, 100)).map{ |p| p.name })
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_no_reroll_if_temp_range_is_ok
|
41
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold, :min_temp => 0}),
|
42
|
-
(21..100) => create_precip_info({ :name => :warm, :min_temp => 30})})
|
43
|
-
assert_equal([:warm], precip_occur.type(RiggedRoller.new(35, 10), 40..50).map{ |p| p.name })
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_reroll_if_temp_is_too_low
|
47
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold, :min_temp => 0}),
|
48
|
-
(21..100) => create_precip_info({ :name => :warm, :min_temp => 30})})
|
49
|
-
assert_equal(:cold, precip_occur.type(RiggedRoller.new(35, 10), 10..20)[0].name)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_reroll_if_temp_is_too_high
|
53
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold, :max_temp => 30}),
|
54
|
-
(21..100) => create_precip_info({ :name => :warm, :max_temp => 50})})
|
55
|
-
assert_equal(:warm, precip_occur.type(RiggedRoller.new(10, 35), 40..60)[0].name)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_rerolls_once_only_for_bad_weather
|
59
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold, :max_temp => 30})})
|
60
|
-
assert_equal(Precipitation.new(NullPrecipitationInfo.new(), nil).name,
|
61
|
-
precip_occur.type(RiggedRoller.new(10, 10), 60..70)[0].name)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_checks_temp_ranges_for_continuing_weather
|
65
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold,
|
66
|
-
:chance_to_continue => 10,
|
67
|
-
:max_temp => 20}),
|
68
|
-
(21..100) => create_precip_info({ :name => :hot,
|
69
|
-
:chance_to_continue => 10,
|
70
|
-
:min_temp => 40})})
|
71
|
-
assert_equal([:hot, :hot],
|
72
|
-
precip_occur.type(RiggedRoller.new(35, 5, 1, 20), 30..50).map{ |p| p.name })
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_checks_terrain_for_precipitation
|
76
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :not, :not_allowed_in => [:desert]})})
|
77
|
-
assert_equal(NullPrecipitationInfo.new().name, precip_occur.type(RiggedRoller.new(10), nil, :desert).first.name)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_checks_terrain_for_continuin_weather
|
81
|
-
precip_occur = PrecipitationOccurance.new({ (0..20) => create_precip_info({ :name => :cold,
|
82
|
-
:chance_to_continue => 10,
|
83
|
-
:not_allowed_in => [:desert]}),
|
84
|
-
(21..100) => create_precip_info({ :name => :hot,
|
85
|
-
:chance_to_continue => 10 })})
|
86
|
-
assert_equal(:hot, precip_occur.type(RiggedRoller.new(35, 5, 1, 20), nil, :desert)[1].name)
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
def create_precip_info(hash)
|
91
|
-
PrecipitationInfo.create_from_data(hash)
|
92
|
-
end
|
93
|
-
end
|