#include<bits/stdc++.h>
#define PLAYERCOUNT 3
#define CARDSCOUNT 54
#define CURRENTPLAYER 0
#define VALUECOUNT 17
#define ERROR -1
using namespace std;
const char toFigure[]="34567890JQKA 2YZ";
enum COLOR{ //花色显示ASCII: 3~6
eHEART=3,//红桃
eDIAMOND,//方片
eCLUB, //草花
eSPADE //黑桃
};
class Card;
class CardsType;
class CardGroup;
class Player;
class Landlords;
class LastCards;
bool makeChoice(string tip);
bool cmp(Card* a,Card* b);
class Card{
public:
char figure;
COLOR color;
int value;
Card(char _figure,COLOR _color){
figure=_figure;
color=_color;
value=calValue();
}
int calValue(){
for(int i=0;toFigure[i];i++){
if(toFigure[i]==figure){
return i;
}
}
return ERROR;
}
void print(){
assert(value!=ERROR);
if(figure=='Z'){
cout<<"ZZ";
}else if(figure=='Y'){
cout<<"YY";
}else{
cout<<figure<<(char)color;
}
cout<<' ';
}
};
class CardsType{
public:
//为了规范查找对应牌的方法
//统一为3个参数cnt1、isContinuous、cnt2
int typeId;
string typeStr;
int cnt1,cnt2;
bool isContinuous;
CardsType(){
typeId=ERROR;
}
bool operator ==(const CardsType& other)const{
return this->typeId==other.typeId;
}
void init(char* _typeStr,int _typeId,int _cnt1,bool _isContinuous,int _cnt2){
cnt1=_cnt1;
isContinuous=_isContinuous;
cnt2=_cnt2;
typeStr=_typeStr;
typeId=_typeId;
}
};
class CardGroup{
public:
vector<Card*> cards;
CardsType type;
void calType(){
int i,n=cards.size();
//init(typeStr,typeId,cnt1,isContinuous,cnt2)
if(n==0){
type.init("不出",14,0,0,0);
return;
}
if(n==2&&cards[0]->value==15&&cards[1]->value==14){
type.init("王炸",0,0,0,0);
return;
}
//统计同点数牌有多少张
int cntFlag[VALUECOUNT]={0};
for(i=0;i<n;i++){
cntFlag[cards[i]->value]++;
}
//统计点数最多和最少的牌
int maxCnt=0,minCnt=4;
for(i=0;i<VALUECOUNT;i++){
if(maxCnt<cntFlag[i]){
maxCnt=cntFlag[i];
}
if(cntFlag[i]&&minCnt>cntFlag[i]){
minCnt=cntFlag[i];
}
}
if(n==4&&maxCnt==4){
type.init("炸蛋",1,4,0,0);
return;
}
if(n==1){
type.init("单牌",2,1,0,0);
return;
}
if(n==2&&maxCnt==2){
type.init("对子",3,2,0,0);
return;
}
if(n==3&&maxCnt==3){
type.init("三张 ",4,3,0,0);
return;
}
if(n==4&&maxCnt==3){
type.init("三带一",5,3,0,1);
return;
}
if(n==5&&maxCnt==3&&minCnt==2){
type.init("三带一对",6,3,0,2);
return;
}
if(n==6&&maxCnt==4){
type.init("四带二",7,4,0,1);
return;
}
if(n==8&&maxCnt==4&&minCnt==2){
type.init("四带二",8,4,0,2);
return;
}
if(n>=5&&maxCnt==1&&cards[0]->value==cards[n-1]->value+n-1){
type.init("顺子",9,1,1,0);
return;
}
if(n>=6&&maxCnt==2&&minCnt==2&&cards[0]->value==cards[n-1]->value+n/2-1){
type.init("连对",10,2,1,0);
return;
}
int fjCnt;//