/* Takes a piece value, generates a pseudo piece and uses it to get the corresponding style of movement. The style contains the directions the piece can go (dirs) and how many times (maxIters). */ public static MovementStyle getMovementStyle(EGamePieces piece) { return new MovementStyle(new Piece(piece)); }
/* Represents a Game piece object. All that a piece consists of is its value and a MovedOnce property which is false until the piece is moved for the first time. This property is only relevant for the Pawn pieces and is only updated by the model when the piece moves. */ public Piece(EGamePieces val) { this.Val = val; this.MovedOnce = false; }
/* Takes a piece identifier and returns the image/icon for that piece in a picturebox component. Ready for placement on the View board component. The click handler is registered to the piece also. */ private PictureBox getClickableGuiPiecee(EGamePieces mPiece) { PictureBox pb = new PictureBox(); pb.Name = "pb"; pb.Size = new Size(50, 50); pb.Image = gamePieces[mPiece]; pb.SizeMode = PictureBoxSizeMode.Zoom; pb.Click += OnTileClick; return pb; }
/* Takes a piece value, generates a pseudo piece and uses it to get the corresponding style of capture movement. The style contains the directions the piece can go (dirs) and how many times (maxIters). */ public static CaptureStyle getCaptureStyle(EGamePieces piece) { return new CaptureStyle(new Piece(piece)); }
/* Takes a piece identifier and returns the image/icon for that piece in a picturebox component. Ready for placement on the View board component. There is no click handler registered so this may be used for the promotionSelection dialog (gets a different click handler) or the captured display. */ public static PictureBox getGuiPiece(EGamePieces mPiece) { PictureBox pb = new PictureBox(); pb.Name = "pb"; pb.Size = new Size(50, 50); pb.Image = gamePieces[mPiece]; pb.SizeMode = PictureBoxSizeMode.Zoom; return pb; }
/* Same as GetPieceRay but takes a pawn piece and returns the diagonal attack rays rather than the vertical pawn movement ray.*/ public List<List<Tuple<int, int>>> GetPieceRayPawnCapture(EGamePieces piece, Tuple<int, int> location) { if (rayArrayPawnCapture == null) throw new Exception("ray array (pawns) noy instantiated"); int pieceIndex = (piece == EGamePieces.WhitePawn) ? 0 : 1; return rayArrayPawnCapture[pieceIndex][location.Item1, location.Item2]; }
/* Takes a piece and a y,x board location and returns one List containing a List for each valid direction of movement. Each of these lists contains a sequence of board locations that the piece could potentially move to (from that starting location) */ public List<List<Tuple<int, int>>> GetPieceRay(EGamePieces piece, Tuple<int, int> location) { if (rayArray == null) throw new Exception("ray array not instantiated"); return rayArray[(int)piece][location.Item1, location.Item2]; }
/* Takes a piece value and adds it to the PiecesCapd List. This method is overridden by the ChessPositionModel which adds a CapturedChanged event.*/ protected virtual void addToCaptured(EGamePieces piece) { this.PiecesCapd.Add(piece); }
/* Same as the ChessPosition implementation but this also fires the CapturedChanged event so the View can update accordingly */ protected override void addToCaptured(EGamePieces piece) { this.PiecesCapd.Add(piece); OnCapturedChanged(EventArgs.Empty); }