/* http://www.wadlo.com */ #include #include #include #include int turn = 0; #define MAXPLAYERS 12 int players = 4; int prop[40][3]; int price[40][18]; char posnames[40][25]; int propcolor[40]; int positions[MAXPLAYERS]; long cash[MAXPLAYERS][2]; char symbols[12] = { 2,137,155,235,237,247,232,15,234,21,3,14 }; int symcolor[12] = { 10,3,8,13,15,9,2,14,6,7,12,11 }; int jailed[12]; int beeping = 1; int speed = 0; int movewith = 1; int scroller = 1; int maxhouses = 9; int logoonly = 1; int autobuy = 1; int passing = 200; int landing = 400; int startcash = 500; int reclear = 0; int preroll = 0; int doubles = 0; int propview = 0; int optionalsale = 1; int jailfee = 50; int jailstays = 3; int difficulty = 1; void load(); void save(); void initial(); int makedice(); void passgo(int x); void drawdice(int roll); void drawsymbols(); void checkowner(int roll); void showdetails(); void clearoptions(); void options(); void scrollleft(); void scrollright(); void drawcolors(); void drawprop(); int makex(int x); int makey(int y); void charxy(int s, int x, int y); void drawcard(); void drawboard(); /* float dice(); */ void buildhouse(int x); void drawtitle(); void showmenu(); void detailarrow(); void sellhouse(int x); void mortgage(int x); void unmortgage(int x); void compsell(); void compbuy(); void broke(); void specialprops(); void jail(); void playersell(); void trade(int x); long GetDollars(); void displayexit( int winner ); main() { int i, j,/* space,*/ command; int roll; char quit; int winner = 1; int plsrem = 0; textbackground(0); textcolor(15); clrscr(); load(); drawboard(); initial(); while(quit != 'y' && quit != 'Y' ) { plsrem = players; while (cash[turn][1] == -1 /*&& turn != 0*/ ) { turn = (turn + 1) % players; plsrem--; } if ( plsrem == 1 ) { quit = 'Y'; /* winner = 1; */ } if (preroll == 0 && doubles == 0) { gotoxy(8,16); if (turn == 0) printf(" Roll! "); else printf(" Rolling..."); } else if (doubles == 0 ) { gotoxy(8,16); printf(" Done? "); } else { gotoxy(8,16); printf("Roll Again!"); } if (jailed[turn] != -1 && preroll == 0 && 1 == 2 ) { jail(); command = getch(); preroll = 1; gotoxy(8,16); printf(" Done? "); } else if (turn == 0 && cash[0][1] != -1 ) { if (logoonly == 1) { clearoptions(); drawtitle(); logoonly = 0; command = getch(); clearoptions(); showdetails(); showmenu(); } else if (propview != 1) { showdetails(); showmenu(); command = getch(); } else command = getch(); } else { detailarrow(); command = 32; for ( i=(speed * -3000) ; i<(speed * 3000) ; i++ ) for ( j=(speed * -3000) ; j<(speed * 3000) ; j++ ) ; if (cash[turn][1] < 0) compsell(); else { compbuy(); } } if (command == 32) { if (preroll == 0) { if (propview == 1) { propview = 0; clearoptions(); showdetails(); } roll = makedice(); positions[turn] = positions[turn] + roll; if (positions[turn] > 40) passgo(passing); else if ( positions[turn] == 39) passgo(landing); if (turn == 0 && movewith == 1) scroller = positions[turn]; /* drawsymbols(); */ checkowner(roll); /* if ( cash[0][1] == -1 ) */ /* { */ /* quit == 'Y'; */ /* winner = 0; */ /* } */ drawdice(roll); if (turn != 0 && cash[0][1] == -1 ) showdetails(); } if (preroll == 1) { turn++; preroll = 0; } else if (doubles > 0) ; else preroll = 1; } else if (command == 27) { if (propview == 0) { textcolor(15); gotoxy(23,25); cprintf("Are you sure you want to quit? Y/N "); gotoxy(37,25); quit = getch(); showmenu(); if ( quit == 'y' || quit == 'Y' ) winner = 0; } else { showdetails(); propview = 0; } } else if (command == '@') { if (preroll == 0) { textcolor(15); gotoxy(2,1); cprintf("CHEATER! 1-13? "); gotoxy(17,1); /* scanf("%d", &roll); */ roll = GetDollars(); if (roll>13 || roll<1) roll = 6; gotoxy(2,1); textcolor(1); cprintf(" "); textcolor(15); positions[turn] = (positions[turn] + roll); if (positions[turn] > 40) passgo(passing); else if ( positions[turn] == 40) passgo(landing); drawsymbols(); showdetails(); checkowner(roll); } if (preroll == 1) { turn++; preroll = 0; } else if (doubles > 0) ; else preroll = 1; } else if ((command == 'o') || (command == 'O')) { propview = 0; clearoptions(); options(); clearoptions(); /* showdetails(); */ drawsymbols(); } else if (command == 'b' || command == 'B') { buildhouse(scroller); } else if (command == 's' || command == 'S') sellhouse(scroller); else if (command == 'm' || command == 'M') mortgage(scroller); else if (command == 'u' || command == 'U') unmortgage(scroller); else if (command == 't' || command == 'T' || command == 'a' || command == 'A') trade(scroller); else if (command == 0) { command = getch(); if (command == 75) scrollleft(); else if (command == 77) scrollright(); else { /* gotoxy(5,5); printf("ERROR2!"); */ } } else if (command == 'n') ; else { if (beeping == 1) printf("\a"); } if (turn >= players) turn = 0; broke(); if (propview == 0) drawsymbols(); /* if ( spacesused[positions[turn]] != 'X' ) */ /* { */ /* spacesused[positions[turn]] = 'X'; */ /* } */ /* gotoxy(35,21); */ /* for ( i=0 ; i<41 ; i++ ) */ /* { */ /* if ( spacesused[i] == 'X' ) */ /* printf("X"); */ /* else */ /* printf("_"); */ /* } */ if ( cash[0][1] == -1 ) { quit = 'Y'; winner = 0; } } displayexit( winner ); save(); /* getch(); */ return 0; } int makedice() { int roll; time_t seconds; seconds = time(NULL); roll = (( rand() + seconds ) % 11) + 2; /* gotoxy(55,19); printf("dice = %d ", roll); */ return (int)roll; } void initial() { int i; for ( i=0 ; i<40 ; i++ ) prop[i][1] = -1; /* No one owns anything */ for ( i=0 ; i<40 ; i++ ) prop[i][2] = 0; /* No houses at start */ for ( i=0 ; i=0 ; i-- ) { if (cash[i][1] != -1 ) { gotoxy(makex(positions[i]),makey(positions[i])); textcolor(symcolor[i]); cprintf("%c", symbols[i]); } } } int makex(int space) { int x; if (space < 10) x = 23 - (space * 2); else if (space < 21) x = 3; else if (space < 30) x = (space * 2) - 37; else x = 23; /* gotoxy(73,2); cprintf("x "); gotoxy(73,3); cprintf("%d ",x); */ return x; } int makey(int space) { int y; if (space < 10) y = 23; else if (space < 21) y = 43 - (space * 2); else if (space < 30) y = 3; else y = (space * 2) - 57; /* gotoxy(1,1); printf("*"); */ /* gotoxy(76,2); cprintf("y "); gotoxy(76,3); cprintf("%d ",y); */ return y; } void drawprop() { gotoxy(21,24); if (prop[1][2] != -2) printf("%d", prop[1][2]); else printf("M"); gotoxy(17,24); if (prop[3][2] != -2) printf("%d", prop[3][2]); else printf("M"); gotoxy(13,24); if (prop[5][2] != -2) printf("%c", 205); else printf("M"); gotoxy(11,24); if (prop[6][2] != -2) printf("%d", prop[6][2]); else printf("M"); gotoxy(7,24); if (prop[8][2] != -2) printf("%d", prop[8][2]); else printf("M"); gotoxy(5,24); if (prop[9][2] != -2) printf("%d", prop[9][2]); else printf("M"); gotoxy(2,21); if (prop[11][2] != -2) printf("%d", prop[11][2]); else printf("M"); gotoxy(2,19); if (prop[12][2] != -2) printf("%c", 186); else printf("M"); gotoxy(2,17); if (prop[13][2] != -2) printf("%d", prop[13][2]); else printf("M"); gotoxy(2,15); if (prop[14][2] != -2) printf("%d", prop[14][2]); else printf("M"); gotoxy(2,13); if (prop[15][2] != -2) printf("%c", 186); else printf("M"); gotoxy(2,11); if (prop[16][2] != -2) printf("%d", prop[16][2]); else printf("M"); gotoxy(2,7); if (prop[18][2] != -2) printf("%d", prop[18][2]); else printf("M"); gotoxy(2,5); if (prop[19][2] != -2) printf("%d", prop[19][2]); else printf("M"); gotoxy(5,2); if (prop[21][2] != -2) printf("%d", prop[21][2]); else printf("M"); gotoxy(9,2); if (prop[23][2] != -2) printf("%d", prop[23][2]); else printf("M"); gotoxy(11,2); if (prop[24][2] != -2) printf("%d", prop[24][2]); else printf("M"); gotoxy(13,2); if (prop[25][2] != -2) printf("%c", 205); else printf("M"); gotoxy(15,2); if (prop[26][2] != -2) printf("%d", prop[26][2]); else printf("M"); gotoxy(17,2); if (prop[27][2] != -2) printf("%d", prop[27][2]); else printf("M"); gotoxy(19,2); if (prop[28][2] != -2) printf("%c", 205); else printf("M"); gotoxy(21,2); if (prop[29][2] != -2) printf("%d", prop[29][2]); else printf("M"); gotoxy(24,5); if (prop[31][2] != -2) printf("%d", prop[31][2]); else printf("M"); gotoxy(24,7); if (prop[32][2] != -2) printf("%d", prop[32][2]); else printf("M"); gotoxy(24,11); if (prop[34][2] != -2) printf("%d", prop[34][2]); else printf("M"); gotoxy(24,13); if (prop[35][2] != -2) printf("%c", 186); else printf("M"); gotoxy(24,17); if (prop[37][2] != -2) printf("%d", prop[37][2]); else printf("M"); gotoxy(24,21); if (prop[39][2] != -2) printf("%d", prop[39][2]); else printf("M"); } void drawdice(int prevroll) { int dice1=0, dice2, roll; charxy(201,10,11); charxy(187,12,11); charxy(201,14,11); charxy(187,16,11); charxy(200,10,13); charxy(188,12,13); charxy(200,14,13); charxy(188,16,13); gotoxy(10,10); printf("Roll: %d ", prevroll); do { roll = makedice(); /* gotoxy(29,18); printf("total = %d ", roll); */ roll = roll % 6 + 1; dice1 = roll; /* printf("dice1 = %d ", dice1); */ dice2 = prevroll - dice1; /* printf("!!!!!!!!!!!!!!!!!!! %d+%d=%d...",dice1,dice2,prevroll); */ } while( dice2>6 || dice2<1 ); /* printf("%d+%d=%d ", dice1, dice2,prevroll); */ /* ..getch(); */ gotoxy(11,12); printf("%d", dice1); gotoxy(15,12); printf("%d", dice2); if ( dice2 == dice1) { doubles++; /* gotoxy(8,14); printf("Doubles (%d)", doubles); */ } else { gotoxy(8,14); doubles = 0; printf(" "); } if (doubles > 2) { positions[turn] = 10; jailed[turn] = jailstays; doubles = 0; turn++; } } void showdetails() { int i, max; if (reclear == 1) clearoptions(); if (players > 12) max = 12; else max = players; for ( i=0 ; i Are you sure? Y/N"); command = getch(); if (command == 'y' || command == 'Y') { initial(); command = 27; } else { gotoxy(43,6); printf(" "); } } else if (command == 's' || command == 'S') { speed = speed - 1; if (speed<0) speed = 8; } else if (command == 'm' || command == 'M') { maxhouses = maxhouses + 1; if (maxhouses > 9) maxhouses = 0; } else if (command == 'i' || command == 'I') { startcash = startcash + 50; if (startcash > 5000) startcash = 100; } else if (command == 'g' || command == 'G') { passing = passing + 50; if (passing > 800) passing = 50; landing = passing * 2; } else if (command == 'j' || command == 'J') { jailfee = jailfee + 25; if (jailfee > 300) jailfee = 50; } else if (command == 't' || command == 'T') { jailstays = jailstays + 1; if (jailstays > 5) jailstays = 1; } else if (command == 'r' || command == 'R') autobuy = (autobuy * -1) + 1; else if (command == 'l' || command == 'L') { FILE *fp; fp = fopen("prefs.dat","r"); if (fp != 0) { fscanf(fp, "Beeping: %d\n", &beeping); fscanf(fp, "Players %d\n", &players); fscanf(fp, "Speed %d\n", &speed); fscanf(fp, "Maxhouses %d\n", &maxhouses); fscanf(fp, "InitialCash %d\n", &startcash); fscanf(fp, "GoMoney %d %d\n", &passing, &landing); fscanf(fp, "CardWithToken %d\n", &movewith); fscanf(fp, "JailFee %d\n", &jailfee); fscanf(fp, "TurnsInJail %d\n", &jailstays); fscanf(fp, "ReflexBuying %d\n", &autobuy); } fclose(fp); /* FILE *fp; fp = fopen("props.dat","r"); if (fp != 0) { for ( i=0 ; i<40 ; i++ ) { fscanf(fp, "%s\n", &posnames[i]); } } */ } else if (command == 'a' || command == 'A') { gotoxy(32,17); printf(" About Monopoly "); gotoxy(34,18); printf(" This program was programmed and compiled "); gotoxy(34,19); printf(" by Wadlo. Made in 2003. For background "); gotoxy(34,20); printf(" information, see http://www.wadlo.com/ "); gotoxy(34,22); printf("The original Monopoly is a Hasbro product."); } } while (command != 27); if ( players > tempplayers ) { for ( i=tempplayers ; i 39) scroller = 1; } while (price[scroller][0] == -1); gotoxy(makex(scroller),makey(scroller)); textcolor(10); cprintf("%c",176); drawcard(); } void scrollright() { drawsymbols(); do { scroller--; if (scroller < 1) scroller = 39; } while (price[scroller][0] == -1); gotoxy(makex(scroller),makey(scroller)); textcolor(10); cprintf("%c",176); drawcard(); } void load() /* load records if possible */ { int i, j; FILE *fp; /* Pointer to a file */ fp = fopen("props.dat","r"); /* open file to "fp" */ if (fp != 0) /* if file exists */ { for ( i=0 ; i<40 ; i++ ) { fscanf(fp, "%s\n", &posnames[i]); } } fclose(fp); /* close the file */ for ( i=0 ; i<40 ; i++ ) for ( j=0 ; j<25 ; j++ ) if (posnames[i][j] == 95) posnames[i][j] = 32; fp = fopen("prices.dat","r"); /* open file to "fp" */ if (fp != 0) /* if file exists */ { for ( i=0 ; i<40 ; i++ ) { for ( j=0 ; j<18 ; j++ ) fscanf(fp, "%d ", &price[i][j]); fscanf(fp, "%d", &propcolor[i]); } } fclose(fp); /* close the file */ } void save() { /*int i;*/ FILE *fp; fp = fopen("prefs.dat","w"); fprintf(fp, "Beeping: %d\n", beeping); fprintf(fp, "Players %d\n", players); fprintf(fp, "Speed %d\n", speed); fprintf(fp, "Maxhouses %d\n", maxhouses); fprintf(fp, "InitialCash %d\n", startcash); fprintf(fp, "GoMoney %d %d\n", passing, landing); fprintf(fp, "CardWithToken %d\n", movewith); fprintf(fp, "JailFee %d\n", jailfee); fprintf(fp, "TurnsInJail %d\n", jailstays); fprintf(fp, "ReflexBuying %d\n", autobuy); fclose(fp); } void drawcard() { int i, j, owncount=0; if (propview == 0) { propview = 1; clearoptions(); } gotoxy(30,3); for ( i=3 ; i<24 ; i++ ) { for ( j=0 ; j<20 ; j++ ) printf(" "); gotoxy(30,i); } for ( i=0 ; i<20 ; i++ ) { charxy(205,i+30,2); charxy(205,i+30,23); charxy(186,29,i+3); charxy(186,50,i+3); } charxy(201,29,2); charxy(187,50,2); charxy(200,29,23); charxy(188,50,23); gotoxy(31,4); printf("%s", posnames[scroller]); textcolor(propcolor[scroller]); gotoxy(30,3); for ( i=30 ; i<50 ; i++ ) { cprintf("%c", 177); } gotoxy(30,5); for ( i=30 ; i<50 ; i++ ) { cprintf("%c", 177); } if (price[scroller][1] != -1) { gotoxy(35,6); printf("Price: $%d", price[scroller][0]); gotoxy(32,7); printf("Mortgage: $%d", price[scroller][16]); gotoxy(34,8); printf("Houses: $%d ", price[scroller][17]); gotoxy(36,10); printf("Rent: $%d", price[scroller][1]); gotoxy(32,11); printf("Monopoly: $%d", price[scroller][2]); for ( i=3 ; i 0) gotoxy(31,prop[scroller][2]+11); else gotoxy(31,6); printf("%c",16); } else if ( price[scroller][13] != -1 && price[scroller][14] == -1) { gotoxy(35,6); printf("Price: $%d", price[scroller][0]); gotoxy(32,7); printf("Mortgage: $%d", price[scroller][16]); gotoxy(32,9); printf("Own 1: %d Times", price[scroller][12]); gotoxy(36,10); printf("Roll of Dice"); gotoxy(32,11); printf("Own 2: %d Times", price[scroller][13]); gotoxy(36,12); printf("Roll of Dice"); gotoxy(33,22); if (prop[scroller][1] != -1) printf("Owner: Player %d", prop[scroller][1]+1); else printf("Owner: None"); if (prop[scroller][1] == prop[12][1]) owncount++; if (prop[scroller][1] == prop[28][1]) owncount++; if (prop[scroller][2] != -2 && prop[scroller][1] != -1) gotoxy(31,(owncount*2)+7); else if (prop[scroller][2] == -2) gotoxy(31,7); else gotoxy(31,6); printf("%c",16); } else if ( price[scroller][14] != -1 ) { gotoxy(35,6); printf("Price: $%d", price[scroller][0]); gotoxy(32,7); printf("Mortgage: $%d", price[scroller][16]); for ( i=12 ; i<16 ; i++) { gotoxy(35,i-3); printf("Own %d: $%d ", i-11, price[scroller][i]); } gotoxy(33,22); if (prop[scroller][1] != -1) printf("Owner: Player %d", prop[scroller][1]+1); else printf("Owner: None"); for ( i=1 ; i<5 ; i++ ) if (prop[(i*10)-5][1] == prop[scroller][1]) owncount++; if (prop[scroller][2] == -2 && prop[scroller][1] != -1) gotoxy(31,7); else if (prop[scroller][1] != -1) gotoxy(31,owncount+8); else gotoxy(31,6); printf("%c",16); } if (optionalsale == 1) { gotoxy(52,2); printf("Property Commands:"); if (prop[scroller][1] == -1 && autobuy == 0 && positions[turn] == scroller) textcolor(15); else textcolor(8); gotoxy(53,4); cprintf("(P)urchase Property"); if (prop[scroller][2] == 0 && prop[scroller][1] == turn) textcolor(15); else textcolor(8); gotoxy(53,5); cprintf("(M)ortgage Property"); if (prop[scroller][2] == -2 && prop[scroller][1] == turn) textcolor(15); else textcolor(8); gotoxy(53,6); cprintf("(U)nmortgage Property"); if (price[scroller][17] != -1 && prop[scroller][1] == turn && prop[scroller][2] < maxhouses) textcolor(15); else textcolor(8); gotoxy(53,7); cprintf("(B)uy Houses"); if (price[scroller][17] != -1 && prop[scroller][1] == turn && prop[scroller][2] > 0) textcolor(15); else textcolor(8); gotoxy(53,8); cprintf("(S)ell Houses"); if (price[scroller][1] != -1 && prop[scroller][1] != turn && prop[scroller][1] != -1 ) textcolor(15); else textcolor(8); gotoxy(53,9); cprintf("(T)rade Property"); if (price[scroller][1] != -1 && prop[scroller][1] == turn && prop[scroller][1] != -1 ) textcolor(15); else textcolor(8); gotoxy(53,10); cprintf("(A)uction Property"); gotoxy(61,24); printf("(Esc) to View Stats"); } reclear=1; } void checkowner(roll) { int owncount = 0, i; /* int player = turn; int owner = prop[positions[turn]][1]; int playercash = cash[turn][1]; int pricetobuy = price[positions[turn]][0]; int pricetoland = price[positions[turn]][1]; int pricewhouses = price[positions[turn]][prop[positions[turn]][2]+1]; int ownerscash = cash[prop[positions[turn]][1]][1]; gotoxy(64,5); printf("player %d \n", player); gotoxy(64,6); printf("owner %d \n", owner); gotoxy(64,7); printf("players cash %d \n", playercash); gotoxy(64,8); printf("price of prop %d \n", pricetobuy); gotoxy(64,9); printf("price to land %d \n", pricetoland); gotoxy(64,10); printf("price w houses %d \n", pricewhouses); gotoxy(64,11); printf("owners cash %d \n", ownerscash); */ if (prop[positions[turn]][1] == -1 && cash[turn][1] > price[positions[turn]][0] + 100 && price[positions[turn]][0] > 0 ) { if (autobuy == 1 || turn != 0) { prop[positions[turn]][1] = turn; cash[turn][1] = cash[turn][1] - price[positions[turn]][0]; } } else if ( prop[positions[turn]][1] != -1 && prop[positions[turn]][1] != turn ) { if (price[positions[turn]][prop[positions[turn]][2]+1] != -1) { /* gotoxy(40,20); printf("Paying1..."); getch(); gotoxy(40,20); printf(" "); */ cash[turn][1] = cash[turn][1] - price[positions[turn]][prop[positions[turn]][2]+1]; cash[prop[positions[turn]][1]][1] = cash[prop[positions[turn]][1]][1] + price[positions[turn]][prop[positions[turn]][2]+1]; } else if (price[positions[turn]][14] != -1) { for ( i=1 ; i<5 ; i++ ) if (prop[(i*10)-5][1] == prop[positions[turn]][1]) owncount++; cash[turn][1] = cash[turn][1] - price[positions[turn]][owncount+11]; cash[prop[positions[turn]][1]][1] = cash[prop[positions[turn]][1]][1] + price[positions[turn]][owncount+11]; /* gotoxy(40,20); printf("Paying2...own %d...pay %d", owncount, price[positions[turn]][owncount+11]); getch(); gotoxy(40,20); printf(" "); */ } else { if (prop[positions[turn]][1] == prop[12][1]) owncount++; if (prop[positions[turn]][1] == prop[28][1]) owncount++; cash[turn][1] = cash[turn][1] - (price[positions[turn]][owncount+11] * roll); cash[prop[positions[turn]][1]][1] = cash[prop[positions[turn]][1]][1] + price[positions[turn]][owncount+11]; /* gotoxy(1,25); printf("owns %d, pay %d", owncount, price[positions[turn]][owncount+11]); */ } if (turn == 0 && cash[turn][1] < 0) playersell(); else if (cash[turn][1] < 0) while (cash[turn][1] < 0 && cash[turn][2] > 0 ) compsell(); } else if (prop[positions[turn]][1] == turn && cash[0][1] > cash[turn][1] && cash[turn][1] > price[positions[turn]][17] + 50) { buildhouse(positions[turn]); /* add this back */ } else specialprops(); } void buildhouse(int cur) { /*int i; */ /* gotoxy(10,10); printf("Scr %d ", cur); gotoxy(10,11); printf("Pos %d ", 99); gotoxy(10,12); printf("Own %d ", prop[cur][1]); gotoxy(10,13); printf("Tur %d ", turn); */ if (prop[cur][1] == turn && price[cur][1] != -1 && prop[cur][2]<9 && prop[cur][2] != -2 && cash[turn][1] - price[cur][17] > 0) { /* gotoxy(10,15); printf("you may buy"); */ prop[cur][2]++; cash[turn][2]++; cash[turn][1] = cash[turn][1] - price[cur][17]; drawprop(); } else { /* gotoxy(10,15); printf("NO BUY! NO!"); */ if (beeping == 1) printf("\a"); } if (propview == 1) drawcard(); } void sellhouse(int cur) { if (prop[cur][1] == turn && price[cur][3] != -1 && prop[cur][2]>0) { prop[cur][2]--; cash[turn][2]--; cash[turn][1] = cash[turn][1] + price[cur][17]; drawprop(); } else { /* gotoxy(5,5); printf("ERROR1!"); */ if (beeping == 1) printf("\a"); } if (propview == 1) drawcard(); } void mortgage(int cur) { if (prop[cur][1] == turn && price[cur][16] != -1 && prop[cur][2] == 0) { /* gotoxy(5,5); printf("Mortgageable"); */ prop[cur][2] = -2; cash[turn][1] = cash[turn][1] + price[cur][16]; drawprop(); } else { if (beeping == 1) printf("\a"); } if (propview == 1) drawcard(); } void unmortgage(int cur) { /* gotoxy(80,23); printf("p1=%2d t=%2d p2=%2d"); getch(); */ if (prop[cur][1] == turn && price[cur][16] != -1 && prop[cur][2] == -2) { prop[cur][2] = 0; cash[turn][1] = cash[turn][1] - price[cur][16]; drawprop(); } else { if (beeping == 1) printf("\a"); } if (propview == 1) drawcard(); /* gotoxy(80,23); printf("p1=%2d t=%2d p2=%2d"); getch(); */ } void compbuy() { int i=0, built=0; while( i<40 && cash[turn][1] > 100 && built < 5 && cash[0][1] > cash[turn][1]) { if (prop[i][1] == turn && prop[i][2] < maxhouses && price[i][17] > 0) { buildhouse(i); i=0; built++; } else i++; } } void compsell() { int i=0; /* gotoxy(5,5); printf("I need to sell!"); */ /* printf("outside while: cash[turn][1] < 0 && cash[turn][2] > 0 : %d < 0 && %d > 0 ",cash[turn][1],cash[turn][2]); */ while ( i<40 && cash[turn][1] < 100 && cash[turn][2] > 0 ) { if (prop[i][1] == turn && prop[i][2] > 0) { sellhouse(i); i=0; } else i++; } i=0; while( i<40 && cash[turn][1] < 0 ) { if (prop[i][1] == turn && prop[i][2] == 0) { mortgage(i); i++; } else i++; } /* gotoxy(5,5); printf("Done Selling."); */ } void broke() { int i, j, swtch=0; for ( j=0 ; j 999999 ) { cash[j][1] = 999999; } } if (swtch == 1) drawprop(); } void playersell() { char playeroption; int bankr = 0; clearoptions(); optionalsale = 0; drawcard(); drawsymbols(); while (cash[0][1] < 0 && bankr == 0 ) { textcolor(15); gotoxy(52,3); cprintf("You are $%d in debt! ", cash[0][1] * -1); gotoxy(53,4); cprintf("What would you like to do?"); if (price[scroller][17] != -1 && prop[scroller][1] == turn && prop[scroller][2] > 0) textcolor(15); else textcolor(8); gotoxy(54,6); cprintf("(S)ell Houses"); if (prop[scroller][2] == 0 && prop[scroller][1] == turn) textcolor(15); else textcolor(8); gotoxy(54,7); cprintf("(M)ortgage Property"); textcolor(15); gotoxy(54,8); cprintf("(D)eclare Bankruptcy"); playeroption = getch(); if (playeroption == 0) { playeroption = getch(); if (playeroption == 75) scrollleft(); else if (playeroption == 77) scrollright(); } else if (playeroption == 's' || playeroption == 'S') sellhouse(scroller); else if (playeroption == 'm' || playeroption == 'M') mortgage(scroller); else if (playeroption == 'd' || playeroption == 'D') { /* printf("delcairing..."); */ cash[0][1] = -1; cash[0][2] = 0; broke(); /* printf("delcared."); */ bankr = 1; } } clearoptions(); showdetails(); drawsymbols(); optionalsale = 1; } void specialprops() { if (positions[turn] == 30) { positions[turn] = 10; jailed[turn] = jailstays; doubles = 0; turn++; } } void jail() { char pop = 'c'; int roll; clearoptions(); if (turn == 0) { gotoxy(40,10); printf("You are in Jail!"); gotoxy(40,11); printf("(P)ay $%d", jailfee); if (jailed[turn] == 0) textcolor(8); else textcolor(15); gotoxy(40,12); cprintf("(Space) to try to roll doubles"); } textcolor(15); while ( pop != 'p' && pop != 'P') { if (turn == 0) pop = getch(); else pop = 'p'; if ((pop == 'p' || pop == 'P')) { cash[turn][1] = cash[turn][1] - jailfee; jailed[turn] = -1; roll = makedice(); positions[turn] = (positions[turn] + roll); drawdice(roll); } else if (pop == 32 && jailed[turn] >0) { roll = makedice(); drawdice(roll); if (doubles > 3) { positions[turn] = (positions[turn] + roll); jailed[turn] = -1; pop = 'p'; doubles = 0; } else pop = 'p'; } } /* gotoxy(1,1); */ if (jailed[turn] != -1) jailed[turn]--; clearoptions(); showdetails(); drawsymbols(); } void trade(int prp) { int value, com=2, bid; int sale=0, nosale=0; int seller; int i,j; int auc_point = 1; if ( prop[prp][1] != -1 && prop[prp][1] != 0 ) { /* printf("trying to buy PROP!!!!!!"); */ /* getch(); */ clearoptions(); optionalsale = 0; drawcard(); optionalsale = 1; /* gotoxy(54,15); printf("c.v: "); */ value = (cash[turn][1] - cash[prop[prp][1]][1])/10; if (value<0) value = value * -1; value = value + price[prp][0]; if ( prop[prp][2] > 0) value = value + ((price[prp][17] * prop[prp][2]) + 5 ); else if ( prop[prp][2] == -2) value = value - price[prp][16]; value = value * difficulty; gotoxy(1,1); printf("price = %d", value); while ( com != 27 && sale==0 && nosale==0 ) { gotoxy(53,11); printf("(B)id"); gotoxy(53,12); printf("(A)utobid ($100's)"); gotoxy(53,13); printf("(W)ithdraw"); com = getch(); if (com == 'b' || com == 'B') { gotoxy(53,11); textcolor(8); cprintf("(B)id"); textcolor(15); gotoxy(60,11); cprintf("Enter Bid: $"); bid = GetDollars(); if ( bid > cash[0][1] ) { printf("You don't have that much cash."); } else if ( bid > value ) { printf("SOLD!"); sale = 1; seller = prop[prp][1]; prop[prp][1] = 0; cash[seller][1] = cash[seller][1] + bid; cash[0][1] = cash[0][1] - bid; } else printf("No Sale."); } else if ( com == 'a' || com == 'A' ) { bid = 0; while ( bid < value && cash[0][1] >= bid ) { gotoxy(60,18); printf("%ld",bid); for ( i=(speed * -3000) ; i<(speed * 3000) ; i++ ) for ( j=(speed * -3000) ; j<(speed * 3000) ; j++ ) ; bid += 100; } if ( bid <= cash[0][1] ) { printf("SOLD!"); sale = 1; seller = prop[prp][1]; prop[prp][1] = 0; cash[seller][1] = cash[seller][1] + bid; cash[0][1] = cash[0][1] - bid; } else printf("you dont have enough cash"); } else if ( com == 'w' || com == 'W' ) { nosale = 1; } } clearoptions(); drawcard(); } else if ( prop[prp][1] != -1 && prop[prp][1] == 0 ) { /* printf("AUCTIONING PROP!!!"); */ /* getch(); */ textcolor(15); for ( j=2 ; j<25 ; j++ ) { gotoxy(52,j); for ( i=1 ; i<29 ; i++ ) cprintf(" "); } /* clearoptions(); */ gotoxy(52,2); printf("Select Trade Arrangement:"); for ( i=1 ; i 0) value = value + (price[prp][17] * prop[prp][2]); value = value - ( ( cash[0][1] - cash[i][1] + ( ( cash[0][2] - cash[i][2] ) * 50 ) ) / 10 ); value = value * 9 / ( 9 + difficulty ); if ( cash[i][1] < value ) { if ( value / 2 < cash[i][1] ) value = value / 2; else if ( cash[i][1] > 1 ) value = 1; else value = 0; } /* else if */ } else { value = 0; } gotoxy(54,3+i); printf("Player %d's offer: $%d ", i+1, value); } gotoxy(54,3+players); printf("Reject All"); do { gotoxy(52,auc_point+2); printf(" "); gotoxy(52,auc_point+3); printf("%c",16); gotoxy(52,auc_point+4); printf(" "); com = getch(); if ( com == 0 ) { com = getch(); if ( com == 80 && auc_point < players ) auc_point++; else if ( com == 72 && auc_point-1 > 0 ) auc_point--; } } while ( com != 13 ); if ( auc_point == players ) printf("Rejected all"); else if ( cash[auc_point][1] == -1 ) printf("Cannot Trade With Broke Players!"); else printf("trade with player %d", auc_point ); } else { printf("\a"); } /* clearoptions(); */ /* drawcard(); */ } long GetDollars() { char chr; long dollars = 0; do { chr = getch(); if ( chr >= '0' && chr <= '9' && ( (dollars * 10) + chr - '0' < 1000000) && ( (dollars * 10) + chr - '0' > dollars ) ) { printf("%c", chr); dollars = (dollars * 10) + chr - '0'; } if ( chr == '\b' && dollars > 0 ) { printf("\b \b"); dollars = dollars/10; } } while ( chr != 13 && chr != 27 ); /* printf("end result: %ld ", dollars); */ if ( chr == 13 ) { return dollars; } else { return 0; } } void displayexit( int winner ) { int i,j; /* gotoxy(30,3); */ for ( i=3 ; i<24 ; i++ ) { gotoxy(30,i); for ( j=0 ; j<46 ; j++ ) printf(" "); } for ( i=0 ; i<21 ; i++ ) { charxy(186,29,i+3); charxy(186,76,i+3); } for ( i=0 ; i<46 ; i++ ) { charxy(205,i+30,2); charxy(205,i+30,24); } charxy(201,29,2); charxy(187,76,2); charxy(200,29,24); charxy(188,76,24); if( winner == 1 ) { gotoxy(48,12); printf("You won!"); } else { gotoxy(48,12); printf("You lost!"); } gotoxy(43,13); printf("Press ESC to exit..."); /* while ( getch() != 27 ) ...add this back!!!!!! */ /* printf("\a"); */ }