Check-in [9d983af88c]
Not logged in
Overview
SHA1 Hash:9d983af88c6b1dd870c859839021fcab1b60b77b
Date: 2012-07-15 10:58:08
User: kinaba
Comment:Hige parsing and rendering.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Added maps/beard1.map version [bb6926793a51311a]

1 +########## 2 +#** \\\\# 3 +#.R.. # 4 +# \ ..*\# 5 +#! ..*!# 6 +#### # # 7 +#\\... # L 8 +#\\.W... # 9 +#\\. # 10 +########## 11 + 12 +Growth 15 13 +Razors 0

Added maps/beard2.map version [2e942009c89717d7]

1 +############################## 2 +#R...........................# 3 +#.........................W..# 4 +#..\\\\\\\\\\\\\\\\\\\\\\\\..# 5 +#............................# 6 +#..*****.*\...*...*...*****..# 7 +#..*\....*\....*\*..*.\\*\\..# 8 +#..*\....****..!*!......*....# 9 +#..*\....*\....*\*..*...*....# 10 +#..*\....*\...*...*.....*....# 11 +#............................# 12 +#..\\\\\\\\\\\\\\\\\\\\\\\\..# 13 +#................ ..... .....# 14 +#................ W....L# 15 +############################## 16 + 17 +Growth 25 18 +Razors 10 19 +Flooding 20

Added maps/beard3.map version [1dcab340493857d0]

1 + ################ 2 + #*****#!! 1 # 3 + #..\..# # 4 +#########\\\\ # .\\\. # 5 +#.............# * # 6 +#.. .\\\#..!..#\** # 7 +#.. LW\\#W ..##### #### 8 +#..R\\\\#.. ..*\*\*W...# 9 +#.......A.. ...\.\...\\# 10 +#.......... ** # 11 +############....\.###### 12 + #.....!# 13 + ######## 14 + 15 +Growth 10 16 +Trampoline A targets 1

Added maps/beard4.map version [b62967eb47a5f507]

1 +#################### 2 +#W\\!#\\\**.\#W\\\W# 3 +##*######..###..\\\# 4 +#.......\.R ###...\# 5 +#####.###.#.......## 6 +#.......#.#\####.### 7 +#\\##\###\#\\#...#.L 8 +#\##\.###.####.#.#.# 9 +#\W#####.....###.W.# 10 +####\\...\\\...#.#.# 11 +#W*######.######.#.# 12 +#\\\\\\\\\.........# 13 +############\###\### 14 +#\\.. *..........\\# 15 +#W... #.........##W# 16 +####################

Modified src/game.d from [1b2e4ad2dae20251] to [06258bf9d419d24b].

84 84 assert( 1 == w.level(3) ); 85 85 assert( 1 == w.level(4) ); 86 86 assert( 1 == w.level(5) ); 87 87 } 88 88 89 89 //////////////////////////////////////////////////////////////////////////////// 90 90 91 +class Hige 92 +{ 93 + public immutable int pace; 94 + mixin DeriveCreate; 95 + mixin DeriveCompare; 96 + mixin DeriveShow; 97 + Hige clone() const { return cast(Hige)this; } 98 + 99 + static load(string[string] params) 100 + { 101 + return new Hige(params.get("Growth", "25").to!int()); 102 + } 103 + 104 + bool is_growing_turn(int turn) const 105 + { 106 + return pace ? turn%pace == pace-1 : false; 107 + } 108 + 109 + int until_rise(int turn) const 110 + { 111 + return pace ? pace-turn%pace : int.max; 112 + } 113 +} 114 + 115 +//////////////////////////////////////////////////////////////////////////////// 116 + 91 117 class Map 92 118 { 93 119 mixin DeriveShow; 94 120 95 121 static Map load(string[] raw_data, string[string] params, char[char] trampo) 96 122 { 97 123 // TODO: choose optimal representation. ................................................................................ 101 127 char[][] data; 102 128 Pos robot; 103 129 Pos lift; 104 130 int waterproof; 105 131 // TODO: immutable 106 132 Pos[char] tr_target; 107 133 Pos[][char] tr_source; 134 + const(Hige) hige; 135 + int razor; 108 136 109 137 Map clone() const { return new Map(this); } 110 138 this(in Map m) { 111 139 foreach(s; m.data) 112 140 this.data ~= s.dup; 113 141 this.robot = m.robot.clone(); 114 142 this.lift = m.lift.clone(); 115 143 this.waterproof = m.waterproof; 116 144 this.tr_target = cast(Pos[char])m.tr_target; 117 145 this.tr_source = cast(Pos[][char])m.tr_source; 146 + this.hige = m.hige.clone(); 147 + this.razor = m.razor; 118 148 } 119 149 120 150 this(string[] raw_data, string[string] params, char[char] trampo) 121 151 { 122 152 int width = 0; 123 153 foreach(r; raw_data) 124 154 width = max(width, r.length); ................................................................................ 146 176 147 177 this.waterproof = params.get("Waterproof", "5").to!int(); 148 178 foreach(fr,to; trampo) { 149 179 tr_target[fr] = tr_pos[to]; 150 180 if(to !in tr_source) tr_source[to] = []; 151 181 tr_source[to] ~= tr_pos[fr]; 152 182 } 183 + 184 + this.hige = Hige.load(params); 185 + this.razor = params.get("Razors", "0").to!int(); 153 186 } 154 187 155 188 const @property { 156 189 int H() { return data.length; } 157 190 int W() { return data[0].length; } 158 191 } 159 192 ................................................................................ 385 418 // TODO: when adding members, take care of clone(). 386 419 // TODO: fix this poor design. 387 420 388 421 @property const { 389 422 long score() { return lambda*25L*(1+exit_bonus) - turn; } 390 423 int water_level() { return water.level(turn); } 391 424 int water_until_rise() { return water.until_rise(turn); } 425 + int hige_until_rise() { return map.hige.until_rise(turn); } 392 426 bool cleared() { return exit_bonus>0; } 393 427 int hp() { return map.waterproof - under_water; } 394 428 long score_if_abort_now() { return lambda*25*(1+max(1,exit_bonus)) - turn; } 395 429 } 396 430 } 397 - 398 -unittest 399 -{ 400 - Game.load(["###","...","#RL"], ["xxx":"yyy"]); 401 -}

