Differences From Artifact [9d4255819d57ec36]:
- File
src/game.d
- 2012-07-15 03:48:10 - part of checkin [4aa9d7f484] on branch trunk - cleanup (user: kinaba) [annotate]
To Artifact [0eb850e277f37179]:
- File
src/game.d
- 2012-07-15 04:44:33 - part of checkin [879099f815] on branch trunk - Moved 'abort' behavior completely out of Game. (user: kinaba) [annotate]
391 391 Game clone() const { return new Game(this); }
392 392 this(in Game g) {
393 393 map = g.map.clone();
394 394 water = g.water.clone();
395 395 turn = g.turn;
396 396 dead = g.dead;
397 397 lambda = g.lambda;
398 - exit_bonus = g.exit_bonus;
398 + cleared = g.cleared;
399 399 under_water = g.under_water;
400 400 }
401 401
402 402 void command(char c)
403 403 {
404 + assert(c != 'A');
404 405 if(dead || cleared)
405 406 return;
406 407
407 - if(c == 'A')
408 - {
409 - exit_bonus = 1;
410 - return;
411 - }
412 -
413 408 // TODO: clarify the event order
414 409 Tuple!(int,bool) ld = map.command(c, turn);
415 410 if( map.cleared() ) {
416 - exit_bonus = 2;
411 + cleared = true;
417 412 }
418 413 else {
419 414 lambda += ld[0];
420 - if( ld[1] ) {
415 + if( ld[1] )
421 416 dead = true;
422 - }
423 417 }
424 418 if( map.robot.y <= water_level )
425 419 ++under_water;
426 420 else
427 421 under_water = 0;
428 422 if( under_water > map.waterproof )
429 423 dead = true;
................................................................................
431 425 }
432 426
433 427 Map map;
434 428 Water water;
435 429 int turn = 0;
436 430 bool dead = false;
437 431 int lambda = 0;
438 - int exit_bonus = 0;
439 432 int under_water = 0;
433 + bool cleared = false;
440 434 // TODO: when adding members, take care of clone().
441 435 // TODO: fix this poor design.
442 436
443 437 @property const {
444 - long score() { return lambda*25L*(1+exit_bonus) - turn; }
438 + long score() { return lambda*(dead ? 25L : cleared ? 75L : 50L) - turn; }
445 439 int water_level() { return water.level(turn); }
446 440 int water_until_rise() { return water.until_rise(turn); }
447 441 int hige_until_rise() { return map.hige.until_rise(turn); }
448 - bool cleared() { return exit_bonus>0; }
449 442 int hp() { return map.waterproof - under_water; }
450 - long score_if_abort_now() { return lambda*25*(1+max(1,exit_bonus)) - turn; }
451 443 }
452 444 }