def was_into_check ( self ) -> bool : king = self . king ( not self . turn ) return king is not None and self . is_attacked_by ( self . turn , king )
a check funtion in python for turned based game
Checks if the king of the other side is attacked . Such a position is not valid and could only be reached by an illegal move .
def was_into_check(self) -> bool:
        """
        Checks if the king of the other side is attacked. Such a position is not
        valid and could only be reached by an illegal move.
        """
        king = self.king(not self.turn)
        return king is not None and self.is_attacked_by(self.turn, king)