회사원 판타지 완성 코드

#include <iostream> // 콘솔 입출력
#include <stdlib.h> // 랜덤 모듈
#include <time.h> // 타임 추출
#include <string>
#include <CoreWindow.h>
using namespace std;

class Monster{

public:
string name;
int hp;
int power;// 공격력
int exp; // 경험치

string meetMent;
string skillMent;
string damageMent;


// 만남 멘트
void  MeetMent(string name, string meetMent){
cout << name << meetMent << endl;
}
// 스킬 멘트
void SkillMeNt(string skillMent){
cout << skillMent << "시전 합니다." << endl;
}
// 데미지
void attack(string skillMent, int damage){
cout << damageMent << " HP " << damage << " 만큼 감소합니다." << endl;
}

int RanDomNum(int minNum, int MaxNum){
int num;
num = rand() % MaxNum + minNum;
return num;
}

};


class Item{
public:
string name; // 아이템 이름
int addPoint;  // 추가 포인트
string script; // 내용
};


class gameMain{

public:

string userName;
int userhp;
int power;
int exp;
string level[7];
string skills[7];
int skillPower[7];
string levels;
bool gameOver = false;
bool restart = false;
int randMonNum;// 몬스터 랜덤 등장 변수
int levelUpNum = 0; // 레벨업 검사
//int introSpeed;


// 스킬 셋팅
void SkillSeeting(){
skills[0] = "[ 일하는척 ]";
skills[1] = "[ 표정관리 ]";
skills[2] = "[ 극한아부 ]";
skills[3] = "[ 술먹고 난동 ]";
skills[4] = "[ 힘들어서 우는척 ]";
skills[5] = "[ 사표 드립 ]";
skills[6] = "[ 사표 드립 ]";

}
// 스킬 파워
void SkillPower(){
skillPower[0] = 20;
skillPower[1] = 10;
skillPower[2] = 25;
skillPower[3] = 30;
skillPower[4] = 15;
skillPower[5] = 1;
skillPower[6] = 25;
}

// 레벨 셋팅
void LevelSetting(){
level[0] = "인턴사원";
level[1] = "신입사원";
level[2] = "경력사원";
level[3] = "1년차사원";
level[4] = "2년차사원";
level[5] = "3년차사원";
level[6] = "무적대리";
}

void InputName(){
cout << " 회사원님의 이름을 입력 하세요. ==> ";
cin >> userName;
}

//레벨업 메소드
void LevelUp(string low, string high){
cout << "레벨업!!! " << low << " 레벨에서" << high << " 으로 레벨업 하였습니다!" << endl;
cout << "레벨업 보너스로 HP 가 100 증가 합니다." << endl;
userhp += 100;
levels = high;
power += 5;

if (levelUpNum >= 7){
levelUpNum = 7;
}
else{
levelUpNum++;
}

}

void infoView(){
LevelSetting(); //레벨셋팅 로드
levels = level[0];
//레벨업
if (exp > 100 && levelUpNum == 0) LevelUp(level[0], level[1]);
else if (exp > 200 && levelUpNum == 1) LevelUp(level[1], level[2]);
else if (exp > 300 && levelUpNum == 2) LevelUp(level[2], level[3]);
else if (exp > 400 && levelUpNum == 3) LevelUp(level[3], level[4]);
else if (exp > 500 && levelUpNum == 4) LevelUp(level[4], level[5]);
else if (exp > 600 && levelUpNum == 5)LevelUp(level[5], level[6]);


cout << "+--Status---------------------------------------------------------------+" << endl;
cout << "|                                                                       |" << endl;
cout << "|  NAME: " << userName << "씨 " << " / HP: " << userhp << " / LEVEL :" << levels << " / EXP :" << exp << " / POWER :" << power << endl;
cout << "|                                                                       |" << endl;
cout << "+-----------------------------------------------------------------------+" << endl;
}

void MoveUser(){
int movePoint;
cout << "" << endl;
cout << "이동 하시겠습니까? ( 1:탕비실, 2:회의실, 3:화장실, 4:옥상 5:종료) ==> ";
cin >> movePoint;
// 종료.
if (movePoint == 5){
gameOver = true;
return;
}
else if ((movePoint != 1) && (movePoint != 2) && (movePoint != 3) && (movePoint != 4) && (movePoint != 5) && (movePoint != 6)){
cout << "화면에 표시된 번호를 눌러 주세요." << endl;
Sleep(1000);
MoveUser();
}
//진행

MonMeet();
}

void MonMeet(){
SkillSeeting();
SkillPower();


randMonNum = rand() % 10; // 몬스터, 아이템 랜덤 등장 번호
int nextSpeed = 500; // txt 표시 시간.
int attackSelect;
int userSkillNum;

// 아이템 추가.
Item items[3];
items[0].name = "박카스";
items[0].script = "정신이 맑아 지는것을 느낍니다. ";
items[0].addPoint = 70;

items[1].name = "비타씨";
items[1].script = "수지를 보고, ";
items[1].addPoint = 100;

items[2].name = "핫식스";
items[2].script = "야근파워의 기운이 느껴집니다. ";
items[2].addPoint = 120;



// 아이템 랜덤수를 늘려서 나오는 숫자.
if (randMonNum == 8 || randMonNum == 9 || randMonNum == 10 || randMonNum == 11){
int itemRanNum = rand() % 3;
cout << "" << endl;
cout << "+--Item!!---------------------------------------------------------------+" << endl;
cout << "" << endl;
cout << "ITEM 발견!" << items[itemRanNum].name << "를 발견 했습니다." << endl;
cout << items[itemRanNum].script << "HP가 " << items[itemRanNum].addPoint << " 회복 되었습니다.." << endl;
cout << "" << endl;
userhp += items[itemRanNum].addPoint;
infoView();
cout << "" << endl;
MoveUser();
}


// 몬스터 설정
Monster mons[8];
mons[0].name = "이대리";
mons[0].hp = 40;
mons[0].exp = 60;
mons[0].power = mons[0].RanDomNum(5, 15);
mons[0].meetMent = " 잘만났다 너 어제 과장님 보다 일찍 가더라?!";
mons[0].skillMent = "이대리가 [ 스킬 - 이유없는 갈굼 ]을";
mons[0].damageMent = "정신적인 충격으로";

mons[1].name = "박과장";
mons[1].hp = 50;
mons[1].exp = 45;
mons[1].power = mons[1].RanDomNum(10, 20);
mons[1].meetMent = " 이것도 서류라고 결재 올린거야!?";
mons[1].skillMent = "박과장이 [ 스킬 - 서류 던지기 ]를";
mons[1].damageMent = "창피해서";

mons[2].name = "김차장";
mons[2].hp = 55;
mons[2].exp = 55;
mons[2].power = mons[2].RanDomNum(15, 25);
mons[2].meetMent = " 담배 하나만 줘...";
mons[2].skillMent = "김차장이[ 스킬 -  담배삥 ]을";
mons[2].damageMent = "한심해서";

mons[3].name = "최선배";
mons[3].hp = 50;
mons[3].exp = 60;
mons[3].power = mons[3].RanDomNum(18, 27);
mons[3].meetMent = " 형이 부탁한다 너희 회사 남는 자리 없냐";
mons[3].skillMent = "최선배가 [ 스킬 -  취업요청 ]을";
mons[3].damageMent = "부담되서 ";

mons[4].name = "비서실 미스리";
mons[4].hp = 60;
mons[4].exp = 55;
mons[4].power = mons[4].RanDomNum(20, 60);
mons[4].meetMent = " 지금 어딜봐요? 아 기분나뻐";
mons[4].skillMent = "비서실 미스리가 [ 스킬 - 성희롱 ] 고소를";
mons[4].damageMent = "정신적 충격으로";

mons[5].name = "이팀장";
mons[5].hp = 70;
mons[5].exp = 45;
mons[5].power = mons[5].RanDomNum(20, 25);
mons[5].meetMent = " 내가 저녁에 말한거 내일 아침에 볼 수 있게 해줘요";
mons[5].skillMent = "이팀장이 [ 스킬 - 밤샘야근 ]을";
mons[5].damageMent = "육체적 고통으로";

mons[6].name = "고전무";
mons[6].hp = 70;
mons[6].exp = 55;
mons[6].power = mons[6].RanDomNum(20, 45);
mons[6].meetMent = " 내가 신입 사원때는 매일 밤을 새서 일을했어";
mons[6].skillMent = "고전무가 [ 스킬 - 끝이 없는 이야기 ]를";
mons[6].damageMent = "정신적 스트레스로";

mons[7].name = "대표님";
mons[7].hp = 80;
mons[7].exp = 65;
mons[7].power = mons[7].RanDomNum(35, 45);
mons[7].meetMent = " 미안한데 말이야.. 월급을 다음달에 줄 수 있을것 같아";
mons[7].skillMent = "대표님이 [ 스킬 - 월급 미루기 ]를";
mons[7].damageMent = "적금 해지로";




int monHp = mons[randMonNum].hp;
// 몬스터 등장

cout << "" << endl;
cout << "+--Monster!!------------------------------------------------------------+" << endl;

//cout << "몬스터 넘버 : " << randMonNum << endl;
cout << mons[randMonNum].name << " 를만났습니다." << endl; Sleep(nextSpeed); //몬스터 이름
cout << "" << endl;
mons[randMonNum].MeetMent(userName, mons[randMonNum].meetMent); Sleep(nextSpeed); //만남멘트
mons[randMonNum].SkillMeNt(mons[randMonNum].skillMent); Sleep(nextSpeed); //스킬멘트
mons[randMonNum].attack(mons[randMonNum].damageMent, mons[randMonNum].power);  //데미지
userhp -= mons[randMonNum].power; //HP 피해
cout << "" << endl;

// 첫 만남에 지는 경우.
if (userhp <= 1) {
cout << mons[randMonNum].name << "님에게 패배 했습니다.." << endl;
restart = true;
return;
}



cout << "공격 하시겠습니까? ( 1: 공격, 2: 도망감) ==> ";
cin >> attackSelect;
if (attackSelect == 1){
cout << "" << endl;
cout << "+--Fight!!--------------------------------------------------------------+" << endl;


for (;;){
int i = 1;
// 플레이어 공격턴
userSkillNum = rand() % 6 + 1;
cout << i << " 번째 턴" << endl;
cout << "스킬 " << skills[userSkillNum] << " 을 시전합니다." << mons[randMonNum].name << "의 HP가 " << skillPower[userSkillNum] + power << " 만큼 감소 합니다." << endl;
monHp -= (skillPower[userSkillNum] + power);

//플레이어 승리시
if (monHp <= 1){
monHp = 0;
cout << mons[randMonNum].name << " HP : " << monHp << " <==== VS ====> " << userName << " HP : " << userhp << endl;
cout << mons[randMonNum].name << "님을 물리쳤습니다" << endl;
cout << "" << endl;
cout << "경험치 " << mons[randMonNum].exp << " 을 얻었습니다." << endl;
exp += mons[randMonNum].exp;

break;
}

Sleep(500);
//몬스터 공격턴
cout << mons[randMonNum].name << " 님이 공격 합니다. HP가 " << mons[randMonNum].power << " 가 만큼 감소 합니다." << endl; userhp -= mons[randMonNum].power; //HP 피해
if (userhp <= 1)userhp = 0;
cout << mons[randMonNum].name << " HP : " << monHp << " <==== VS ====> " << userName << " HP : " << userhp << endl;
cout << "" << endl;

//플레이어 패배시
if (userhp <= 1) {
userhp = 0;
//cout << mons[randMonNum].name << " HP : " << monHp << " <==== VS ====> " << userName << " HP : " << userhp << endl;
cout << mons[randMonNum].name << "님에게 패배 했습니다.." << endl;
restart = true;

break;
}

i++;

}
return;
}

if (attackSelect == 2){
cout << mons[randMonNum].name << " 님이 무서워서 도망갑니다." << endl;
cout << "" << endl;
}

// 상태창 불러오기
//infoView();
}

};


