@@ -87,8 +87,34 @@ } //////////////////////////////////////////////////////////////////////////////// +class Hige +{ + public immutable int pace; + mixin DeriveCreate; + mixin DeriveCompare; + mixin DeriveShow; + Hige clone() const { return cast(Hige)this; } + + static load(string[string] params) + { + return new Hige(params.get("Growth", "25").to!int()); + } + + bool is_growing_turn(int turn) const + { + return pace ? turn%pace == pace-1 : false; + } + + int until_rise(int turn) const + { + return pace ? pace-turn%pace : int.max; + } +} + +//////////////////////////////////////////////////////////////////////////////// + class Map { mixin DeriveShow; @@ -104,8 +130,10 @@ int waterproof; // TODO: immutable Pos[char] tr_target; Pos[][char] tr_source; + const(Hige) hige; + int razor; Map clone() const { return new Map(this); } this(in Map m) { foreach(s; m.data) @@ -114,8 +142,10 @@ this.lift = m.lift.clone(); this.waterproof = m.waterproof; this.tr_target = cast(Pos[char])m.tr_target; this.tr_source = cast(Pos[][char])m.tr_source; + this.hige = m.hige.clone(); + this.razor = m.razor; } this(string[] raw_data, string[string] params, char[char] trampo) { @@ -149,8 +179,11 @@ tr_target[fr] = tr_pos[to]; if(to !in tr_source) tr_source[to] = []; tr_source[to] ~= tr_pos[fr]; } + + this.hige = Hige.load(params); + this.razor = params.get("Razors", "0").to!int(); } const @property { int H() { return data.length; } @@ -388,14 +421,10 @@ @property const { long score() { return lambda*25L*(1+exit_bonus) - 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); } bool cleared() { return exit_bonus>0; } int hp() { return map.waterproof - under_water; } long score_if_abort_now() { return lambda*25*(1+max(1,exit_bonus)) - turn; } } } - -unittest -{ - Game.load(["###","...","#RL"], ["xxx":"yyy"]); -}