Files
wnmj-normal/Classes/Games/DDZ/DDZ_GameLogic.h
2026-03-03 13:56:44 +08:00

150 lines
4.6 KiB
C++

#ifndef GAME_DDZ_LOGIC_HEAD_FILE
#define GAME_DDZ_LOGIC_HEAD_FILE
#pragma once
#include "Types.h"
#include "Macro.h"
#include "CardDefine.h"
#include "DDZ_CMD.h"
//////////////////////////////////////////////////////////////////////////////////
//排序类型
#define DDZ_ST_ORDER 1 //大小排序
#define DDZ_ST_COUNT 2 //数目排序
#define DDZ_ST_CUSTOM 3 //自定排序
//数值掩码
#define DDZ_MASK_COLOR 0xF0 //花色掩码
#define DDZ_MASK_VALUE 0x0F //数值掩码
//逻辑类型
#define DDZ_CT_ERROR 0 //错误类型
#define DDZ_CT_SINGLE 1 //单牌类型
#define DDZ_CT_DOUBLE 2 //对牌类型
#define DDZ_CT_THREE 3 //三条类型
#define DDZ_CT_SINGLE_LINE 4 //单连类型
#define DDZ_CT_DOUBLE_LINE 5 //对连类型
#define DDZ_CT_THREE_LINE 6 //三连类型
#define DDZ_CT_THREE_TAKE_ONE 7 //三带一单
#define DDZ_CT_THREE_TAKE_TWO 8 //三带一对
#define DDZ_CT_FOUR_TAKE_ONE 9 //四带两单
#define DDZ_CT_FOUR_TAKE_TWO 10 //四带两对
#define DDZ_CT_BOMB_CARD 11 //炸弹类型
#define DDZ_CT_MISSILE_CARD 12 //火箭类型
#define DDZ_ST_HIDE 100
#define DDZ_ST_DEAL_CARD 101
#define DDZ_ST_PASS 102
#define DDZ_ST_CALL 103
#define DDZ_ST_CLICK_CARD 104
#define DDZ_ST_OUT_CARD 105
#define DDZ_ST_LEFT_ONE_CARD 106
#define DDZ_ST_WIN 107
#define DDZ_ST_LOSE 108
//////////////////////////////////////////////////////////////////////////////////
//分析结构
struct tagAnalyseResult
{
uint8 cbBlockCount[4]; //扑克数目
uint8 cbCardData[4][DDZ_MAX_COUNT]; //扑克数据
};
//出牌结果
struct tagOutCardResult
{
uint8 cbCardCount; //扑克数目
uint8 cbResultCard[DDZ_MAX_COUNT]; //结果扑克
};
//分布信息
struct tagDistributing
{
uint8 cbCardCount; //扑克数目
uint8 cbDistributing[15][6]; //分布信息
};
//搜索结果
struct tagSearchCardResult
{
uint8 cbSearchCount; //结果数目
uint8 cbCardCount[DDZ_MAX_COUNT]; //扑克数目
uint8 cbResultCard[DDZ_MAX_COUNT][DDZ_MAX_COUNT]; //结果扑克
};
//////////////////////////////////////////////////////////////////////////////////
//游戏逻辑类
class CDDZGameLogic
{
//变量定义
protected:
static const uint8 m_cbCardData[DDZ_FULL_COUNT]; //扑克数据
//函数定义
public:
//构造函数
CDDZGameLogic();
//析构函数
virtual ~CDDZGameLogic();
//类型函数
public:
//获取类型
uint8 GetCardType(const uint8 cbCardData[], uint8 cbCardCount);
//获取数值
uint8 GetCardValue(uint8 cbCardData) { return cbCardData&DDZ_MASK_VALUE; }
//获取花色
uint8 GetCardColor(uint8 cbCardData) { return cbCardData&DDZ_MASK_COLOR; }
//控制函数
public:
//混乱扑克
void RandCardList(uint8 cbCardBuffer[], uint8 cbBufferCount);
//排列扑克
void SortCardList(uint8 cbCardData[], uint8 cbCardCount, uint8 cbSortType);
//删除扑克
bool RemoveCardList(const uint8 cbRemoveCard[], uint8 cbRemoveCount, uint8 cbCardData[], uint8 cbCardCount);
//删除扑克
bool RemoveCard(const uint8 cbRemoveCard[], uint8 cbRemoveCount, uint8 cbCardData[], uint8 cbCardCount);
//排列扑克
void SortOutCardList(uint8 cbCardData[], uint8 cbCardCount);
//逻辑函数
public:
//逻辑数值
uint8 GetCardLogicValue(uint8 cbCardData);
//对比扑克
bool CompareCard(const uint8 cbFirstCard[], const uint8 cbNextCard[], uint8 cbFirstCount, uint8 cbNextCount);
//出牌搜索
uint8 SearchOutCard( const uint8 cbHandCardData[], uint8 cbHandCardCount, const uint8 cbTurnCardData[], uint8 cbTurnCardCount,
tagSearchCardResult *pSearchCardResult );
//同牌搜索
uint8 SearchSameCard( const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbSameCardCount,
tagSearchCardResult *pSearchCardResult );
//连牌搜索
uint8 SearchLineCardType( const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbBlockCount, uint8 cbLineCount,
tagSearchCardResult *pSearchCardResult );
//带牌类型搜索(三带一,四带一等)
uint8 SearchTakeCardType( const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbSameCount, uint8 cbTakeCardCount,
tagSearchCardResult *pSearchCardResult );
//搜索飞机
uint8 SearchThreeTwoLine( const uint8 cbHandCardData[], uint8 cbHandCardCount, tagSearchCardResult *pSearchCardResult );
//内部函数
public:
//构造扑克
uint8 MakeCardData(uint8 cbValueIndex, uint8 cbColorIndex);
//分析扑克
void AnalysebCardData(const uint8 cbCardData[], uint8 cbCardCount, tagAnalyseResult & AnalyseResult);
//分析分布
void AnalysebDistributing(const uint8 cbCardData[], uint8 cbCardCount, tagDistributing & Distributing);
};
//////////////////////////////////////////////////////////////////////////////////
#endif