public void PlaceMarker(Player owner) { // Create the piece that belongs here if (owner == Player.Black) { // if the owner of this piece is the black player, then put a black piece m_occupyingpiece = new CheckerMarker(Player.Black); } else if (owner == Player.Red) { // or if the owner is the red player, then make a red piece m_occupyingpiece = new CheckerMarker(Player.Red); } else { // otherwise, there is no valid owner, therefore no piece m_occupyingpiece = null; } }
public void SwapPieces(BoardSpace b) { // store the current occupying piece CheckerMarker temp = b.OccupyingPiece; // set the other board spaces piece to this ones b.SetPiece(this.m_occupyingpiece); // set this space's occupying piece to the one // the other board space contained m_occupyingpiece = temp; // if this space can king red pieces and the new piece is a red piece, then king the piece if (!this.Empty() && this.m_ableToKing == CanKing.YesRed && this.m_occupyingpiece.Owner == Player.Red) { this.OccupyingPiece.KingMe(); } else // or if this space can king a black piece and it has a black piece, king that piece if (!this.Empty() && this.m_ableToKing == CanKing.YesBlack && this.m_occupyingpiece.Owner == Player.Black) { this.OccupyingPiece.KingMe(); } else // of if the other space can king black pieces and it has a black piece, king the other space's piece if (!b.Empty() && b.AbleToKing == CanKing.YesBlack && b.OccupyingPiece.Owner == Player.Black) { b.OccupyingPiece.KingMe(); } else // or if the other space has a red piece and it can king red pieces, king the other space's piece if (!b.Empty() && b.AbleToKing == CanKing.YesRed && b.OccupyingPiece.Owner == Player.Red) { b.OccupyingPiece.KingMe(); } }
public void SetPiece(CheckerMarker c) { // set this space's occupying piece as // the one passed in this.m_occupyingpiece = c; }
public void RemovePiece() { // set the occupying piece to null so garbage collection // takes care of it m_occupyingpiece = null; }