|
849 | 849 | return this;
|
850 | 850 | };
|
851 | 851 |
|
852 |
| - |
853 | 852 | /**
|
854 | 853 | * Determines if there is a widget in the row and col given. Or if the
|
855 | 854 | * HTMLElement passed as first argument is the player.
|
|
877 | 876 | * @return {Boolean} Returns true or false.
|
878 | 877 | */
|
879 | 878 | fn.is_player_in = function(col, row) {
|
880 |
| - var c = this.cells_occupied_by_player; |
| 879 | + var c = this.cells_occupied_by_player || {}; |
881 | 880 | return $.inArray(col, c.cols) >= 0 && $.inArray(row, c.rows) >= 0;
|
882 | 881 | };
|
883 | 882 |
|
|
1125 | 1124 | var upper_rows = [];
|
1126 | 1125 | var min_row = 10000;
|
1127 | 1126 |
|
| 1127 | + if (widget_grid_data.col < this.player_grid_data.col && |
| 1128 | + (widget_grid_data.col + widget_grid_data.size_y - 1) > |
| 1129 | + (this.player_grid_data.col + this.player_grid_data.size_y - 1) |
| 1130 | + ) { |
| 1131 | + return false; |
| 1132 | + }; |
| 1133 | + |
1128 | 1134 | /* generate an array with columns as index and array with upper rows
|
1129 | 1135 | * empty as value */
|
1130 | 1136 | this.for_each_column_occupied(widget_grid_data, function(tcol) {
|
|
1134 | 1140 | var r = p_bottom_row + 1;
|
1135 | 1141 |
|
1136 | 1142 | while (--r > 0) {
|
1137 |
| - if (this.is_occupied(tcol, r) && !this.is_player(tcol, r)) { |
1138 |
| - break; |
| 1143 | + if (this.is_widget(tcol, r) && !this.is_player_in(tcol, r)) { |
| 1144 | + if (!grid_col[r].is(widget_grid_data.el)) { |
| 1145 | + break; |
| 1146 | + }; |
1139 | 1147 | }
|
1140 | 1148 |
|
1141 | 1149 | if (!this.is_player(tcol, r) &&
|
1142 |
| - !this.is_placeholder_in(tcol, r) |
1143 |
| - ) { |
| 1150 | + !this.is_placeholder_in(tcol, r) && |
| 1151 | + !this.is_player_in(tcol, r)) { |
1144 | 1152 | upper_rows[tcol].push(r);
|
1145 |
| - } |
| 1153 | + }; |
1146 | 1154 |
|
1147 |
| - if (r < min_row ) { |
| 1155 | + if (r < min_row) { |
1148 | 1156 | min_row = r;
|
1149 | 1157 | }
|
1150 | 1158 | }
|
|
1186 | 1194 | while (++r <= p_bottom_row ) {
|
1187 | 1195 | var common = true;
|
1188 | 1196 | $.each(upper_rows, function(col, rows) {
|
1189 |
| - if (rows && $.inArray(r, rows) === -1) { |
| 1197 | + if ($.isArray(rows) && $.inArray(r, rows) === -1) { |
1190 | 1198 | common = false;
|
1191 | 1199 | }
|
1192 | 1200 | });
|
|
1211 | 1219 | }
|
1212 | 1220 | }
|
1213 | 1221 |
|
1214 |
| - |
1215 | 1222 | return new_row;
|
1216 | 1223 | };
|
1217 | 1224 |
|
|
1306 | 1313 | * @return {HTMLElements} Returns a jQuery collection of HTMLElements.
|
1307 | 1314 | */
|
1308 | 1315 | fn.on_stop_overlapping_column = function(col) {
|
1309 |
| - this.set_player(); |
| 1316 | + this.set_player(col, false); |
1310 | 1317 |
|
1311 | 1318 | var self = this;
|
1312 | 1319 | this.for_each_widget_below(col, this.cells_occupied_by_player.rows[0],
|
|
1324 | 1331 | * @return {HTMLElements} Returns a jQuery collection of HTMLElements.
|
1325 | 1332 | */
|
1326 | 1333 | fn.on_stop_overlapping_row = function(row) {
|
1327 |
| - this.set_player(); |
| 1334 | + this.set_player(false, row); |
1328 | 1335 |
|
1329 | 1336 | var self = this;
|
1330 | 1337 | var cols = this.cells_occupied_by_player.cols;
|
|
1370 | 1377 | var $w = $(widget);
|
1371 | 1378 | var wgd = $w.coords().grid;
|
1372 | 1379 | var can_go_up = self.can_go_widget_up(wgd);
|
1373 |
| - |
1374 | 1380 | if (can_go_up && can_go_up !== wgd.row) {
|
1375 | 1381 | self.move_widget_to($w, can_go_up);
|
1376 | 1382 | }
|
|
1637 | 1643 | var $w = this.is_widget(col, prev_row);
|
1638 | 1644 | if (this.is_occupied(col, prev_row) ||
|
1639 | 1645 | this.is_player(col, prev_row) ||
|
1640 |
| - this.is_placeholder_in(col, prev_row) |
| 1646 | + this.is_placeholder_in(col, prev_row) || |
| 1647 | + this.is_player_in(col, prev_row) |
1641 | 1648 | ) {
|
1642 | 1649 | result = false;
|
1643 | 1650 | return true; //break
|
|
0 commit comments