122 lines
3.7 KiB
C++
122 lines
3.7 KiB
C++
#ifndef GAME_LOGIC_HEAD_FILE
|
|
#define GAME_LOGIC_HEAD_FILE
|
|
|
|
#pragma once
|
|
|
|
#include "Stdafx.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//排序类型
|
|
#define ST_ORDER 1 //大小排序
|
|
#define ST_COUNT 2 //数目排序
|
|
#define ST_CUSTOM 3 //自定排序
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//分析结构
|
|
struct tagAnalyseResult
|
|
{
|
|
BYTE cbBlockCount[4]; //扑克数目
|
|
BYTE cbCardData[4][MAX_COUNT]; //扑克数据
|
|
};
|
|
|
|
//出牌结果
|
|
struct tagOutCardResult
|
|
{
|
|
BYTE cbCardCount; //扑克数目
|
|
BYTE cbResultCard[MAX_COUNT]; //结果扑克
|
|
};
|
|
|
|
//分布信息
|
|
struct tagDistributing
|
|
{
|
|
BYTE cbCardCount; //扑克数目
|
|
BYTE cbDistributing[15][6]; //分布信息
|
|
};
|
|
|
|
//搜索结果
|
|
struct tagSearchCardResult
|
|
{
|
|
BYTE cbSearchCount; //结果数目
|
|
BYTE cbCardCount[MAX_COUNT]; //扑克数目
|
|
BYTE cbResultCard[MAX_COUNT][MAX_COUNT]; //结果扑克
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//游戏逻辑类
|
|
class CGameLogic
|
|
{
|
|
//变量定义
|
|
protected:
|
|
static const BYTE m_cbCardData[FULL_COUNT]; //扑克数据
|
|
static const BYTE m_cbGoodcardData[GOOD_CARD_COUTN]; //好牌数据
|
|
|
|
//函数定义
|
|
public:
|
|
//构造函数
|
|
CGameLogic();
|
|
//析构函数
|
|
virtual ~CGameLogic();
|
|
|
|
//类型函数
|
|
public:
|
|
//获取类型
|
|
BYTE GetCardType(const BYTE cbCardData[], BYTE cbCardCount);
|
|
//获取数值
|
|
BYTE GetCardValue(BYTE cbCardData) { return cbCardData&MASK_VALUE; }
|
|
//获取花色
|
|
BYTE GetCardColor(BYTE cbCardData) { return cbCardData&MASK_COLOR; }
|
|
|
|
//控制函数
|
|
public:
|
|
//混乱扑克
|
|
VOID RandCardList(BYTE cbCardBuffer[], BYTE cbBufferCount);
|
|
//排列扑克
|
|
VOID SortCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbSortType);
|
|
//排列扑克
|
|
VOID SortOutCardList(BYTE cbCardData[], BYTE cbCardCount);
|
|
//删除扑克
|
|
bool RemoveCardList(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount);
|
|
//删除扑克
|
|
bool RemoveCard(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount);
|
|
//删除扑克
|
|
bool RemoveCardEx(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount);
|
|
//得到好牌
|
|
void GetGoodCardData(BYTE cbGoodCardData[NORMAL_COUNT]);
|
|
|
|
//逻辑函数
|
|
public:
|
|
//逻辑数值
|
|
BYTE GetCardLogicValue(BYTE cbCardData);
|
|
//对比扑克
|
|
bool CompareCard(const BYTE cbFirstCard[], const BYTE cbNextCard[], BYTE cbFirstCount, BYTE cbNextCount);
|
|
//出牌搜索
|
|
BYTE SearchOutCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, const BYTE cbTurnCardData[], BYTE cbTurnCardCount,
|
|
tagSearchCardResult *pSearchCardResult );
|
|
//同牌搜索
|
|
BYTE SearchSameCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbSameCardCount,
|
|
tagSearchCardResult *pSearchCardResult );
|
|
//连牌搜索
|
|
BYTE SearchLineCardType( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbBlockCount, BYTE cbLineCount,
|
|
tagSearchCardResult *pSearchCardResult );
|
|
//带牌类型搜索(三带一,四带一等)
|
|
BYTE SearchTakeCardType( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbSameCount, BYTE cbTakeCardCount,
|
|
tagSearchCardResult *pSearchCardResult );
|
|
//搜索飞机
|
|
BYTE SearchThreeTwoLine( const BYTE cbHandCardData[], BYTE cbHandCardCount, tagSearchCardResult *pSearchCardResult );
|
|
|
|
//内部函数
|
|
public:
|
|
//构造扑克
|
|
BYTE MakeCardData(BYTE cbValueIndex, BYTE cbColorIndex);
|
|
//分析扑克
|
|
VOID AnalysebCardData(const BYTE cbCardData[], BYTE cbCardCount, tagAnalyseResult & AnalyseResult);
|
|
//分析分布
|
|
VOID AnalysebDistributing(const BYTE cbCardData[], BYTE cbCardCount, tagDistributing & Distributing);
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#endif |