rdgc-dm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +22 -0
- data/README.rdoc +148 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/rdgc/maker/divide_dungeon_maker.rb +371 -0
- data/lib/rdgc/maker/divide_temp_block.rb +269 -0
- data/lib/rdgc/maker/dungeon_maker.rb +57 -0
- data/lib/rdgc/maker/temp_block.rb +23 -0
- data/lib/rdgc/map/area.rb +103 -0
- data/lib/rdgc/map/block.rb +155 -0
- data/lib/rdgc/map/board.rb +81 -0
- data/lib/rdgc/map/road.rb +18 -0
- data/lib/rdgc/map/room.rb +69 -0
- data/lib/rdgc/map/tile.rb +35 -0
- data/lib/rdgc/map/tile_type.rb +11 -0
- data/lib/rdgc/util/config.rb +74 -0
- data/lib/rdgc/util/random_util.rb +104 -0
- data/lib/rdgc-dm.rb +17 -0
- data/rdgc-dm.gemspec +93 -0
- data/spec/rdgc/maker/01_temp_block_spec.rb +45 -0
- data/spec/rdgc/maker/02_divide_temp_block_spec.rb +241 -0
- data/spec/rdgc/maker/03_divide_dungeon_maker_divide_spec.rb +224 -0
- data/spec/rdgc/maker/04_divide_dungeon_maker_create_spec.rb +244 -0
- data/spec/rdgc/map/01_tile_spec.rb +56 -0
- data/spec/rdgc/map/02_area_spec.rb +118 -0
- data/spec/rdgc/map/03_road_spec.rb +23 -0
- data/spec/rdgc/map/04_room_spec.rb +190 -0
- data/spec/rdgc/map/05_block_spec.rb +273 -0
- data/spec/rdgc/map/06_board_spec.rb +132 -0
- data/spec/rdgc/util/01_config_spec.rb +44 -0
- data/spec/rdgc/util/02_random_util_spec.rb +153 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- metadata +124 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
3
|
+
|
4
|
+
include RDGC::Util
|
5
|
+
|
6
|
+
describe RDGC::Util::RandomUtil do
|
7
|
+
|
8
|
+
it "bool_rand provides true or false" do
|
9
|
+
100.times do
|
10
|
+
[true, false].should be_include(bool_rand)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "range_rand provides s_val <= val <= e_val" do
|
15
|
+
|
16
|
+
it "give s_val and e_val" do
|
17
|
+
s_val = 1
|
18
|
+
e_val = 10
|
19
|
+
|
20
|
+
100.times do
|
21
|
+
ret = range_rand(s_val, e_val)
|
22
|
+
ret.should >= s_val
|
23
|
+
ret.should <= e_val
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "return s_val if s_val > e_val" do
|
28
|
+
s_val = 15
|
29
|
+
e_val = 1
|
30
|
+
|
31
|
+
100.times do
|
32
|
+
ret = range_rand(s_val, e_val)
|
33
|
+
ret.should == s_val
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "select_rand provides hash key at random" do
|
40
|
+
|
41
|
+
it "select random key" do
|
42
|
+
hash = {:k1 => 10, :k2 => 5, :k3 => 3}
|
43
|
+
expect = [:k1, :k2, :k3]
|
44
|
+
|
45
|
+
100.times do
|
46
|
+
ret = select_rand(hash)
|
47
|
+
expect.should be_include(ret)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "never return key if value = 0" do
|
52
|
+
hash = {:k1 => 1, :k2 => 1, :k3 => 0}
|
53
|
+
expect = [:k1, :k2]
|
54
|
+
|
55
|
+
100.times do
|
56
|
+
ret = select_rand(hash)
|
57
|
+
expect.should be_include(ret)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "return nil, if hash is nil or values sum 0" do
|
62
|
+
hash = {:k1 => 0, :k2 => 0, :k3 => 0}
|
63
|
+
|
64
|
+
10.times do
|
65
|
+
ret = select_rand(hash)
|
66
|
+
ret.should be_nil
|
67
|
+
end
|
68
|
+
|
69
|
+
10.times do
|
70
|
+
ret = select_rand(nil)
|
71
|
+
ret.should be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "dice provides value like (n-dice * times)" do
|
78
|
+
|
79
|
+
it "dice(1, n) behave n-dice" do
|
80
|
+
[4, 6, 10].each do |n|
|
81
|
+
100.times do
|
82
|
+
val = dice(1, n)
|
83
|
+
val.should >= 1
|
84
|
+
val.should <= n
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "dice(n, 6) behave 6-dice roll n-times" do
|
90
|
+
(1..10).each do |n|
|
91
|
+
100.times do
|
92
|
+
val = dice(n, 6)
|
93
|
+
val.should >= (1 * n)
|
94
|
+
val.should <= (6 * n)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "define Integer#dice" do
|
102
|
+
|
103
|
+
it "#d4 #d6 #d10 provides each-dice roll self-times" do
|
104
|
+
(1..10).each do |n|
|
105
|
+
100.times do
|
106
|
+
d4 = n.d4
|
107
|
+
d4.should >= (1 * n)
|
108
|
+
d4.should <= (4 * n)
|
109
|
+
|
110
|
+
d6 = n.d6
|
111
|
+
d6.should >= (1 * n)
|
112
|
+
d6.should <= (6 * n)
|
113
|
+
|
114
|
+
d10 = n.d10
|
115
|
+
d10.should >= (1 * n)
|
116
|
+
d10.should <= (10 * n)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "any number dice can use, example 4.d5, 3.d16" do
|
122
|
+
100.times do
|
123
|
+
val1 = 4.d5
|
124
|
+
val1.should >= (1 * 4)
|
125
|
+
val1.should <= (5 * 4)
|
126
|
+
|
127
|
+
val2 = 3.d16
|
128
|
+
val2.should >= (1 * 3)
|
129
|
+
val2.should <= (16 * 3)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "define Array#pickup!" do
|
136
|
+
|
137
|
+
it "#pickup! shift random value in Array" do
|
138
|
+
array = [1, 2, 3, 4, 5]
|
139
|
+
list = array.dup
|
140
|
+
|
141
|
+
array.size.times do |i|
|
142
|
+
ret = list.pickup!
|
143
|
+
array.should be_include(ret)
|
144
|
+
list.should_not be_include(ret)
|
145
|
+
list.size.should == array.size - (i+1)
|
146
|
+
end
|
147
|
+
|
148
|
+
list.should be_empty
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdgc-dm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- parrot_studio
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-01 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
31
|
+
version: 1.2.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
description: " This gem is part of RDGC - Ruby(Random) Dungeon Game Core.\n RDGC is core of random dungeon game (like rogue), make dungeon, manage mnsters etc.\n"
|
35
|
+
email: parrot@users.sourceforge.jp
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- LICENSE
|
42
|
+
- README.rdoc
|
43
|
+
files:
|
44
|
+
- .document
|
45
|
+
- .gitignore
|
46
|
+
- LICENSE
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- VERSION
|
50
|
+
- lib/rdgc-dm.rb
|
51
|
+
- lib/rdgc/maker/divide_dungeon_maker.rb
|
52
|
+
- lib/rdgc/maker/divide_temp_block.rb
|
53
|
+
- lib/rdgc/maker/dungeon_maker.rb
|
54
|
+
- lib/rdgc/maker/temp_block.rb
|
55
|
+
- lib/rdgc/map/area.rb
|
56
|
+
- lib/rdgc/map/block.rb
|
57
|
+
- lib/rdgc/map/board.rb
|
58
|
+
- lib/rdgc/map/road.rb
|
59
|
+
- lib/rdgc/map/room.rb
|
60
|
+
- lib/rdgc/map/tile.rb
|
61
|
+
- lib/rdgc/map/tile_type.rb
|
62
|
+
- lib/rdgc/util/config.rb
|
63
|
+
- lib/rdgc/util/random_util.rb
|
64
|
+
- rdgc-dm.gemspec
|
65
|
+
- spec/rdgc/maker/01_temp_block_spec.rb
|
66
|
+
- spec/rdgc/maker/02_divide_temp_block_spec.rb
|
67
|
+
- spec/rdgc/maker/03_divide_dungeon_maker_divide_spec.rb
|
68
|
+
- spec/rdgc/maker/04_divide_dungeon_maker_create_spec.rb
|
69
|
+
- spec/rdgc/map/01_tile_spec.rb
|
70
|
+
- spec/rdgc/map/02_area_spec.rb
|
71
|
+
- spec/rdgc/map/03_road_spec.rb
|
72
|
+
- spec/rdgc/map/04_room_spec.rb
|
73
|
+
- spec/rdgc/map/05_block_spec.rb
|
74
|
+
- spec/rdgc/map/06_board_spec.rb
|
75
|
+
- spec/rdgc/util/01_config_spec.rb
|
76
|
+
- spec/rdgc/util/02_random_util_spec.rb
|
77
|
+
- spec/spec.opts
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://github.com/parrot-studio/rdgc-dm
|
81
|
+
licenses: []
|
82
|
+
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- --charset=UTF-8
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 8
|
95
|
+
- 7
|
96
|
+
version: 1.8.7
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.3.6
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Random Dungeon Maker from RDGC
|
111
|
+
test_files:
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- spec/rdgc/util/02_random_util_spec.rb
|
114
|
+
- spec/rdgc/util/01_config_spec.rb
|
115
|
+
- spec/rdgc/map/04_room_spec.rb
|
116
|
+
- spec/rdgc/map/06_board_spec.rb
|
117
|
+
- spec/rdgc/map/01_tile_spec.rb
|
118
|
+
- spec/rdgc/map/03_road_spec.rb
|
119
|
+
- spec/rdgc/map/05_block_spec.rb
|
120
|
+
- spec/rdgc/map/02_area_spec.rb
|
121
|
+
- spec/rdgc/maker/02_divide_temp_block_spec.rb
|
122
|
+
- spec/rdgc/maker/01_temp_block_spec.rb
|
123
|
+
- spec/rdgc/maker/04_divide_dungeon_maker_create_spec.rb
|
124
|
+
- spec/rdgc/maker/03_divide_dungeon_maker_divide_spec.rb
|