Differences From Artifact [6849c1cc0eb810a9]:
- File
src/game.d
- 2012-07-16 10:02:57 - part of checkin [b96971b0b6] on branch trunk - refactoring. (user: kinaba) [annotate]
To Artifact [18f8bb38825744d0]:
- File
src/game.d
- 2012-07-16 10:08:05 - part of checkin [03b7073abc] on branch trunk - refactor. (user: kinaba) [annotate]
315 315 bool use_razor(bool hige_day)
316 316 {
317 317 if(collected_razor > 0)
318 318 {
319 319 collected_razor--;
320 320 for(int dy=-1; dy<=+1; ++dy)
321 321 for(int dx=-1; dx<=+1; ++dx)
322 - if(this[robot.y+dy,robot.x+dx] == 'W') {
323 - emptified(new Pos(robot.y+dy,robot.x+dx));
324 - this[robot.y+dy,robot.x+dx] = ' ';
325 - }
322 + if(this[robot.y+dy,robot.x+dx] == 'W')
323 + emptify(new Pos(robot.y+dy,robot.x+dx));
326 324 }
327 325 return update(hige_day);
328 326 }
329 327
330 328 // Register a position that may become empty in the last turn.
331 - void emptified(Pos p)
329 + void emptify(Pos p)
332 330 {
331 + this[p] = ' ';
333 332 for(int dy=0; dy<=+1; ++dy)
334 333 for(int dx=-1; dx<=+1; ++dx)
335 334 may_update ~= new Pos(p.y+dy, p.x+dx);
336 335 }
337 336
338 337 bool move(int dy, int dx, bool hige_day, in Trampoline tr)
339 338 {
................................................................................
342 341
343 342 if( '\\' == this[next] ) collected_lambda++;
344 343 if( '!' == this[next] ) collected_razor++;
345 344 if( 'O' == this[next] ) cleared = true;
346 345
347 346 if( is_spacy(this[next]) )
348 347 {
349 - emptified(robot);
350 - this[y,x] = ' ';
351 - this[next] = 'R';
348 + emptify(robot);
352 349 robot = next;
350 + this[next] = 'R';
353 351 }
354 352 else if(dy==0 && is_rocky(this[next]) && ' '==this[y+dy*2,x+dx*2])
355 353 {
356 354 char rock = this[next];
357 - emptified(robot);
358 - this[y,x] = ' ';
355 + emptify(robot);
356 + robot = next;
359 357 this[next] = 'R';
360 358 this[y+dy*2,x+dx*2] = rock;
361 - robot = next;
362 359 may_update ~= new Pos(y+dy*2,x+dx*2);
363 360 }
364 361 else if(is_trampoline_source(this[next]))
365 362 {
366 - emptified(robot);
367 - this[y,x] = ' ';
363 + emptify(robot);
368 364 Pos tp = tr.target_pos(this[next]);
369 365 foreach(p; tr.source_pos(this[tp]))
370 - {
371 - emptified(p);
372 - this[p] = ' ';
373 - }
366 + emptify(p);
374 367 this[tp] = 'R';
375 368 robot = tp;
376 369 }
377 370 return update(hige_day);
378 371 }
379 372
380 373 bool update(bool hige_day)
................................................................................
386 379 scope(exit) {
387 380 may_update.length = 0;
388 381 foreach(wr; write_buffer) {
389 382 this[wr[0],wr[1]] = wr[2];
390 383 if(is_rocky(wr[2]))
391 384 may_update ~= new Pos(wr[0],wr[1]);
392 385 if(wr[2]==' ')
393 - emptified(new Pos(wr[0], wr[1]));
386 + emptify(new Pos(wr[0], wr[1]));
394 387 }
395 388 }
396 389
397 390 if(collected_lambda == total_lambda)
398 391 if(this[lift]=='L')
399 392 this[lift] = 'O';
400 393