* 2013년 10월 26일 개발 * 미완성 {{{ #include #include #include #include #pragma warning(disable:4996) //scanf 등의 함수로 인해 뜨는 4996에러를 무시함 struct city { char name[10]; //도시의 이름 int own; //소유자 int arrive[4]; //도시에 머무르고 있는 플레이어 int level; //도시의 레벨 int cost; //1단계 기준 도시의 비용 }city[16]; //도시 구조체 struct player { char name[10]; //플레이어의 이름 int cash; //현금 자산 int prop; //부동산 자산 int loca; //플레이어의 위치 int die; //파산 여부 }player[4]; //플레이어 구조체 int rest[4]={0,0,0,0}; //무인도 int rank[4]={0,0,0,0}; //순위 void marble_board(); //마블 게임판을 출력하는 함수 int play_marble(int play_num); //마블을 플레이하는 함수 void main() { int i, j; int play_num; //플레이어의 수 char name[3]; srand(time(NULL)); strcpy(city[0].name,"출발"); strcpy(city[1].name,"서울"); strcpy(city[2].name,"도쿄"); strcpy(city[3].name,"시드니"); strcpy(city[4].name,"모스크바"); strcpy(city[5].name,"두바이"); strcpy(city[6].name,"카이로"); strcpy(city[7].name,"쌍파울로"); strcpy(city[8].name,"세계여행"); strcpy(city[9].name,"하와이"); strcpy(city[10].name,"프라하"); strcpy(city[11].name,"푸켓"); strcpy(city[12].name,"무인도"); strcpy(city[13].name,"런던"); strcpy(city[14].name,"빈"); strcpy(city[15].name,"발리"); for(i=0;i<16;i++) { city[i].own = -1; city[i].level = 0; city[i].cost = 100; for(j=0;j<4;j++) city[i].arrive[j] = 0; } //city 구조체 값 초기화 for(i=0;i<4;i++) { strcpy(player[i].name," "); player[i].cash = 5000; player[i].prop = 0; player[i].loca = 0; player[i].die = 0; } //player 구조체 값 초기화 printf("총 몇 명이 할까요(2~4)? "); scanf("%d",&play_num); for(i=0;i0;i--) printf("|%8s(레벨%d)",city[i].name,city[i].level); printf("|%15s",city[0].name); printf("|\n"); for(i=4;i>0;i--) printf("|-소유자:%-7d",city[i].own+1); printf("| |\n"); for(i=4;i>=0;i--) { printf("|"); for(j=0;j<4;j++) { if(city[i].arrive[j]==1) printf("(%d)",j+1); else printf(" "); } printf(" "); } printf("|\n"); for(i=0;i<5;i++) printf("+---------------"); printf("+\n"); //다섯째줄 도시 출력 } int play_marble(int play_num) { int dice; //주사위의 눈금 char buy; //인수 여부 int i,j; for(i=0;i 15) { player[i].cash+=500; printf("월급 500원을 받았습니다.(잔액 %d원)\n",player[i].cash); } city[player[i].loca].arrive[i] = 0; player[i].loca+=dice; if(player[i].loca>15) player[i].loca-=16; city[player[i].loca].arrive[i] = 1; printf("%s에 도착했습니다.\n",city[player[i].loca].name); if(player[i].loca == 0) { printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else if(player[i].loca == 12) { rest[i] = 1; printf("다음 턴을 쉽니다. 턴을 종료합니다.\n\n"); system("pause"); continue; } else if(player[i].loca == 8) { printf("세계여행을 원하는 위치를 선택해주세요(출발(0)~발리(15)) : "); city[player[i].loca].arrive[i] = 0; scanf("%d",&player[i].loca); fflush(stdin); city[player[i].loca].arrive[i] = 1; if(player[i].loca<8) { player[i].cash+=500; printf("월급 500원을 받았습니다.(잔액 %d원)\n",player[i].cash); } printf("%s에 도착했습니다.\n",city[player[i].loca].name); if(player[i].loca == 0) { printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else if(player[i].loca == 12) { rest[i] = 1; printf("다음 턴을 쉽니다. 턴을 종료합니다.\n\n"); system("pause"); continue; } } if(city[player[i].loca].own == -1) { printf("도시의 소유자가 없습니다. 도시를 인수할 수 있습니다.\n"); printf("인수비용은 %d원입니다.\n",city[player[i].loca].cost); printf("인수하시겠습니까(Y/N)? : "); scanf("%c",&buy); fflush(stdin); if(buy == 'N') { printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else if(buy == 'Y') { if(player[i].cash >= city[player[i].loca].cost) { player[i].cash -= city[player[i].loca].cost; player[i].prop += city[player[i].loca].cost; city[player[i].loca].own = i; city[player[i].loca].level = 1; printf("%s(레벨 %d)를 인수했습니다.(잔액 %d원)\n",city[player[i].loca].name,city[player[i].loca].level,player[i].cash); printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else { printf("현금이 부족합니다. 턴을 종료합니다.\n\n"); system("pause"); continue; } } } else if(city[player[i].loca].own != i) { printf("%s의 소유자는 %s입니다.\n",city[player[i].loca].name,player[city[player[i].loca].own].name); printf("통행료는 %d원입니다.\n",city[player[i].loca].cost*2); if(player[i].cash >= city[player[i].loca].cost*2) { player[i].cash -= city[player[i].loca].cost*2; player[city[player[i].loca].own].cash += city[player[i].loca].cost*2; printf("통행료를 냈습니다.(잔액 %d원)\n",player[i].cash); if(city[player[i].loca].level == 3) { printf("도시를 인수할 수 없습니다. (레벨 3)\n"); printf("턴을 종료합니다.\n\n"); system("pause"); continue; } printf("도시를 인수할 수 있습니다. 인수 비용은 %d원입니다.\n",city[player[i].loca].cost*4); printf("인수하시겠습니까(Y/N)? : "); scanf("%c",&buy); fflush(stdin); if(buy == 'N') { printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else if(buy == 'Y') { if(player[i].cash >= city[player[i].loca].cost*4) { player[i].cash -= city[player[i].loca].cost*4; player[i].prop += city[player[i].loca].cost; player[city[player[i].loca].own].cash += city[player[i].loca].cost*4; player[city[player[i].loca].own].prop -= city[player[i].loca].cost; city[player[i].loca].own = i; printf("%s(레벨 %d)를 인수했습니다.(잔액 %d원)\n",city[player[i].loca].name,city[player[i].loca].level,player[i].cash); printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else { printf("현금이 부족합니다. 턴을 종료합니다.\n\n"); system("pause"); continue; } } } else { printf("통행료가 부족합니다. %s이(가) 파산하였습니다.\n",player[i].name); player[i].die = 1; for(j=0;j<16;j++) { if(city[j].own == i) { city[j].own = -1; city[j].level = 0; city[j].cost = 100; } } city[player[i].loca].arrive[i] = 0; for(j=0;j<4;j++) { if(rank[j] == 0) { rank[j] = i+1; break; } else continue; } continue; } } else if(city[player[i].loca].own == i) { if(city[player[i].loca].level == 3) { printf("도시를 업그레이드 할 수 없습니다. (레벨 3)\n"); printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else { printf("도시를 레벨%d로 업그레이드 할 수 있습니다. (%d원)\n",city[player[i].loca].level+1,(city[player[i].loca].level+1)*100); printf("업그레이드하시겠습니까(Y/N)? : "); scanf("%c",&buy); fflush(stdin); if(buy == 'N') { printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else if(buy == 'Y') { if(player[i].cash >= (city[player[i].loca].level+1)*100) { player[i].cash -= (city[player[i].loca].level+1)*100; player[i].prop += (city[player[i].loca].level+1)*100; city[player[i].loca].level++; city[player[i].loca].cost+=(city[player[i].loca].level)*100; printf("%s을(를) 업그레이드했습니다.\n",city[player[i].loca].name); printf("턴을 종료합니다.\n\n"); system("pause"); continue; } else { printf("현금이 부족합니다. 턴을 종료합니다.\n\n"); system("pause"); continue; } } } } } return 0; } }}} ----- [최다인]