Index: src/game.d ================================================================== --- src/game.d +++ src/game.d @@ -100,10 +100,11 @@ char[][] data; Pos robot; Pos lift; int waterproof; + // TODO: immutable Pos[char] tr_target; Pos[][char] tr_source; Map clone() const { return new Map(this); } this(in Map m) { @@ -110,10 +111,12 @@ foreach(s; m.data) this.data ~= s.dup; this.robot = m.robot.clone(); 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(string[] raw_data, string[string] params, char[char] trampo) { int width = 0; @@ -143,11 +146,11 @@ this.waterproof = params.get("Waterproof", "5").to!int(); foreach(fr,to; trampo) { tr_target[fr] = tr_pos[to]; if(to !in tr_source) tr_source[to] = []; - tr_source[to] ~= tr_pos[to]; + tr_source[to] ~= tr_pos[fr]; } } const @property { int H() { return data.length; } @@ -228,10 +231,17 @@ } else if(dy==0 && '*'==this[y+dy,x+dx] && ' '==this[y+dy*2,x+dx*2]) { this[y,x]=' '; this[y+dy,x+dx]='R'; this[y+dy*2,x+dx*2]='*'; robot = new Pos(y+dy,x+dx); + } else if('A'<=this[y+dy,x+dx] && this[y+dy,x+dx]<='I') { + this[y,x]=' '; + Pos tp = tr_target[this[y+dy,x+dx]]; + foreach(p; tr_source[this[tp]]) + this[p] = ' '; + this[tp] = 'R'; + robot = tp; } if( update() ) dead = true; return tuple(lambda,dead); } Index: src/gui.d ================================================================== --- src/gui.d +++ src/gui.d @@ -76,10 +76,11 @@ this.render['.'] = "♒"; this.render['\\'] = "λ"; this.render['R'] = "☃"; this.render['D'] = "☠"; this.render['L'] = "☒"; + this.render['O'] = "☐"; foreach(c,tp; g.map.tr_target) { char d = g.map[tp]; this.render[c] = [cast(dchar)('㋀'+d-'1')].to!string(); } foreach(char c; '1'..':') this.render[c] = [cast(dchar)('㏠'+c-'1')].to!string();