(self, widget)
| 169 | return not (x > w - 1 or y > h - 1 or x < 0 or y < 0) |
| 170 | |
| 171 | def new_game(self, widget): |
| 172 | self.time_count = 0 |
| 173 | self.mine_table = gui.Table(margin='0px auto') # 900, 450 |
| 174 | self.mine_matrix = self.build_mine_matrix(8, 8, 5) |
| 175 | self.mine_table.empty() |
| 176 | |
| 177 | for x in range(0, len(self.mine_matrix[0])): |
| 178 | row = gui.TableRow() |
| 179 | for y in range(0, len(self.mine_matrix)): |
| 180 | row.append(self.mine_matrix[y][x]) |
| 181 | self.mine_matrix[y][x].onclick.do(self.mine_matrix[y][x].check_mine) |
| 182 | self.mine_table.append(row) |
| 183 | |
| 184 | # self.mine_table.append_from_list(self.mine_matrix, False) |
| 185 | self.main_container.append(self.mine_table, key="mine_table") |
| 186 | self.check_if_win() |
| 187 | self.set_root_widget(self.main_container) |
| 188 | |
| 189 | def build_mine_matrix(self, w, h, minenum): |
| 190 | """random fill cells with mines and increments nearest mines num in adiacent cells""" |
no test coverage detected