public bool burn(int x, int y)
        {
            Console.WriteLine("Burning: " + x + "," + y);
            Console.WriteLine(BOARD.getPiece(x, y).getClass2());
            if (BOARD.getPiece(x, y).getClass2() == DeflexionPiece.getClass())
            {
                String deleted_type   = ((DeflexionPiece)BOARD.getPiece(x, y)).get_type();
                int    deleted_player = ((DeflexionPiece)BOARD.getPiece(x, y)).getPlayer();
                if (BOARD.removePiece(x, y))
                {
                    if (deleted_type.Equals(DeflexionPiece.PHAROAH, StringComparison.CurrentCultureIgnoreCase))
                    {
                        GAME_ENDED = true;
                        if (deleted_player == PLAYER1)
                        {
                            WINNER = PLAYER2;
                        }
                        else if (deleted_player == PLAYER2)
                        {
                            WINNER = PLAYER1;
                        }
                        else
                        {
                            Console.WriteLine("Invalid player - burn end game");
                        }

                        Console.WriteLine("End game. Winner: " + WINNER);
                    }
                    CONT_ID++;
                    return(true);
                }
            }
            return(false);
        }
 public bool canRotate(int x, int y, int Player)
 {
     if (BOARD.validCell(x, y))
     {
         if (BOARD.getPiece(x, y).getClass2() == DeflexionPiece.getClass())
         {
             if (((DeflexionPiece)BOARD.getPiece(x, y)).get_type().Equals(DeflexionPiece.DJED, StringComparison.CurrentCultureIgnoreCase) || ((DeflexionPiece)BOARD.getPiece(x, y)).get_type().Equals(DeflexionPiece.PYRAMID, StringComparison.CurrentCultureIgnoreCase))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public void auxDisparLaser(int x, int y, String laser_orientation)
        {
            if (BOARD.validCell(x, y))
            {
                Console.Write(x + "," + y + " " + laser_orientation + " ");
                LAST_MESSAGE += x + "," + y + " " + laser_orientation + ";";
                Piece P1 = BOARD.getPiece(x, y);
                if (P1.getClass2() == NullPiece.getClass())
                {
                    if (laser_orientation.Equals("N", StringComparison.CurrentCultureIgnoreCase))
                    {
                        auxDisparLaser(x - 1, y, laser_orientation);
                    }
                    else if (laser_orientation.Equals("S", StringComparison.CurrentCultureIgnoreCase))
                    {
                        auxDisparLaser(x + 1, y, laser_orientation);
                    }
                    else if (laser_orientation.Equals("E", StringComparison.CurrentCultureIgnoreCase))
                    {
                        auxDisparLaser(x, y + 1, laser_orientation);
                    }
                    else if (laser_orientation.Equals("W", StringComparison.CurrentCultureIgnoreCase))
                    {
                        auxDisparLaser(x, y - 1, laser_orientation);
                    }
                    else
                    {
                        Console.WriteLine("ERROR invalid laser orientation - aux_dispar_laser");
                    }
                }
                else if (P1.getClass2() == DeflexionPiece.getClass())
                {
                    String type = ((DeflexionPiece)P1).get_type();
                    if ((type.Equals(DeflexionPiece.PHAROAH, StringComparison.CurrentCultureIgnoreCase)) || (type.Equals(DeflexionPiece.OBELISK, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        burn(x, y);
                        LAST_MESSAGE += P1.getString();
                    }
                    else
                    {
                        String ori = ((DeflexionPiece)P1).get_orientation();

                        String tag1 = "";
                        String tag2 = "";
                        if (laser_orientation.Equals("N", StringComparison.CurrentCultureIgnoreCase))
                        {
                            tag1 = "NE";
                            tag2 = "NW";
                        }
                        else if (laser_orientation.Equals("S", StringComparison.CurrentCultureIgnoreCase))
                        {
                            tag1 = "SE";
                            tag2 = "SW";
                        }
                        else if (laser_orientation.Equals("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            tag1 = "NE";
                            tag2 = "SE";
                        }
                        else if (laser_orientation.Equals("W", StringComparison.CurrentCultureIgnoreCase))
                        {
                            tag1 = "SW";
                            tag2 = "NW";
                        }

                        if (ori.Equals(tag1, StringComparison.CurrentCultureIgnoreCase) || ori.Equals(tag2, StringComparison.CurrentCultureIgnoreCase))
                        {
                            burn(x, y);
                            LAST_MESSAGE += P1.getString();
                        }
                        else
                        {
                            if ((laser_orientation.Equals("N", StringComparison.CurrentCultureIgnoreCase)) || (laser_orientation.Equals("S", StringComparison.CurrentCultureIgnoreCase)))
                            {
                                if (ori.Equals("NE", StringComparison.CurrentCultureIgnoreCase) || ori.Equals("SE", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    auxDisparLaser(x, y + 1, "E");
                                }
                                else if (ori.Equals("NW", StringComparison.CurrentCultureIgnoreCase) || ori.Equals("SW", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    auxDisparLaser(x, y - 1, "W");
                                }
                                else
                                {
                                    Console.WriteLine("ERROR invalid deflexion: " + laser_orientation + " - " + ori + "- aux_dispar_laser");
                                }
                            }
                            else if ((laser_orientation.Equals("E", StringComparison.CurrentCultureIgnoreCase)) || (laser_orientation.Equals("W", StringComparison.CurrentCultureIgnoreCase)))
                            {
                                if (ori.Equals("NE", StringComparison.CurrentCultureIgnoreCase) || ori.Equals("NW", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    auxDisparLaser(x - 1, y, "N");
                                }
                                else if (ori.Equals("SE", StringComparison.CurrentCultureIgnoreCase) || ori.Equals("SW", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    auxDisparLaser(x + 1, y, "S");
                                }
                                else
                                {
                                    Console.WriteLine("ERROR invalid deflexion2: " + laser_orientation + " - " + ori + "- aux_dispar_laser");
                                }
                            }
                            else
                            {
                                Console.WriteLine("ERROR invalid deflexion3: " + laser_orientation + " - " + ori + "- aux_dispar_laser");
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("ERROR invalid class piece type - aux_dispar_laser");
                }
            }
            else
            {
                Console.WriteLine("No piece burned.");
            }
        }
 public override bool rotate(int x, int y, String direction, int Player)
 {
     if (ACTUAL_PLAYER == Player)
     {
         if (canRotate(x, y, Player))
         {
             DeflexionPiece P1  = ((DeflexionPiece)BOARD.getPiece(x, y));
             String         ori = P1.get_orientation();
             if (direction.Equals(CLOCKWISE, StringComparison.CurrentCultureIgnoreCase))
             {
                 if (ori.Equals("NE", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("SE");
                 }
                 else if (ori.Equals("SE", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("SW");
                 }
                 else if (ori.Equals("SW", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("NW");
                 }
                 else if (ori.Equals("NW", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("NE");
                 }
                 else
                 {
                     Console.WriteLine("Invalid orientation: " + ori);
                 }
             }
             else if (direction.Equals(ANTICLOCKWISE, StringComparison.CurrentCultureIgnoreCase) || direction.Equals(COUNTERCLOCKWISE, StringComparison.CurrentCultureIgnoreCase))
             {
                 if (ori.Equals("NE", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("NW");
                 }
                 else if (ori.Equals("SE", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("NE");
                 }
                 else if (ori.Equals("SW", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("SE");
                 }
                 else if (ori.Equals("NW", StringComparison.CurrentCultureIgnoreCase))
                 {
                     P1.update_orientation("SW");
                 }
                 else
                 {
                     Console.WriteLine("Invalid orientation: " + ori);
                 }
             }
             else
             {
                 Console.WriteLine("Invalid type of rotation.");
                 return(false);
             }
             Console.WriteLine("Deflexion rotation OK");
             BOARD.replacePiece(x, y, P1);
             CONFIRM_MOVE = true;
             endTurn(Player);
             return(true);
         }
     }
     return(false);
 }
        public override bool canMove(int x1, int y1, int x2, int y2, int Player)
        {
            Console.WriteLine("Deflexion can move: " + x1 + " " + x2 + " " + y1 + " " + y2 + " " + Player + " " + PLAYER1 + " " + PLAYER2 + " " + GAME_ENDED);
            if (GAME_ENDED)
            {
                return(false);
            }

            if (CONFIRM_MOVE)
            {
                return(false);
            }

            if ((Math.Abs(x2 - x1) > 1 || Math.Abs(y2 - y1) > 1))
            {
                return(false);
            }

            if ((Math.Abs(x2 - x1) == 0 && Math.Abs(y2 - y1) == 0))
            {
                return(false);
            }

            if (Player != ACTUAL_PLAYER)
            {
                return(false);
            }

            if (!BOARD.validCell(x1, y1) || !BOARD.validCell(x2, y2))
            {
                return(false);
            }

            if (BOARD.getPiece(x1, y1).getClass2() == NullPiece.getClass())
            {
                return(false);
            }

            if (BOARD.getPiece(x2, y2).getClass2() != NullPiece.getClass())
            {
                Console.WriteLine("Moving deflexion2.1");
                if (!((DeflexionPiece)BOARD.getPiece(x1, y1)).get_type().Equals(DeflexionPiece.DJED, StringComparison.CurrentCultureIgnoreCase))
                {
                    Console.WriteLine("Moving deflexion2.2");
                    return(false);
                }
                else
                {
                    Console.WriteLine("Moving deflexion2.3");
                    String temp_type = ((DeflexionPiece)BOARD.getPiece(x2, y2)).get_type();
                    if ((temp_type.Equals(DeflexionPiece.DJED)) || (temp_type.Equals(DeflexionPiece.PHAROAH, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        Console.WriteLine("Moving deflexion4");
                        return(false);
                    }
                }
            }

            if (BOARD.getPiece(x1, y1).getClass2() == NullPiece.getClass())
            {
                return(false);
            }

            DeflexionPiece P1 = (DeflexionPiece)BOARD.getPiece(x1, y1);

            Console.WriteLine(Player + " " + P1.getPlayer());
            if (P1.getPlayer() != Player)
            {
                return(false);
            }


            if ((y2 == 0) && (P1.getPlayer() == PLAYER2))
            {
                return(false);
            }

            if ((y2 == 9) && (P1.getPlayer() == PLAYER1))
            {
                return(false);
            }

            return(true);
        }