MDGSF Software Engineer

[vk_mj] 麻将基础类型设计

2017-05-19

//最大的游戏玩家数
#define MAX_GAME_PLAY_USER 4

//兰州麻将中牌数
#define CARD_MAX_COUNT 136

//最多的手牌数量为14张
#define MAX_HANDCARD_NUM 14

//最多的固定牌数量
#define MAX_FIXCARD_NUM 4

//序数牌的张数: 1~9
#define MAX_XUSHU_NUM 9

//风牌的张数: 东南西北
#define MAX_FENG_NUM 4

//箭牌的张数: 中发白
#define MAX_JIAN_NUM 3

//最大杠操作,因为手牌最多14张,一个杠要用4张牌,所以手中最多同时存在3个杠。
#define MAX_GANG_COUNT 3

//一张非真实性的牌,填充假数据之用
#define INVALID_CARD 0xFF

//一个非真实性的玩家椅子号
#define INVALID_CHAIR 0x7F


#define NUM_MASK 0x0F
#define TYPE_MASK 0xF0
#define CardNum(c) ((c) & NUM_MASK)
#define CardType(c) (((c) & TYPE_MASK)>>4)

#define MJ_TYPE_WAN 0 //万, 0-8,各4张,共36张
#define MJ_TYPE_TIAO 1 //条, 0-8,各4张,共36张
#define MJ_TYPE_BING 2 //饼, 0-8,各4张,共36张
#define MJ_TYPE_FENG 3 //东南西北各4张,共16张
#define MJ_TYPE_JIAN 4 //中发白  各4张,共12张
#define MJ_TYPE_FLOWER 5 //花

//牌的种类数量(万,条,饼,风,箭)
#define MJ_TYPE_NUM 5

//牌数
#define MAX_ALL_GANG_COUNT 34

//最大牌面值
#define MAX_CARD 0x43

#define MAX_CARD_ARRAY_SIZE (MAX_CARD + 1)

#define WIK_NULL 0x00 //没有类型
#define WIK_LEFT 0x01 //左吃类型
#define WIK_CENTER 0x02 //中吃类型
#define WIK_RIGHT 0x04 //右吃类型

typedef uint8_t Card;

const Card g_CardWangData[] =
{
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,//万
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
    0x00
};

const Card g_CardTiaoData[] =
{
    0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,//条
    0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
    0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
    0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
    0x00
};

const Card g_CardTongData[] =
{
    0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,//筒
    0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
    0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
    0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
    0x00
};

const Card g_CardFengData[] =
{
    0x31, 0x32, 0x33, 0x34,//风
    0x31, 0x32, 0x33, 0x34,
    0x31, 0x32, 0x33, 0x34,
    0x31, 0x32, 0x33, 0x34,
    0x00
};

const Card g_CardJianData[] =
{
    0x41, 0x42, 0x43,  //箭
    0x41, 0x42, 0x43,
    0x41, 0x42, 0x43,
    0x41, 0x42, 0x43,
    0x00
};

const Card g_CardHuaData[] = { 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x00 /* 花 */ };

const Card g_CardGangData[] =
{
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,//万
    0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,//条
    0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,//筒
    0x31, 0x32, 0x33, 0x34,//风
    0x41, 0x42, 0x43 //箭
};

#define CardYiWan 0x01  //一万
#define CardYaoJi 0x11  //一条,幺鸡
#define CardYiTong 0x21  //一筒

#define CardJiuWan 0x09  //九万
#define CardJiuTiao 0x19  //九条
#define CardJiuTong 0x29  //九筒


//东南西北
#define CardDONG 0x31
#define CardNAN 0x32
#define CardXI 0x33
#define CardBEI 0x34

//中发白
#define CardZHONG 0x41
#define CardFA 0x42
#define CardBAI 0x43

weixingongzhonghao

Comments

Content