private Move getSingleEatMoveOfSoldier(Soldier i_Soldier, eVertical i_VerticalDirection, eHorizontal i_HorizontalDirection) { Location currentLocation = i_Soldier.Location; Location opponentSoldierLocation = new Location(currentLocation.Row + (int)i_VerticalDirection, currentLocation.Col + (int)i_HorizontalDirection); Move eatMove = null; if (locationExistInBoard(opponentSoldierLocation)) { Cell cell = GetCellByLocation(opponentSoldierLocation); if (!cell.IsCellEmpty() && cell.Soldier.Owner != i_Soldier.Owner) { Location jumppingLocation = new Location(opponentSoldierLocation.Row + (int)i_VerticalDirection, opponentSoldierLocation.Col + (int)i_HorizontalDirection); if (locationExistInBoard(jumppingLocation) && GetCellByLocation(jumppingLocation).IsCellEmpty()) { eatMove = new Move(currentLocation, jumppingLocation); } } } return(eatMove); }
private void addNextLocationIfPossible(Soldier i_Soldier, eVertical i_VerticalDirection, eHorizontal i_HorizontalDirection, ref List <Location> io_Locations) { Location nextLocation = new Location(i_Soldier.Location.Row + (int)i_VerticalDirection, i_Soldier.Location.Col + (int)i_HorizontalDirection); if (locationExistInBoard(nextLocation)) { io_Locations.Add(nextLocation); } }
private void addEatMoveIfExist(Soldier i_Soldier, eVertical i_VerticalDirection, eHorizontal i_HorizontalDirection, ref List <Move> io_EatMoves) { Move eatMove = getSingleEatMoveOfSoldier(i_Soldier, i_VerticalDirection, i_HorizontalDirection); if (eatMove != null) { io_EatMoves.Add(eatMove); } }