@@ -9,13 +9,19 @@ { private char[][] data; bool dead = false; bool cleared = false; + int water = 0; + int flooding = 0; + int water_proof = 10; + int underwater = 0; + int flooding_counter = 0; this(File input) { - foreach(s; input.byLine()) - data ~= s.chomp.dup; + string line; + while( (line=input.readln().chomp()).length ) + data ~= line.dup; int width = 0; foreach(s; data) width = max(width, s.length); @@ -31,8 +37,20 @@ // vertical sentinel char[] sen = new char[width+2]; sen[] = '#'; data = sen.dup ~ data ~ sen; + + // flooding + water = H-1; + string wfws = input.readln().chomp() ~ " "; + wfws ~= input.readln().chomp() ~ " "; + wfws ~= input.readln().chomp(); + string[] wfw = wfws.split(); + if(wfw.length==6) { + water = H-1 - wfw[1].to!int(); + flooding = wfw[3].to!int(); + water_proof = wfw[5].to!int(); + } } @property const { @@ -133,8 +151,27 @@ next[y][x] = 'O'; } } data = next; + + if(flooding) { + flooding_counter ++; + if(flooding_counter == flooding) { + flooding_counter = 0; + water --; + } + bool wa = false; + for(int y=water; y+1 water_proof) + dead = true; + } + if(!wa) + underwater = 0; + } } } class MyForm : Form @@ -157,8 +194,9 @@ { int Z = min(this.clientSize.width/(m.W-2), this.clientSize.height/(m.H-2)); Font font = new Font("MS Gothic", Z-4); Graphics g = ev.graphics; + g.fillRectangle(Color(0,233,255), Rect(0,Z*(m.water-1),this.clientSize.width,this.clientSize.height-(Z*(m.water-1)))); for(int y=1; y+1