void GameIntro(){
int introSpeed = 200;
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl; Sleep(introSpeed);
cout << "$$$$$d0ZOb$$$$$$$$$$BB$$$$$$$$$$*bk$$$$$$#q%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl; Sleep(introSpeed);
cout << "$@8%B8    u$%%%8Wk   )$$$$$$$$dZa8B$$$$$$J :tb$$$$$z.          ;b$$>  k$$" << endl; Sleep(introSpeed);
cout << "$)              d$   )$$$$$$$@    Q$$$$$$*hha$$$$$*   u$@@@@@]   $$+  k$$" << endl; Sleep(introSpeed);
cout << "@@@@@@@:       :%@%   %@@@@@@.   .*@@@@@@.  =#@%@%+#%%%%%#+=:=+%@@:   @@@" << endl; Sleep(introSpeed);
cout << "$$rrr        ^^Q$$   ,$$$$$${{   `?Q$$$$$t   jY$w$$wzOoB$*mztfnC$$$<  k$$" << endl; Sleep(introSpeed);
cout << "$q   w$$$$$$/   $$`  `$$$$$blX*&&bf<{$$$$1          .         l?h*$c+.b$$" << endl; Sleep(introSpeed);
cout << "$M   _zccccv,   $$^  I$$$$f_<` &$    O$$$)   d$$$urt    /uxjjruY$$t :]M$$" << endl; Sleep(introSpeed);
cout << "$$p_II     |:l|$$$    $$$-    $$$o    B$$|   p$$$$$! : <#b*$$$>       a$$" << endl; Sleep(introSpeed);
cout << "$M%$$#    b$$$$&bb.   B$i   .$$$$$c    $$nw  p$$$$-   :   i$$dCOOOOOOL@$$" << endl; Sleep(introSpeed);
cout << "$                     $0{}~<$$$$$$$?   I$B   w$$$*   :$               Y$$" << endl; Sleep(introSpeed);
cout << "$*############*@$$p0OL$$$$$$$$$$$$$$MW&o@pQOQ&$$8$O0L$$LQ00QQQQQQQQQQC*$$" << endl; Sleep(introSpeed);
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl; Sleep(introSpeed);
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl; Sleep(introSpeed);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "+-                 '니가 나를 해고시킬수 있을거같냐?'                  -+" << endl; Sleep(500);
cout << "+-                                                                     -+" << endl; Sleep(introSpeed);
cout << "+-                  본격 하드 보일드 판타지. 회사원                    -+" << endl; Sleep(500);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "+- 정동 액션 회사원 판티지에 오신것을 환영합니다!                      -+" << endl; Sleep(introSpeed);
cout << "+- 게임방법은 쉽고 간단합니다.                                         -+" << endl; Sleep(introSpeed);
cout << "+- 직장스트레스를 이곳에서 화끈한 액션과 함께 풀어나가시길 바랍니다.   -+" << endl; Sleep(introSpeed);
cout << "+- Enjoy Company Man fantasy Game                                      -+" << endl; Sleep(introSpeed);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "+-----------------------------------------------------------------------+" << endl; Sleep(introSpeed);
cout << "" << endl; Sleep(introSpeed);



}

