/*
2011.05.19-20.
The Game Of Poker For Socket
Daun...
*/
/*
-카드 -
1~13 : 하트
14~26 : 다이아
27~39 : 스페이드
40~52 : 크로바
-무늬-
1:하트
2:다이아
3:스페이드
4:크로바
-숫자-
1~10 : 1~10
11 : J
12 : Q
13 : K
*/
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
int myRandCard[5]={0}, num[13]={0}, shape[4]={0};
cout << " J : 11, Q : 12 , K : 13"<<endl;
cout << "shape[0] : ♥ shape[1] : ◆ shape[2] : ♠ shape[3] : ♣"<<"\n\n";
while(1)
{
for (int i = 0 ; i < 5 ; i++)
myRandCard[i]=rand()%52+1;
int count=0;
for(int i = 0 ; i < 5 ; i++)
for(int a = i+1 ; a < 5 ; a++)
if(myRandCard[a]==myRandCard[i])
count++;
if(count ==0)
break;
} //랜덤으로 카드를 뽑음!
for (int i = 0 ; i < 5 ; i++)
{
if( myRandCard[i]/13 == 0)
{
shape[0]++;
num[myRandCard[i]%13]++;
cout << "뽑은 카드는 ♥" << myRandCard[i]%13 +1<<"입니다"<<endl;
}
else if(myRandCard[i]/13 == 1)
{
shape[1]++;
num[myRandCard[i]%13]++;
cout << "뽑은 카드는 ◆"<<myRandCard[i]%13 +1 << "입니다."<<endl;
}
else if(myRandCard[i]/13 == 2)
{
shape[2]++;
num[myRandCard[i]%13]++;
cout << "뽑은 카드는 ♠"<<myRandCard[i]%13 +1 << "입니다."<<endl;
}
else
{
shape[3]++;
num[myRandCard[i]%13]++;
cout <<"뽑은 카드는 ♣"<<myRandCard[i]%13 +1 << "입니다."<<endl;
}
} //카드의 무늬 판별!+카드보여주기->저거 뽑은카드 숫자보여주는거 따로 함수써서 하고싶당! 13같은거는 K로 나타나도록!
// for(int i = 0 ; i < 4 ; i++)
// cout << "shape[" << i << "] : " << shape[i] << "\t";
//
// cout << endl;
//
// for(int i = 0 ; i < 13 ; i++)
// cout << "num[" << i+1 << "] : " << num[i] << "\t"; //카드 숫자새는거 제대로 된거인지 확인용이엿음!!
int two=0, three=0, four=0;
for(int i = 0 ; i < 13 ; i++)
{
if(num[i]==2)
two++;
else if(num[i]==3)
three++;
else if(num[i]==4)
four++;
}
int flush = 0;
for(int i = 0 ; i < 4 ; i++)
if(shape[i]==5)
flush++;
cout << endl;
if(four ==1)
cout << "포카드 (Four Card)"<<endl;
else if(three == 1 && two == 1)
cout << "풀하우스 (Full house)"<<endl;
else if(flush == 1 )
cout << "플러쉬 (Flush)"<<endl;
else if(three ==1)
cout << "트리플(Triple)"<<endl;
else if(two == 2)
cout << "투페어(Two Pair)"<<endl;
else if(two == 1)
cout << "원페어(One Pair)"<<endl;
else
{
int sum = 0;
if(num[0]==1)
{
for(int i = 0 ; i < 5 ; i++)
if(num[i]==1)
sum++;
if(sum == 5)
cout << "백스트레이트(Back Straight)"<<endl;
}
sum = 0 ;
if(num[0]==1)
{
for(int i = 9 ; i < 13 ; i++)
if(num[i]==1)
sum++;
if(sum==4)
cout << "마운틴 (Mountain)"<<endl;
}
else
{
for (int i = 1 ; i < 9 ; i ++)
{
sum = 0 ;
for(int a = i ; a < i + 5 ; a++)
if(num[a]==1)
sum++;
if(sum == 5)
cout << "스트레이트 (Straight)" <<endl;
}
}
}
return 0;
}