public Player(bool startTurn, KeyPublisher keyPub) { this.white = startTurn; team = white == true ? "+" : "-"; keyPub.RaiseKeyEvent += KeyEventHandler; isActive = startTurn; }
//https://en.wikipedia.org/wiki/Chess_piece_relative_value if you ever want to implement an AI this could help /// <summary> /// The default chess piece constructor. /// </summary> /// <param name="colour_">The colour of the chess piece.</param> /// <param name="team_">The team of the chess piece, true for white, false for black.</param> /// <param name="mapLocation_">The start location on the map.</param> /// <param name="ID">The ID of the chess piece. The constructor does nothing to ensure the ID is unique.</param> public ChessPiece(byte[] colour_, bool team_, int[] mapLocation_, string ID, KeyPublisher keyPub, CapturePublisher capPub) { Colour = colour_; SetTeam(team_); MapLocation = mapLocation_; this.ID = ID; LocationUpdate(); MapMatrix.Map[mapLocation[0], mapLocation[1]] = ID; teamIcon = ID.Split(':')[0]; keyPub.RaiseKeyEvent += KeyEventHandler; capPub.RaiseCaptureEvent -= CaptureEventHandler; //might help capPub.RaiseCaptureEvent += CaptureEventHandler; }
/// <summary> /// The constructor for the rook chess piece. /// </summary> /// <param name="colour_">The colour of the chess piece.</param> /// <param name="team_">The team of the chess piece.</param> /// <param name="spawnLocation_">The start location of the chess piece.</param> /// <param name="ID">The ID of the chess piece.</param> public Rook(byte[] colour_, bool team_, int[] spawnLocation_, string ID, KeyPublisher keyPub, CapturePublisher capPub) : base(colour_, team_, spawnLocation_, ID, keyPub, capPub) { Design = new string[] { "^^^", "|=|", "-R-" }; mostImportantDesignPart = new byte[] { 1, 2 }; DesignResizer(); Draw(); directions = new int[][] { new int[] { -1, 0 }, new int[] { 1, 0 }, new int[] { 0, 1 }, new int[] { 0, -1 } }; }
// https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance /// <summary> /// The constructor for the pawn chess piece. /// </summary> /// <param name="colour_">The colour of the chess piece.</param> /// <param name="team_">The team of the chess piece.</param> /// <param name="spawnLocation_">The start location of the chess piece.</param> /// <param name="ID">The ID of the chess piece.</param> public Pawn(byte[] colour_, bool team_, int[] spawnLocation_, string ID, KeyPublisher keyPub, CapturePublisher capPub) : base(colour_, team_, spawnLocation_, ID, keyPub, capPub) { Design = new string[] { " - ", " | ", "-P-" }; moveDirection = team ? (sbyte)-1 : (sbyte)1; mostImportantDesignPart = new byte[] { 1, 2 }; DesignResizer(); Draw(); promotions.Add("knight", 4); promotions.Add("rook", 5); promotions.Add("bishop", 3); promotions.Add("queen", 2); directions = new int[][] { new int[] { 0, moveDirection } }; canPromoted = true; }
/// <summary> /// The constructor for the bishop chess piece. /// </summary> /// <param name="colour_">The colour of the chess piece.</param> /// <param name="team_">The team of the chess piece.</param> /// <param name="spawnLocation_">The start location of the chess piece.</param> /// <param name="ID">The ID of the chess piece.</param> public Bishop(byte[] colour_, bool team_, int[] spawnLocation_, string ID, KeyPublisher keyPub, CapturePublisher capPub) : base(colour_, team_, spawnLocation_, ID, keyPub, capPub) { Design = new string[] { $"_{Settings.CVTS.DEC.DEC_Active}{Settings.CVTS.DEC.DEC_Plus_Minus}{Settings.CVTS.DEC.DEC_Deactive}_", $"{Settings.CVTS.DEC.DEC_Active}{Settings.CVTS.DEC.DEC_Vertical_Line}{Settings.CVTS.DEC.DEC_Deactive}O{Settings.CVTS.DEC.DEC_Active}{Settings.CVTS.DEC.DEC_Vertical_Line}{Settings.CVTS.DEC.DEC_Deactive}", $"-B-" }; mostImportantDesignPart = new byte[] { 1, 2 }; DesignResizer(); Draw(); directions = new int[][] { new int[] { -1, -1 }, new int[] { -1, 1 }, new int[] { 1, -1 }, new int[] { 1, 1 } }; }
/// <summary> /// The constructor for the knight chess piece. /// </summary> /// <param name="colour_">The colour of the chess piece.</param> /// <param name="team_">The team of the chess piece.</param> /// <param name="spawnLocation_">The start location of the chess piece.</param> /// <param name="ID">The ID of the chess piece.</param> public Knight(byte[] colour_, bool team_, int[] spawnLocation_, string ID, KeyPublisher keyPub, CapturePublisher capPub) : base(colour_, team_, spawnLocation_, ID, keyPub, capPub) { Design = new string[] { " ^_", " |>", "-k-" }; mostImportantDesignPart = new byte[] { 1, 2 }; DesignResizer(); Draw(); directions = new int[][] { new int[] { 1, 2 }, new int[] { 2, 1 }, new int[] { -1, -2 }, new int[] { -2, -1 }, new int[] { 1, -2 }, new int[] { 2, -1 }, new int[] { -1, 2 }, new int[] { -2, 1 } }; }