void main(){
//시드 섞기
srand((unsigned int)time(NULL));
int isRePlay = 0; // 재실행 여부 변수

// 객체선언
gameMain gam;

// 초기 캐릭터 상태 설정
gam.userhp = 350;
gam.exp = 0;
gam.power = 5;
//gam.introSpeed = 300;


// 메소드 실행
GameIntro();
gam.InputName();

for (;;){

// 게임 종료 여부
if (gam.gameOver == true){
cout << "" << endl;
cout << "게임을 종료 합니다." << endl;
break;
}
if (gam.restart == true){
cout << "" << endl;
cout << "한번 더 하시겠습니까? ( 1 : 다시한다, 2 : 그만한다 ) ==> ";
cin >> isRePlay;
if (isRePlay == 1){
cout << "" << endl;
cout << "게임을 재 실행 합니다." << endl;
Sleep(1000);
system("cls");
main();
}
else if (isRePlay == 2){
cout << "" << endl;
cout << "게임을 종료 합니다.." << endl;
Sleep(1000);
break;
}
}

gam.infoView();
gam.MoveUser();
}


}

댓글

이 블로그의 인기 게시물

날짜 시간 시간차 시간 계산 하기

코루틴에서 CallBack 함수 적용하기

C++ 언어 퍼센트 구하는 방법 / 기본 언어 퍼센트 구하는 방법