Repository: fabiobatalha/chess_master

Issue:
Implement threatening zone for panws
Implement a method to delivery the threatening zone for panws

Discussion:

Patch:
diff --git a/chess.py b/chess.py
index 8c57bc4..c9d7287 100644
--- a/chess.py
+++ b/chess.py
@@ -101,6 +101,19 @@ class Bishop(Pieces):
     def __str__(self):
 
         return self.NAME
+    
+    def threatening_zone(self, max_size):
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+
+        Arguments:
+        max_size -- integer that defines de boundary limits of the board.
+        """
+        
+        import pdb; pdb.set_trace()
+        
+        self.position
 
 class Kinight(Pieces):
 
@@ -110,6 +123,14 @@ class Kinight(Pieces):
 
         return self.NAME
 
+    def threatening_zone():
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+        """
+        
+        pass
+
 class King(Pieces):
 
     NAME = 'king'
@@ -118,6 +139,14 @@ class King(Pieces):
 
         return self.NAME
 
+    def threatening_zone(self):
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+        """
+        
+        pass
+
 class Pawn(Pieces):
 
     NAME = 'pawn'
@@ -126,6 +155,24 @@ class Pawn(Pieces):
 
         return self.NAME
 
+    def threatening_zone(self, max_size):
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+
+        Arguments:
+        max_size -- integer that defines de boundary limits of the board.
+        """
+        zone = []
+
+        x, y = self.position
+
+        zone.append((x+1, y+1))
+        zone.append((x-1, y+1))
+
+        return [(x, y) for x, y in zone if x in range(max_size) and y in range(max_size)]
+
+
 class Queen(Pieces):
 
     NAME = 'queen'
@@ -134,6 +181,14 @@ class Queen(Pieces):
 
         return self.NAME
 
+    def threatening_zone():
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+        """
+        
+        pass
+
 class Rook(Pieces):
 
     NAME = 'rook'
@@ -141,3 +196,11 @@ class Rook(Pieces):
     def __str__(self):
 
         return self.NAME
+
+    def threatening_zone():
+        """
+        Get the current position of the piece and produce a list of threathening
+        places in the board.
+        """
+        
+        pass


Test patch:
diff --git a/tests/tests.py b/tests/tests.py
index 24ff9a6..acb7e6d 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -89,6 +89,84 @@ class TestsChessMasterPiece(unittest.TestCase):
         with self.assertRaises(ValueError):
             pawn.set_position((1, 2, 4,))
 
+
+    def test_pawn_threatening_zone(self):
+        """
+        Testing pawn when the piece is able to threatening other piece in both
+        sides.
+        """
+
+        pawn = chess.Pawn((4,0))
+
+        expected = [
+            (3,1),
+            (5,1)
+        ]
+
+        self.assertEqual(
+            sorted(pawn.threatening_zone(8)), sorted(expected)
+        )
+
+
+    def test_pawn_threatening_x_boundary_left(self):
+        """
+        Testing boundary where the pawn can not move to the left
+        """
+
+        pawn = chess.Pawn((0,0))
+
+        expected = [
+            (1,1)
+        ]
+
+        self.assertEqual(
+            sorted(pawn.threatening_zone(8)), sorted(expected)
+        )
+
+    def test_pawn_threatening_x_boundary_right(self):
+        """
+        Testing boundary where the pawn can not move to the right
+        """
+
+        pawn = chess.Pawn((7,0))
+
+        expected = [
+            (6,1)
+        ]
+
+        self.assertEqual(
+            sorted(pawn.threatening_zone(8)), sorted(expected)
+        )
+
+    def test_pawn_threatening_zone_y_boundary(self):
+        """
+        Testing boundary where the pawn can not move forward
+        """
+
+        pawn = chess.Pawn((4,7))
+
+        expected = []
+
+        self.assertEqual(
+            sorted(pawn.threatening_zone(8)), sorted(expected)
+        )
+
+    def test_pawn_threatening_zone_y_boundary_last_move(self):
+        """
+        Testing boundary where the pawn can make your last move forward
+        """
+
+        pawn = chess.Pawn((4,6))
+
+        expected = [
+            (3,7),
+            (5,7)
+        ]
+
+        self.assertEqual(
+            sorted(pawn.threatening_zone(8)), sorted(expected)
+        )
+
 class TestsChessMasterBoard(unittest.TestCase):
 
     def test_put_1_piece(self):