public override SoldierPiece Challenge(SoldierPiece piece) { ValidateChallenge(piece); if (piece is SoldierFlag) { return(SwapSoldierPiece(piece, this)); } return(base.Challenge(piece)); }
public override SoldierPiece Challenge(SoldierPiece piece) { ValidateChallenge(piece); if (piece is SoldierSpy) { return(SwapSoldierPiece(piece, this)); } if (piece is SoldierPrivate) { return(SwapSoldierPiece(this, piece)); } return(base.Challenge(piece)); }
public static List <SoldierPiece> CreateBoardSoldierPieces(SoldierPiece piece, int quantity) { List <SoldierPiece> pieces = new List <SoldierPiece>(); if (piece == null || quantity < 1) { return(pieces); } while (pieces.Count < quantity) { pieces.Add(piece); } return(pieces); }
public static List <SoldierPiece> CreateBoardSoldierPieces(SoldierPiece piece, int quantity) { List <SoldierPiece> pieces = new List <SoldierPiece>(); if (piece == null || quantity < 1) { return(pieces); } for (int i = 0; i < quantity; i++) { pieces.Add(piece); } return(pieces); }
public void RelocateSoldierPiece(BoardLocation fromLocation, BoardLocation toLocation) { SoldierPiece p = GetSoldierPiece(fromLocation); SoldierPiece p2 = GetSoldierPiece(toLocation); if (p is EmptyPiece) { throw new ApplicationException($"Location {fromLocation.Coordinates()} does not contain a piece to move."); } if (p2 is EmptyPiece) { p.CurrentLocation = toLocation; } else { throw new ApplicationException($"New location is not empty. {p2}"); } }
public void MoveSoldierPiece(BoardLocation fromLocation, BoardLocation toLocation) { SoldierPiece p = GetSoldierPiece(fromLocation); SoldierPiece p2 = GetSoldierPiece(toLocation); if (p is EmptyPiece) { throw new ApplicationException($"Location {fromLocation.Coordinates()} does not contain a piece to move."); } if (!(p2 is EmptyPiece)) { p.Challenge(p2); } else { p.Move(toLocation); } }
public void RemoveSoldierPiece(SoldierPiece piece) { piece.CurrentLocation = new BoardLocation(0, 0); piece.IsEliminated = true; }