2 require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
\r
6 describe "blind mode" do
\r
8 describe RDGC::Map::Area, "with blind" do
\r
15 @area.set_blind(:none)
\r
17 @area.blind_level.should == :none
\r
18 @area.blind_level_none?.should be_true
\r
19 @area.blind_level_open?.should be_false
\r
20 @area.blind_level_blind?.should be_false
\r
21 @area.blind_level_dark?.should be_false
\r
25 @area.set_blind(:open)
\r
27 @area.blind_level.should == :open
\r
28 @area.blind_level_none?.should be_false
\r
29 @area.blind_level_open?.should be_true
\r
30 @area.blind_level_blind?.should be_false
\r
31 @area.blind_level_dark?.should be_false
\r
35 @area.set_blind(:blind)
\r
37 @area.blind_level.should == :blind
\r
38 @area.blind_level_none?.should be_false
\r
39 @area.blind_level_open?.should be_false
\r
40 @area.blind_level_blind?.should be_true
\r
41 @area.blind_level_dark?.should be_false
\r
45 @area.set_blind(:dark)
\r
47 @area.blind_level.should == :dark
\r
48 @area.blind_level_none?.should be_false
\r
49 @area.blind_level_open?.should be_false
\r
50 @area.blind_level_blind?.should be_false
\r
51 @area.blind_level_dark?.should be_true
\r
54 it "unexpected level" do
\r
55 @area.set_blind(:hoge)
\r
57 @area.blind_level.should be_nil
\r
58 @area.blind_level_none?.should be_false
\r
59 @area.blind_level_open?.should be_false
\r
60 @area.blind_level_blind?.should be_false
\r
61 @area.blind_level_dark?.should be_false
\r
66 describe RDGC::Map::Board, "with blind" do
\r
69 @board = Board.create(0, 20, 0, 20)
\r
71 @room = Room.create(5, 15, 5, 15)
\r
72 @road1 = Road.create(0, 4, 10, 10)
\r
73 @road2 = Road.create(16, 20, 12, 12)
\r
75 @board.rooms << @room
\r
76 @board.roads << @road1
\r
77 @board.roads << @road2
\r
81 it "#blind_level/#set_blind is disable" do
\r
82 [:none, :open, :blind, :dark].each do |lv|
\r
83 @board.set_blind(lv)
\r
85 @board.blind_level.should be_nil
\r
86 @board.blind_level_none?.should be_false
\r
87 @board.blind_level_open?.should be_false
\r
88 @board.blind_level_blind?.should be_false
\r
89 @board.blind_level_dark?.should be_false
\r
93 it "#init_blind_all will set :blind to all rooms/roads" do
\r
94 @board.init_blind_all(:none)
\r
95 @board.areas.each do |a|
\r
96 a.blind_level_none?.should be_true
\r
99 @board.init_blind_all(:blind)
\r
100 @board.areas.each do |a|
\r
101 a.blind_level_blind?.should be_true
\r
105 it "#init_blind_normal will set :blind to roads, :open to rooms" do
\r
106 @board.init_blind_normal
\r
108 @room.blind_level_open?.should be_true
\r
109 @road1.blind_level_blind?.should be_true
\r
110 @road2.blind_level_blind?.should be_true
\r
113 it "#init_blind will set blind_level each rooms/roads as blind_mode" do
\r
114 @board.instance_eval do
\r
115 @blind_mode = Board::BLIND_MODE_NONE
\r
119 @room.blind_level_none?.should be_true
\r
120 @road1.blind_level_none?.should be_true
\r
121 @road2.blind_level_none?.should be_true
\r
123 @board.instance_eval do
\r
124 @blind_mode = Board::BLIND_MODE_NORMAL
\r
128 @room.blind_level_open?.should be_true
\r
129 @road1.blind_level_blind?.should be_true
\r
130 @road2.blind_level_blind?.should be_true
\r
132 @board.instance_eval do
\r
133 @blind_mode = Board::BLIND_MODE_BLIND
\r
137 @room.blind_level_blind?.should be_true
\r
138 @road1.blind_level_blind?.should be_true
\r
139 @road2.blind_level_blind?.should be_true
\r
142 it "#set_blind_mode will set blind_mode, and init_blind" do
\r
143 @board.blind_mode?.should be_false
\r
145 @board.set_blind_mode(Board::BLIND_MODE_NONE)
\r
146 @board.blind_mode.should == Board::BLIND_MODE_NONE
\r
147 @board.blind_mode?.should be_true
\r
149 @room.blind_level_none?.should be_true
\r
150 @road1.blind_level_none?.should be_true
\r
151 @road2.blind_level_none?.should be_true
\r
153 @board.set_blind_mode(Board::BLIND_MODE_NORMAL)
\r
154 @board.blind_mode.should == Board::BLIND_MODE_NORMAL
\r
155 @board.blind_mode?.should be_true
\r
157 @room.blind_level_open?.should be_true
\r
158 @road1.blind_level_blind?.should be_true
\r
159 @road2.blind_level_blind?.should be_true
\r
161 @board.set_blind_mode(Board::BLIND_MODE_BLIND)
\r
162 @board.blind_mode.should == Board::BLIND_MODE_BLIND
\r
163 @board.blind_mode?.should be_true
\r
165 @room.blind_level_blind?.should be_true
\r
166 @road1.blind_level_blind?.should be_true
\r
167 @road2.blind_level_blind?.should be_true
\r
169 @board.set_blind_mode
\r
170 @board.blind_mode.should == Board::BLIND_MODE_NORMAL
\r
171 @board.blind_mode?.should be_true
\r
173 @room.blind_level_open?.should be_true
\r
174 @road1.blind_level_blind?.should be_true
\r
175 @road2.blind_level_blind?.should be_true
\r
178 it "#fill_blind will fill blind_data as each area's blind_level" do
\r
179 @board.set_blind_mode
\r
182 @board.areas.each do |r|
\r
184 @board.blind_data[x][y].should == :blind
\r
188 @board.set_blind_mode(:none)
\r
191 @board.areas.each do |r|
\r
193 @board.blind_data[x][y].should == :none
\r
198 it "#dark? judge this point is :dark now" do
\r
199 @board.set_blind_mode
\r
200 @room.set_blind(:dark)
\r
201 @room.blind_level_dark?.should be_true
\r
204 @room.each.all?{|x, y| @board.dark?(x, y)}.should be_true
\r
206 tx, ty = @room.random_point
\r
207 @board.blind_data[tx][ty] = :none
\r
208 @board.dark?(tx, ty).should be_false
\r
211 it "#fill_dark_before_cancel" do
\r
212 @board.set_blind_mode
\r
213 @room.set_blind(:dark)
\r
214 @room.blind_level_dark?.should be_true
\r
218 tx, ty = @room.random_point
\r
219 @board.blind_data[tx][ty] = :none
\r
221 @room.each.all?{|x, y| @board.dark?(x, y)}.should be_false
\r
223 @board.instance_eval do
\r
224 fill_dark_before_cancel
\r
226 @room.each.all?{|x, y| @board.dark?(x, y)}.should be_true
\r
229 it "#open_blind will clear blind stat recursive" do
\r
230 @board.set_blind_mode(Board::BLIND_MODE_BLIND)
\r
233 @board.open_blind(10, 4, 0)
\r
234 @board.blind_data[10][4].should == :none
\r
235 @board.blind_data[10][3].should == :blind
\r
236 @board.blind_data[10][5].should == :blind
\r
238 @board.open_blind(10, 4, 1)
\r
239 @board.blind_data[10][4].should == :none
\r
240 @board.blind_data[10][3].should == :none
\r
241 @board.blind_data[10][5].should == :none
\r
242 @board.blind_data[10][2].should == :blind
\r
243 @board.blind_data[10][6].should == :blind
\r
245 @board.open_blind(10, 4, 2)
\r
246 @board.blind_data[10][4].should == :none
\r
247 @board.blind_data[10][3].should == :none
\r
248 @board.blind_data[10][2].should == :none
\r
249 @board.blind_data[10][1].should == :blind
\r
251 @board.blind_data[10][5].should == :none
\r
252 @board.blind_data[9][5].should == :none
\r
253 @board.blind_data[10][6].should == :none
\r
254 @board.blind_data[11][5].should == :none
\r
256 @board.blind_data[8][5].should == :blind
\r
257 @board.blind_data[12][5].should == :blind
\r
258 @board.blind_data[9][6].should == :blind
\r
259 @board.blind_data[11][6].should == :blind
\r
260 @board.blind_data[10][7].should == :blind
\r
263 it "#open_blind will clear blind all of area for :open" do
\r
264 @board.set_blind_mode
\r
267 @board.open_blind(10, 4, 1)
\r
268 @board.blind_data[10][4].should == :none
\r
269 @board.blind_data[10][3].should == :none
\r
270 @board.blind_data[10][5].should == :none
\r
271 @board.blind_data[10][2].should == :blind
\r
273 @room.each do |x, y|
\r
274 @board.blind_data[x][y].should == :none
\r
278 it "#open_blind will clear blind, and turn to dark for opened point" do
\r
279 @board.set_blind_mode
\r
280 @room.set_blind(:dark)
\r
284 @board.open_blind(10, 5, 1)
\r
286 @board.blind_data[10][4].should == :none
\r
288 @board.blind_data[10][5].should == :none
\r
289 @board.blind_data[9][5].should == :none
\r
290 @board.blind_data[11][5].should == :none
\r
291 @board.blind_data[10][6].should == :none
\r
294 @board.open_blind(10, 6, 1)
\r
295 @board.blind_data[10][4].should == :none
\r
297 @board.blind_data[10][6].should == :none
\r
298 @board.blind_data[9][6].should == :none
\r
299 @board.blind_data[11][6].should == :none
\r
300 @board.blind_data[10][5].should == :none
\r
301 @board.blind_data[10][7].should == :none
\r
303 @board.blind_data[9][5].should == :dark
\r
304 @board.blind_data[11][5].should == :dark
\r
307 it "#visible?/#invisible?" do
\r
308 @board.set_blind_mode
\r
309 @road2.set_blind(:dark)
\r
312 @board.open_blind(10, 4, 1)
\r
313 @board.visible?(10, 4).should be_true
\r
314 @board.visible?(10, 3).should be_true
\r
315 @board.visible?(10, 5).should be_true
\r
316 @board.visible?(10, 2).should be_false
\r
317 @board.invisible?(10, 2).should be_true
\r
319 @room.each do |x, y|
\r
320 @board.visible?(x, y).should be_true
\r
321 @board.invisible?(x, y).should be_false
\r
325 tx, ty = @road2.random_point
\r
326 @board.visible?(tx, ty).should be_false
\r
327 @board.invisible?(tx, ty).should be_true
\r
330 @board.visible?(30, 30).should be_false
\r
331 @board.invisible?(30, 30).should be_true
\r