Differences From Artifact [06258bf9d419d24b]:
- File
src/game.d
- 2012-07-15 01:58:08 - part of checkin [9d983af88c] on branch trunk - Hige parsing and rendering. (user: kinaba) [annotate]
To Artifact [de7a471045510ac0]:
- File
src/game.d
- 2012-07-15 02:04:13 - part of checkin [2b4f8bba2d] on branch trunk - Hige growth implemented. (user: kinaba) [annotate]
234 for(int y=1; y<=H; ++y) 234 for(int y=1; y<=H; ++y)
235 for(int x=1; x<=W; ++x) 235 for(int x=1; x<=W; ++x)
236 if(this[y,x] == 'L' || this[y,x] == 'O') 236 if(this[y,x] == 'L' || this[y,x] == 'O')
237 return false; 237 return false;
238 return true; 238 return true;
239 } 239 }
240 240
241 Tuple!(int,bool) command(char c) | 241 Tuple!(int,bool) command(char c, int turn)
242 { 242 {
243 if(c=='R') return move( 0, +1); | 243 if(c=='R') return move( 0, +1, turn);
244 if(c=='L') return move( 0, -1); | 244 if(c=='L') return move( 0, -1, turn);
245 if(c=='U') return move(+1, 0); | 245 if(c=='U') return move(+1, 0, turn);
246 if(c=='D') return move(-1, 0); | 246 if(c=='D') return move(-1, 0, turn);
247 if(c=='W') return move( 0, 0); | 247 if(c=='W') return move( 0, 0, turn);
248 assert(false); 248 assert(false);
249 } 249 }
250 250
251 Tuple!(int, bool) move(int dy, int dx) | 251 Tuple!(int, bool) move(int dy, int dx, int turn)
252 { 252 {
253 int y = robot.y; 253 int y = robot.y;
254 int x = robot.x; 254 int x = robot.x;
255 assert( this[robot] == 'R' ); 255 assert( this[robot] == 'R' );
256 int lambda = 0; 256 int lambda = 0;
257 bool dead = false; 257 bool dead = false;
258 if( '\\' == this[y+dy,x+dx] ) 258 if( '\\' == this[y+dy,x+dx] )
................................................................................................................................................................................
270 this[y,x]=' '; 270 this[y,x]=' ';
271 Pos tp = tr_target[this[y+dy,x+dx]]; 271 Pos tp = tr_target[this[y+dy,x+dx]];
272 foreach(p; tr_source[this[tp]]) 272 foreach(p; tr_source[this[tp]])
273 this[p] = ' '; 273 this[p] = ' ';
274 this[tp] = 'R'; 274 this[tp] = 'R';
275 robot = tp; 275 robot = tp;
276 } 276 }
277 if( update() ) | 277 if( update(turn) )
278 dead = true; 278 dead = true;
279 return tuple(lambda,dead); 279 return tuple(lambda,dead);
280 } 280 }
281 281
282 bool update() | 282 bool update(int turn)
283 { 283 {
284 bool dead = false; 284 bool dead = false;
285 285
286 char[][] next; 286 char[][] next;
287 foreach(y,s; data) 287 foreach(y,s; data)
288 next ~= s.dup; 288 next ~= s.dup;
289 289
................................................................................................................................................................................
317 dead=true; 317 dead=true;
318 } 318 }
319 } 319 }
320 else if(this[p]=='L') { 320 else if(this[p]=='L') {
321 if(!lambda) 321 if(!lambda)
322 access(p) = 'O'; 322 access(p) = 'O';
323 } 323 }
> 324 else if(this[p]=='W') {
> 325 if( hige.is_growing_turn(turn) )
> 326 for(int dy=-1; dy<=+1; ++dy)
> 327 for(int dx=-1; dx<=+1; ++dx)
> 328 if(this[p.y+dy,p.x+dx] == ' ')
> 329 access(new Pos(p.y+dy,p.
> 330 }
324 } 331 }
325 data = next; 332 data = next;
326 return dead; 333 return dead;
327 } 334 }
328 } 335 }
329 336
330 //////////////////////////////////////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////////////
................................................................................................................................................................................
385 if(c == 'A') 392 if(c == 'A')
386 { 393 {
387 exit_bonus = 1; 394 exit_bonus = 1;
388 return; 395 return;
389 } 396 }
390 397
391 // TODO: clarify the event order 398 // TODO: clarify the event order
392 Tuple!(int,bool) ld = map.command(c); | 399 Tuple!(int,bool) ld = map.command(c, turn);
393 if( map.cleared() ) { 400 if( map.cleared() ) {
394 exit_bonus = 2; 401 exit_bonus = 2;
395 } 402 }
396 else { 403 else {
397 lambda += ld[0]; 404 lambda += ld[0];
398 if( ld[1] ) { 405 if( ld[1] ) {
399 dead = true; 406 dead = true;