Modified src/gui.d from [19a06a471eb23a83] to [3be06eef4f2a58fa].

64 64 this.colors['.'] = Color(255,191,127); 65 65 this.colors['*'] = Color(255,127,127); 66 66 this.colors['R'] = Color(128,128,0); 67 67 this.colors['d'] = Color(255,0,0); 68 68 this.colors['\\'] = 69 69 this.colors['L'] = 70 70 this.colors['O'] = Color(127,255,127); 71 - this.colors['W'] = Color(204,229,255); 71 + this.colors['w'] = Color(204,229,255); 72 + this.colors['W'] = 73 + this.colors['!'] = Color(159,159,159); 72 74 foreach(char c; 'A'..'J') this.colors[c] = Color(142,142,255); 73 75 foreach(char c; '1'..':') this.colors[c] = Color(255,142,255); 74 76 this.render['#'] = "■"; 75 77 this.render['*'] = "✹"; 76 78 this.render['.'] = "♒"; 77 79 this.render['\\'] = "λ"; 78 80 this.render['R'] = "☃"; 79 81 this.render['d'] = "☠"; 80 82 this.render['L'] = "☒"; 81 83 this.render['O'] = "☐"; 84 + this.render['W'] = "ꔣ"; 85 + this.render['!'] = "✄"; 82 86 foreach(c,tp; g.map.tr_target) { 83 87 char d = g.map[tp]; 84 - this.render[c] = [cast(dchar)('☢'+d-'1')].to!string();/*㋀㏠*/ 88 + this.render[c] = [cast(dchar)('☢'+d-'1')].to!string(); 85 89 } 86 90 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('☢'+c-'1')].to!string(); 87 91 this.paint ~= (Control c, PaintEventArgs ev) { 88 92 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientSize.width,this.clientSize.height)); 89 93 }; 90 94 } 91 95 ................................................................................ 95 99 int scrH = this.clientSize.height; 96 100 97 101 // Fill bg. 98 102 graphicContext.fillRectangle(this.backColor, Rect(0,0,scrW,scrH)); 99 103 100 104 // Fill water. 101 105 int w = g.water_level(); 102 - graphicContext.fillRectangle(this.colors['W'], Rect(0, scrH-cell*w-1, scrW, cell*w+1)); 106 + graphicContext.fillRectangle(this.colors['w'], Rect(0, scrH-cell*w-1, scrW, cell*w+1)); 103 107 104 108 // Paint map. 105 109 for(int y=1; y<=g.map.H; ++y) 106 110 for(int x=1; x<=g.map.W; ++x) { 107 111 Rect r = Rect(cell*(x-1), scrH-cell*y, cell, cell); 108 112 char c = g.map[y,x]; 109 113 if( c != ' ' ) { ................................................................................ 110 114 if( c == 'R' && g.dead ) 111 115 c = 'd'; 112 116 graphicContext.drawText(this.render[c], font, this.colors[c], r); 113 117 } 114 118 } 115 119 116 120 // Update textual info. 117 - this.text = .text("Score: ", g.score, " Air: ", g.hp, " Tide: ", g.water_until_rise); 121 + this.text = .text( 122 + "Score: ", g.score, 123 + " Air: ", g.hp, 124 + " Tide: ", g.water_until_rise, 125 + " Wadler: ", g.hige_until_rise, 126 + " Razor: ", g.map.razor); 118 127 invalidate(); 119 128 } 120 129 121 130 private: 122 131 void setup_keyhandling() 123 132 { 124 133 noMessageFilter();

Modified src/util.d from [783554bf667412ed] to [0665970b47ba63ed].

19 19 this.tupleof = params; 20 20 } 21 21 } 22 22 23 23 template DeriveCompare() 24 24 { 25 25 override: 26 - bool opEquals(Object rhs) 26 + bool opEquals(Object rhs) const 27 27 { 28 28 return tuple(this.tupleof) == tuple((cast(typeof(this))rhs).tupleof); 29 29 } 30 30 31 - int opCmp(Object rhs) 31 + int opCmp(Object rhs) const 32 32 { 33 33 return tuple(this.tupleof).opCmp(tuple((cast(typeof(this))rhs).tupleof)); 34 34 } 35 35 36 - hash_t toHash() 36 + hash_t toHash() const 37 37 { 38 38 hash_t v = 0; 39 39 foreach(mem; this.tupleof) { 40 40 v *= 11; 41 41 static if(__traits(compiles, v^=mem)) 42 42 v ^= mem; 43 43 else ................................................................................ 46 46 return v; 47 47 } 48 48 } 49 49 50 50 template DeriveShow() 51 51 { 52 52 override: 53 - string toString() 53 + string toString() const 54 54 { 55 55 string str = text(typeof(this).stringof, "("); 56 56 foreach(i,mem; this.tupleof) { 57 57 if(i) str ~= ", "; 58 58 str = text(str, this.tupleof[i].stringof[5..$], ":", mem); 59 59 } 60 60 return str ~ ")"; 61 61 } 62 62 }