Check-in [fc9286dad1]
Not logged in
Overview
SHA1 Hash:fc9286dad1b67886e1383a5319816cdec6520152
Date: 2012-07-15 21:11:33
User: kinaba
Comment:uum
Timelines: family | ancestors | redesign
Diffs: root of this branch
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/game.d from [eaa7866c864bed8a] to [fc05481901940844].

345 345 } 346 346 } 347 347 data = next; 348 348 return dead; 349 349 } 350 350 } 351 351 352 -//////////////////////////////////////////////////////////////////////////////// 353 -/* 354 -class Game 355 -{ 356 - mixin DeriveShow; 357 - 358 - static Game load(File input) 359 - { 360 - string[] raw_data; 361 - string[string] params; 362 - 363 - // Raw map data; read until empty line. 364 - for(string line; !(line=input.readln().chomp()).empty; ) 365 - raw_data ~= line; 366 - 367 - // Additional commands; read until EOF. 368 - char[char] trampo; 369 - for(string line; !(line=input.readln()).empty; ) { 370 - string[] ss = line.split(); 371 - if( ss.length == 2 ) 372 - params[ss[0]] = ss[1]; 373 - if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="targets" ) 374 - trampo[ss[1][0]] = ss[3][0]; 375 - } 376 - 377 - return load(raw_data, params, trampo); 378 - } 379 - 380 - static Game load(string[] raw_data, string[string] params, char[char] trampo = null) 381 - { 382 - return new Game(raw_data, params, trampo); 383 - } 384 - 385 - this(string[] raw_data, string[string] params, char[char] trampo) 386 - { 387 - this.map = Map.load(raw_data, params, trampo); 388 - this.water = Water.load(params); 389 - } 390 - 391 - Game clone() const { return new Game(this); } 392 - this(in Game g) { 393 - map = g.map.clone(); 394 - water = g.water.clone(); 395 - turn = g.turn; 396 - dead = g.dead; 397 - lambda = g.lambda; 398 - cleared = g.cleared; 399 - under_water = g.under_water; 400 - } 401 - 402 - void command(char c) 403 - { 404 - assert(c != 'A'); 405 - if(dead || cleared) 406 - return; 407 - 408 - // TODO: clarify the event order 409 - Tuple!(int,bool) ld = map.command(c, turn); 410 - if( map.cleared() ) { 411 - cleared = true; 412 - } 413 - else { 414 - lambda += ld[0]; 415 - if( ld[1] ) 416 - dead = true; 417 - } 418 - if(!cleared) { 419 - if( map.robot.y <= water_level ) 420 - ++under_water; 421 - else 422 - under_water = 0; 423 - if( under_water > map.waterproof ) 424 - dead = true; 425 - } 426 - turn += 1; 427 - } 428 - 429 - Map map; 430 - Water water; 431 - int turn = 0; 432 - bool dead = false; 433 - int lambda = 0; 434 - int under_water = 0; 435 - bool cleared = false; 436 - // TODO: when adding members, take care of clone(). 437 - // TODO: fix this poor design. 438 - 439 - @property const { 440 - long score() { return lambda*(dead ? 25L : cleared ? 75L : 50L) - turn; } 441 - int water_level() { return water.level(turn); } 442 - int water_until_rise() { return water.until_rise(turn); } 443 - int hige_until_rise() { return map.hige.until_rise(turn); } 444 - int hp() { return map.waterproof - under_water; } 445 - } 446 -} 447 -*/ 448 - 449 352 //////////////////////////////////////////////////////////////////////////////// 450 353 451 354 class Game 452 355 { 453 356 public: 454 357 this(File input) 455 358 {