|
|
|
|
#pragma once
|
|
|
|
|
#include "graphics.h"
|
|
|
|
|
#include <vector>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
struct ChessPos
|
|
|
|
|
{
|
|
|
|
|
int row;
|
|
|
|
|
int col;
|
|
|
|
|
|
|
|
|
|
ChessPos(int r = 0, int c = 0):row{ r }, col{ c } {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
CHESS_WHITE = -1,//<2F><>
|
|
|
|
|
CHESS_BLACK = 1//<2F><>
|
|
|
|
|
}chess_kind_t;
|
|
|
|
|
class Chess
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD>Ա
|
|
|
|
|
private:
|
|
|
|
|
IMAGE chessBlackImg;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IMAGE chessWhiteImg;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
int gradeSize;//<2F><><EFBFBD>̴<EFBFBD>С
|
|
|
|
|
int margin_x;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD>
|
|
|
|
|
int margin_y;//<2F><><EFBFBD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD>߽<EFBFBD>
|
|
|
|
|
double chessSize;//<2F><><EFBFBD>Ӵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD><CCB8><EFBFBD>С<EFBFBD><D0A1>
|
|
|
|
|
ChessPos lastPos;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷֲ<D3B7><D6B2><EFBFBD><EFBFBD><EFBFBD>chessMap[<5B><>][<5B><>]
|
|
|
|
|
vector<vector<int>>chessMap{};
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ӷ<EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
bool playerFlag;//true<75><65>false<73><65>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
void updateGameMap(ChessPos* pos);
|
|
|
|
|
|
|
|
|
|
//ʤ<><CAA4><EFBFBD>ж<EFBFBD>
|
|
|
|
|
bool checkWin();
|
|
|
|
|
public:
|
|
|
|
|
Chess(int gradeSize, int marginX, int marginY, double chessSize);
|
|
|
|
|
//<2F><><EFBFBD>̳<EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
//<2F>ж<EFBFBD><D0B6><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чλ<D0A7><CEBB>
|
|
|
|
|
bool clickBoard(int x, int y, ChessPos *pos);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
void ChessMove(ChessPos *pos, chess_kind_t kind);
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>̴<EFBFBD>С
|
|
|
|
|
int getGradeSize();
|
|
|
|
|
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ʤ
|
|
|
|
|
bool checkOver();
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡָ<C8A1><D6B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
int getChessData(ChessPos* pos);
|
|
|
|
|
int getChessData(int row, int col);
|
|
|
|
|
};
|
|
|
|
|
|