2017. 6. 14. 14:02
콘솔기반의 간단한
배팅을 이용한 도박 게임입니다.
상대방의 카드보다 값이 높으면 졌었는지 이겼는지 기억이 안나네요.
하하....(땀땀)...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "AppleSeeU.h" | |
#include <iostream> | |
#include <time.h> | |
#include <conio.h> | |
using namespace std; | |
AppleSeeU::AppleSeeU() | |
{ | |
//cout << "Test Called First" << endl; | |
srand((unsigned int)time(NULL)); | |
int card[4][13]; | |
int card2[52]; | |
for (int i = 0; i < 52; i++) { | |
card2[i] = i + 1; | |
} | |
int cardCount = 1; | |
for (int i = 0; i < 4; i++) { | |
for (int j = 0; j < 13; j++) { | |
card[i][j] = cardCount++; | |
} | |
cardCount = 1; | |
} | |
int randomCard[3]; | |
int batting; | |
int myGold = 50000; | |
int gameCount = 1; | |
for (int i = 0; i < 50; i++) { | |
int dest = rand() % 52; | |
int sour = rand() % 52; | |
int temp = card2[dest]; | |
card2[dest] = card2[sour]; | |
card2[sour] = temp; | |
} | |
while (true) { | |
for (int i = 0; i < 3; i++) { | |
for (int j = 0; j < 50; j++) { | |
int dest = rand() % 4; | |
int sour = rand() % 13; | |
randomCard[i] = card[dest][sour]; | |
} | |
} | |
cout << "*********************" << endl; | |
cout << gameCount << " 번째 게임" << endl << endl; | |
cout << randomCard[0] << '\t' << "X" << '\t' << randomCard[2] << endl; | |
cout << endl; | |
cout << "*********************" << endl; | |
cout << "현재 소지금 : " << myGold << " 원" << endl; | |
cout << "얼마를 배팅 하시겠습니까?" << endl; | |
cin >> batting; | |
while (true) { | |
if (!cin.good() || batting > myGold || batting < 0) { | |
cin.clear(); | |
cin.ignore(INT_MAX, '\n'); | |
cout << "제대로 된 값을 입력해주세요 :)" << endl; | |
cin >> batting; | |
continue; | |
} | |
else if (batting == 0) { | |
cin.clear(); | |
cin.ignore(INT_MAX, '\n'); | |
cout << "0 원은 배팅 할 수 없다. :P" << endl; | |
cin >> batting; | |
continue; | |
} | |
else | |
{ | |
break; | |
} | |
} | |
cout << "결과 : "<< randomCard[0] << '\t' << randomCard[1] << '\t' << randomCard[2] << endl; | |
if (randomCard[1] > randomCard[0] && randomCard[1] < randomCard[2]\ | |
|| randomCard[1] < randomCard[0] && randomCard[1] > randomCard[2]) { | |
cout << "당신이 이겼습니다. :(" << endl; | |
cout << endl; | |
myGold += batting; | |
cout << "게임 결과 후 소지금 : " << myGold << " 원" << endl; | |
} | |
else { | |
cout << "당신이 졌습니다." << endl; | |
cout << endl; | |
myGold -= batting; | |
cout << "게임 결과 후 소지금 : " << myGold << " 원" << endl; | |
} | |
if (myGold <= 0) { | |
cout << endl; | |
cout << "파산했습니다. ㅋㅋㅋㅋㅋ" << endl; | |
break; | |
} | |
cout << endl; | |
cout << "한 겜더 하실꺼면 아무키나 눌러주세요." << " ***** 종료는 ESC 키" << endl << endl; | |
int key = _getch(); | |
if (key != 27) { | |
system("cls"); | |
batting = 0; | |
gameCount++; | |
continue; | |
} | |
else break; | |
} | |
} | |
AppleSeeU::~AppleSeeU() | |
{ | |
//cout << "Test Called Last" << endl; | |
} |
'Programming > C++' 카테고리의 다른 글
[C++]상점/인벤토리 만들기(콘솔) (0) | 2017.06.14 |
---|---|
[C++]High/low/Seven (0) | 2017.06.14 |
[C++]간단한 숫자 퍼즐 게임 (0) | 2017.06.14 |
[C++]간단한 별찍기 (0) | 2017.06.14 |
[C++]Console Bingo(빙고) (1) | 2017.06.14 |