Initial commit of MPLABX version
This commit is contained in:
commit
d80b03bdf0
10 changed files with 251 additions and 0 deletions
45
Piece.hpp
Normal file
45
Piece.hpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* File: Piece.hpp
|
||||
* Author: amr
|
||||
*
|
||||
* Created on July 30, 2025, 9:21 PM
|
||||
*/
|
||||
|
||||
#ifndef PIECE_HPP
|
||||
#define PIECE_HPP
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "Board.hpp"
|
||||
class Board;
|
||||
|
||||
enum PieceType { PAWN, BISHOP, KNIGHT, ROOK, QUEEN, KING, EMPTY };
|
||||
enum PieceColour { PIECE_WHITE, PIECE_BLACK, PIECE_EMPTY };
|
||||
enum Rank { R1 = 1, R2 = 2, R3 = 3, R4 = 4, R5 = 5, R6 = 6, R7 = 7, R8 = 8 };
|
||||
enum File { A, B, C, D, E, F, G, H };
|
||||
struct Square {
|
||||
Rank rank;
|
||||
File file;
|
||||
};
|
||||
|
||||
class Piece {
|
||||
protected:
|
||||
PieceColour colour;
|
||||
|
||||
public:
|
||||
// methods
|
||||
Piece(PieceColour pColour) : colour(pColour) {}
|
||||
virtual ~Piece() {}
|
||||
virtual std::vector<std::pair<int, int>> getLegalMoves(int x, int y, const Board &board) const;
|
||||
PieceColour getColour() const { return colour; }
|
||||
};
|
||||
|
||||
class King : public Piece {
|
||||
public:
|
||||
King(PieceColour colour) : Piece(colour) {}
|
||||
std::vector<std::pair<int, int>> getLegalMoves(int x, int y, const Board &board) const override;
|
||||
};
|
||||
#endif // PIECE_HPP
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue