www.pudn.com > Five_QT_by_CT.rar > gamelogic.h


#ifndef GAMELOGIC_HEADER
#define GAMELOGIC_HEADER

#include "stdio.h"
#include 
#include 

//记录每步的行棋信息de
class ChessRecordNode
{
public:
	QPoint mPoint;//棋盘的点
	int mTurn;//棋子颜色,约定,0白1黑
	ChessRecordNode()
	{
		mPoint=QPoint(-1,-1);
		mTurn=-1;
	}
	
};



class ChessRecord
{
public:
	ChessRecordNode mRecord[300];
	int mIndex;
	
	ChessRecord()
	{
		mIndex=0;
	}
	void AddRecord(QPoint p, int t)
	{
		mRecord[mIndex].mPoint=p;
		mRecord[mIndex].mTurn=t;
		mIndex++;
			
	}
	void clearRecord()
	{
		int i;
		for(i=0; i<=mIndex; i++)
		{
			mRecord[i].mPoint=QPoint(-1, -1);
			mRecord[i].mTurn=-1;
		}
		mIndex=0;	
	}
};



//游戏逻辑,判断合法性等
class GameLogic
{

public:
	char mGameState;//f-空闲 w-等待 p-下棋
	QString mMyside;
	QString mCurrentTurn;

	int mChessBoard[15][15];//0-白,1-黑,-1空
	ChessRecord mChessRecord;//行棋信息

	bool JudgeWin(int, int, int );       //根据当前步骤判断谁赢,side用QString,便于和别的类传递参数 
	bool CanPut(QPoint PutPos, int );	  //判断PutPos的落子是否合法
	bool PutNewChess(int x, int y, int k);
	QString getTurn();
	void setTurn(QString );
	int CountStones(int x, int y ,int side, int direction);	
	void clearChessInfo();
	GameLogic();
};

#endif