Index: src/game.d ================================================================== --- src/game.d +++ src/game.d @@ -347,107 +347,10 @@ data = next; return dead; } } -//////////////////////////////////////////////////////////////////////////////// -/* -class Game -{ - mixin DeriveShow; - - static Game load(File input) - { - string[] raw_data; - string[string] params; - - // Raw map data; read until empty line. - for(string line; !(line=input.readln().chomp()).empty; ) - raw_data ~= line; - - // Additional commands; read until EOF. - char[char] trampo; - for(string line; !(line=input.readln()).empty; ) { - string[] ss = line.split(); - if( ss.length == 2 ) - params[ss[0]] = ss[1]; - if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="targets" ) - trampo[ss[1][0]] = ss[3][0]; - } - - return load(raw_data, params, trampo); - } - - static Game load(string[] raw_data, string[string] params, char[char] trampo = null) - { - return new Game(raw_data, params, trampo); - } - - this(string[] raw_data, string[string] params, char[char] trampo) - { - this.map = Map.load(raw_data, params, trampo); - this.water = Water.load(params); - } - - Game clone() const { return new Game(this); } - this(in Game g) { - map = g.map.clone(); - water = g.water.clone(); - turn = g.turn; - dead = g.dead; - lambda = g.lambda; - cleared = g.cleared; - under_water = g.under_water; - } - - void command(char c) - { - assert(c != 'A'); - if(dead || cleared) - return; - - // TODO: clarify the event order - Tuple!(int,bool) ld = map.command(c, turn); - if( map.cleared() ) { - cleared = true; - } - else { - lambda += ld[0]; - if( ld[1] ) - dead = true; - } - if(!cleared) { - if( map.robot.y <= water_level ) - ++under_water; - else - under_water = 0; - if( under_water > map.waterproof ) - dead = true; - } - turn += 1; - } - - Map map; - Water water; - int turn = 0; - bool dead = false; - int lambda = 0; - int under_water = 0; - bool cleared = false; - // TODO: when adding members, take care of clone(). - // TODO: fix this poor design. - - @property const { - long score() { return lambda*(dead ? 25L : cleared ? 75L : 50L) - turn; } - int water_level() { return water.level(turn); } - int water_until_rise() { return water.until_rise(turn); } - int hige_until_rise() { return map.hige.until_rise(turn); } - int hp() { return map.waterproof - under_water; } - } -} -*/ - //////////////////////////////////////////////////////////////////////////////// class Game { public: