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."); } }