Game/Pieces/Piece.cs
/// <summary>
/// Calculates the attack line of sight to the target
/// Ghost targets are still able to attack when moved but can't be blocked by other pieces
/// Attack line includes attacking pieces coords
/// </summary>
/// <param name="board"></param>
/// <param name="op"></param>
/// <param name="rotation"></param>
/// <param name="corner"></param>
/// <returns></returns>
Calculates the attack line of sight to the target
Ghost targets are still able to attack when moved but can't be blocked by other pieces
Attack line includes attacking pieces coords
Calculates the attack line of sight to the target Ghost targets are still able to attack when moved but can ' t be blocked by other pieces Attack line includes attacking pieces coords
private List<AttackCoord> GetAttackLine(Tile[] board, Func<int, int, int> op, int rotation, int corner)
        {
            List<AttackCoord> attackList = new List<AttackCoord>();
            bool finished = false;
            bool outOfBounds = false;
            bool isAttackBlockable = false;
            while (!finished)
            {
                Coords coordinate = (Coords) op((int) Coords, rotation);
                if (!ValidCoordinate(board, coordinate, corner) || coordinate.Column() == corner)
                {
                    outOfBounds = true;
                    rotation--;
                    continue;
                }
                if (board.HasPawnOnTile(coordinate))
                {
                    if (outOfBounds && board[(int) coordinate].Piece.EPiece == EPiece.King)
                        isAttackBlockable = true;
                    if(board[(int) coordinate].Piece == this)
                        finished = true;
                }
                attackList.Add(new AttackCoord(coordinate, isAttackBlockable));
                rotation = outOfBounds ? rotation - 1 : rotation + 1;
            }
            return attackList.Distinct().ToList();
        }
private List < AttackCoord > GetAttackLine ( Tile [ ] board , Func < int , int , int > op , int rotation , int corner ) { List < AttackCoord > attackList = new List < AttackCoord > ( ) ; bool finished = false ; bool outOfBounds = false ; bool isAttackBlockable = false ; while ( ! finished ) { Coords coordinate = ( Coords ) op ( ( int ) Coords , rotation ) ; if ( ! ValidCoordinate ( board , coordinate , corner ) || coordinate . Column ( ) == corner ) { outOfBounds = true ; rotation -- ; continue ; } if ( board . HasPawnOnTile ( coordinate ) ) { if ( outOfBounds && board [ ( int ) coordinate ] . Piece . EPiece == EPiece . King ) isAttackBlockable = true ; if ( board [ ( int ) coordinate ] . Piece == this ) finished = true ; } attackList . Add ( new AttackCoord ( coordinate , isAttackBlockable ) ) ; rotation = outOfBounds ? rotation - 1 : rotation + 1 ; } return attackList . Distinct ( ) . ToList ( ) ; }
Calculates the attack line of sight to the target
Ghost targets are still able to attack when moved but can't be blocked by other pieces
Attack line includes attacking pieces coords
Calculates the attack line of sight to the target Ghost targets are still able to attack when moved but can ' t be blocked by other pieces Attack line includes attacking pieces coords
None
board
Tile[]
None
op
Func<int, int, int>
None
rotation
int
None
corner
int
None