def test_increase_x_and_y(self): cell = Point(0, 0, "br") cell.increase(1, 1) self.assertNotEqual(cell.get_y(), 0)
def play(self, selected_figure, new_position): self.view_board() motion = self._make_motion(selected_figure, new_position) figure_info = self.get_figure_from_board(selected_figure) selected_figure.set_info(figure_info) if self._invalid_selection(selected_figure): return False # target means would be taken target_figure = self.get_figure_from_board(new_position) # pawn special check...... if selected_figure.get_type() == 'p': if selected_figure.get_color() == 'b': motion.prepare_first_move_black_pawn(selected_figure) if self._get_with_black_pawn(motion, new_position): self.set_end_of_the_game(target_figure) self._attack_with_pawn(new_position, selected_figure, "bq") return True elif self.invalid_move_black_pawn(motion, new_position): print("invalid black pawn's move") return False else: motion.prepare_first_move_white_pawn(selected_figure) if self._get_with_white_pawn(motion, new_position): self.set_end_of_the_game(target_figure) self._attack_with_pawn( new_position, selected_figure, "wq") print("take with white pown") return True elif self.invalid_move_white_pawn(motion, new_position): print("invalid white pawn's move") return False # end pawn..... if self._checking_the_move_is_correct(selected_figure, motion): step_x, step_y = self._set_step_to_move(motion) prepare_moving = Point(step_x, step_y) if selected_figure.get_type() != 'n': while self.waiting_to_finish_this_turn(prepare_moving, motion): next_cell = self._set_next_cell(selected_figure, prepare_moving) if self._try_jump_yours(next_cell, selected_figure): print("try to jumb over your figure!!! Try again") return False elif self._try_jump_enemy(next_cell, selected_figure, prepare_moving, motion): print("try to jumb over enemy figure!!! Try again") return False prepare_moving.increase(step_x, step_y) elif self.knight_invalid_move(new_position, selected_figure): print("It is your figure!!! Try again") return False self._finally_move(new_position, selected_figure) self.set_end_of_the_game(target_figure) return True else: return False