@@ -8,8 +8,9 @@ class Map { private char[][] data; bool dead = false; + bool cleared = false; this(File input) { foreach(s; input.byLine()) @@ -51,8 +52,9 @@ int command_L() { return move(0, -1); } int command_U() { return move(-1, 0); } int command_D() { return move(+1, 0); } int wait() { if(dead)return 0; update(); return -1; } + int abort() { if(dead)return 0; cleared=true; return gained*25; } int move(int dy, int dx) { foreach(y,s; data) foreach(x,c; s) @@ -69,10 +71,12 @@ if(data[y+dy][x+dx]=='\\') { score += 25; ++gained; } - if(data[y+dy][x+dx]=='O') + if(data[y+dy][x+dx]=='O') { score += gained*50; + cleared = true; + } if(data[y+dy][x+dx]==' ' || data[y+dy][x+dx]=='.' || data[y+dy][x+dx]=='\\' || data[y+dy][x+dx]=='O') { data[y][x]=' '; @@ -210,11 +214,21 @@ score += m.wait(); write("W"); stdout.flush(); break; + case Keys.A: + score += m.abort(); + write("A"); + stdout.flush(); + break; default: break; } + if(m.cleared) { + writeln(); + writeln("Score: ", score); + Application.exit(); + } this.text = .text("Score: ", score); invalidate(); } }