Created
June 14, 2017 05:01
batting game _console
This file contains hidden or 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment