Overview
SHA1 Hash: | 03b7073abc2b503a5631606049d77600719cc18a |
---|---|
Date: | 2012-07-16 19:08:05 |
User: | kinaba |
Comment: | refactor. |
Timelines: | family | ancestors | descendants | both | trunk |
Diffs: | redesign |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified src/game.d from [6849c1cc0eb810a9] to [18f8bb38825744d0].
315 bool use_razor(bool hige_day) 315 bool use_razor(bool hige_day) 316 { 316 { 317 if(collected_razor > 0) 317 if(collected_razor > 0) 318 { 318 { 319 collected_razor--; 319 collected_razor--; 320 for(int dy=-1; dy<=+1; ++dy) 320 for(int dy=-1; dy<=+1; ++dy) 321 for(int dx=-1; dx<=+1; ++dx) 321 for(int dx=-1; dx<=+1; ++dx) 322 if(this[robot.y+dy,robot.x+dx] == 'W') { | 322 if(this[robot.y+dy,robot.x+dx] == 'W') 323 emptified(new Pos(robot.y+dy,robot.x+dx) | 323 emptify(new Pos(robot.y+dy,robot.x+dx)); 324 this[robot.y+dy,robot.x+dx] = ' '; < 325 } < 326 } 324 } 327 return update(hige_day); 325 return update(hige_day); 328 } 326 } 329 327 330 // Register a position that may become empty in the last turn. 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 for(int dy=0; dy<=+1; ++dy) 332 for(int dy=0; dy<=+1; ++dy) 334 for(int dx=-1; dx<=+1; ++dx) 333 for(int dx=-1; dx<=+1; ++dx) 335 may_update ~= new Pos(p.y+dy, p.x+dx); 334 may_update ~= new Pos(p.y+dy, p.x+dx); 336 } 335 } 337 336 338 bool move(int dy, int dx, bool hige_day, in Trampoline tr) 337 bool move(int dy, int dx, bool hige_day, in Trampoline tr) 339 { 338 { ................................................................................................................................................................................ 342 341 343 if( '\\' == this[next] ) collected_lambda++; 342 if( '\\' == this[next] ) collected_lambda++; 344 if( '!' == this[next] ) collected_razor++; 343 if( '!' == this[next] ) collected_razor++; 345 if( 'O' == this[next] ) cleared = true; 344 if( 'O' == this[next] ) cleared = true; 346 345 347 if( is_spacy(this[next]) ) 346 if( is_spacy(this[next]) ) 348 { 347 { 349 emptified(robot); | 348 emptify(robot); 350 this[y,x] = ' '; < 351 this[next] = 'R'; < 352 robot = next; 349 robot = next; > 350 this[next] = 'R'; 353 } 351 } 354 else if(dy==0 && is_rocky(this[next]) && ' '==this[y+dy*2,x+dx*2 352 else if(dy==0 && is_rocky(this[next]) && ' '==this[y+dy*2,x+dx*2 355 { 353 { 356 char rock = this[next]; 354 char rock = this[next]; 357 emptified(robot); | 355 emptify(robot); 358 this[y,x] = ' '; | 356 robot = next; 359 this[next] = 'R'; 357 this[next] = 'R'; 360 this[y+dy*2,x+dx*2] = rock; 358 this[y+dy*2,x+dx*2] = rock; 361 robot = next; < 362 may_update ~= new Pos(y+dy*2,x+dx*2); 359 may_update ~= new Pos(y+dy*2,x+dx*2); 363 } 360 } 364 else if(is_trampoline_source(this[next])) 361 else if(is_trampoline_source(this[next])) 365 { 362 { 366 emptified(robot); | 363 emptify(robot); 367 this[y,x] = ' '; < 368 Pos tp = tr.target_pos(this[next]); 364 Pos tp = tr.target_pos(this[next]); 369 foreach(p; tr.source_pos(this[tp])) 365 foreach(p; tr.source_pos(this[tp])) 370 { < 371 emptified(p); | 366 emptify(p); 372 this[p] = ' '; < 373 } < 374 this[tp] = 'R'; 367 this[tp] = 'R'; 375 robot = tp; 368 robot = tp; 376 } 369 } 377 return update(hige_day); 370 return update(hige_day); 378 } 371 } 379 372 380 bool update(bool hige_day) 373 bool update(bool hige_day) ................................................................................................................................................................................ 386 scope(exit) { 379 scope(exit) { 387 may_update.length = 0; 380 may_update.length = 0; 388 foreach(wr; write_buffer) { 381 foreach(wr; write_buffer) { 389 this[wr[0],wr[1]] = wr[2]; 382 this[wr[0],wr[1]] = wr[2]; 390 if(is_rocky(wr[2])) 383 if(is_rocky(wr[2])) 391 may_update ~= new Pos(wr[0],wr[1]); 384 may_update ~= new Pos(wr[0],wr[1]); 392 if(wr[2]==' ') 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 if(collected_lambda == total_lambda) 390 if(collected_lambda == total_lambda) 398 if(this[lift]=='L') 391 if(this[lift]=='L') 399 this[lift] = 'O'; 392 this[lift] = 'O'; 400 393