home *** CD-ROM | disk | FTP | other *** search
- /* f13.c contains these functions for monopoly:
- canbuild(), cansell(), canmorg(), canlift() */
-
- #include "mono:defines"
- #include "mono:xvariables"
-
- BOOL canmorg(who)
- USHORT who;
- {
- USHORT iter;
-
- for (iter=0; iter<40; iter++)
- {
- if ( (owner[iter] == who) && (numhouses[iter] == 0) ) return(TRUE);
- }
- return(FALSE);
- }
-
- BOOL canlift(who)
- USHORT who;
- {
- USHORT iter;
-
- for (iter=0; iter<40; iter++)
- {
- if ( (owner[iter] == who) && (ismorg[iter]) ) return(TRUE);
- }
- return(FALSE);
- }
-
-
- BOOL canbuild(who)
- USHORT who;
- {
-
- if ( (owner[1] == who) && (ismono[1]) )
- {
- if ( (!ismorg[1]) && (numhouses[1] < 5) ) return(TRUE);
- if ( (!ismorg[3]) && (numhouses[3] < 5) ) return(TRUE);
- }
- if ( (owner[6] == who) && (ismono[6]) )
- {
- if ( (!ismorg[6]) && (numhouses[6] < 5) ) return(TRUE);
- if ( (!ismorg[8]) && (numhouses[8] < 5) ) return(TRUE);
- if ( (!ismorg[9]) && (numhouses[9] < 5) ) return(TRUE);
- }
- if ( (owner[11] == who) && (ismono[11]) )
- {
- if ( (!ismorg[11]) && (numhouses[11] < 5) ) return(TRUE);
- if ( (!ismorg[13]) && (numhouses[13] < 5) ) return(TRUE);
- if ( (!ismorg[14]) && (numhouses[14] < 5) ) return(TRUE);
- }
- if ( (owner[16] == who) && (ismono[16]) )
- {
- if ( (!ismorg[16]) && (numhouses[16] < 5) ) return(TRUE);
- if ( (!ismorg[18]) && (numhouses[18] < 5) ) return(TRUE);
- if ( (!ismorg[19]) && (numhouses[19] < 5) ) return(TRUE);
- }
- if ( (owner[21] == who) && (ismono[21]) )
- {
- if ( (!ismorg[21]) && (numhouses[21] < 5) ) return(TRUE);
- if ( (!ismorg[23]) && (numhouses[23] < 5) ) return(TRUE);
- if ( (!ismorg[24]) && (numhouses[24] < 5) ) return(TRUE);
- }
- if ( (owner[26] == who) && (ismono[26]) )
- {
- if ( (!ismorg[26]) && (numhouses[26] < 5) ) return(TRUE);
- if ( (!ismorg[27]) && (numhouses[27] < 5) ) return(TRUE);
- if ( (!ismorg[29]) && (numhouses[29] < 5) ) return(TRUE);
- }
- if ( (owner[31] == who) && (ismono[31]) )
- {
- if ( (!ismorg[31]) && (numhouses[31] < 5) ) return(TRUE);
- if ( (!ismorg[32]) && (numhouses[32] < 5) ) return(TRUE);
- if ( (!ismorg[34]) && (numhouses[34] < 5) ) return(TRUE);
- }
- if ( (owner[37] == who) && (ismono[37]) )
- {
- if ( (!ismorg[37]) && (numhouses[37] < 5) ) return(TRUE);
- if ( (!ismorg[39]) && (numhouses[39] < 5) ) return(TRUE);
- }
- return(FALSE);
- }
-
- BOOL cansell(who)
- USHORT who;
- {
-
- if ( (owner[1] == who) && (numhouses[1] > 0) ) return(TRUE);
- if ( (owner[3] == who) && (numhouses[3] > 0) ) return(TRUE);
- if ( (owner[6] == who) && (numhouses[6] > 0) ) return(TRUE);
- if ( (owner[8] == who) && (numhouses[8] > 0) ) return(TRUE);
- if ( (owner[9] == who) && (numhouses[9] > 0) ) return(TRUE);
- if ( (owner[16] == who) && (numhouses[16] > 0) ) return(TRUE);
- if ( (owner[18] == who) && (numhouses[18] > 0) ) return(TRUE);
- if ( (owner[19] == who) && (numhouses[19] > 0) ) return(TRUE);
- if ( (owner[21] == who) && (numhouses[21] > 0) ) return(TRUE);
- if ( (owner[23] == who) && (numhouses[23] > 0) ) return(TRUE);
- if ( (owner[24] == who) && (numhouses[24] > 0) ) return(TRUE);
- if ( (owner[26] == who) && (numhouses[26] > 0) ) return(TRUE);
- if ( (owner[27] == who) && (numhouses[27] > 0) ) return(TRUE);
- if ( (owner[29] == who) && (numhouses[29] > 0) ) return(TRUE);
- if ( (owner[31] == who) && (numhouses[31] > 0) ) return(TRUE);
- if ( (owner[32] == who) && (numhouses[32] > 0) ) return(TRUE);
- if ( (owner[34] == who) && (numhouses[34] > 0) ) return(TRUE);
- if ( (owner[27] == who) && (numhouses[27] > 0) ) return(TRUE);
- if ( (owner[39] == who) && (numhouses[39] > 0) ) return(TRUE);
- return(FALSE);
- }
-
- USHORT ahead()
- {
- int iter;
- USHORT biggest;
-
- net_worth[0]=0L;
- net_worth[1]=0L;
- net_worth[2]=0L;
- net_worth[3]=0L;
-
- net_worth[0]+=bankroll[0];
- net_worth[1]+=bankroll[1];
- net_worth[2]+=bankroll[2];
- net_worth[3]+=bankroll[3];
-
- net_worth[0]+=(freecard[0] * 50);
- net_worth[1]+=(freecard[1] * 50);
- net_worth[2]+=(freecard[2] * 50);
- net_worth[3]+=(freecard[3] * 50);
-
- for (iter=0; iter<40; iter++)
- {
- if (owner[iter] == 0)
- {
- net_worth[0]+=(numhouses[iter] * housecost[iter]);
- if (ismorg[iter]) net_worth[0]+=(propcost[iter] /2);
- else net_worth[0]+=propcost[iter];
- }
- if (owner[iter] == 1)
- {
- net_worth[1]+=(numhouses[iter] * housecost[iter]);
- if (ismorg[iter]) net_worth[1]+=(propcost[iter] /2);
- else net_worth[1]+=propcost[iter];
- }
- if (owner[iter] == 2)
- {
- net_worth[2]+=(numhouses[iter] * housecost[iter]);
- if (ismorg[iter]) net_worth[2]+=(propcost[iter] /2);
- else net_worth[2]+=propcost[iter];
- }
- if (owner[iter] == 3)
- {
- net_worth[3]+=(numhouses[iter] * housecost[iter]);
- if (ismorg[iter]) net_worth[3]+=(propcost[iter] /3);
- else net_worth[3]+=propcost[iter];
- }
- }
-
- if (notplaying[0]) net_worth[0]=0;
- if (notplaying[1]) net_worth[1]=0;
- if (notplaying[2]) net_worth[2]=0;
- if (notplaying[3]) net_worth[3]=0;
-
- if (net_worth[0] >= net_worth[1]) biggest=0;
- else biggest=1;
-
- if (net_worth[biggest] <= net_worth[2]) biggest=2;
- if (net_worth[biggest] <= net_worth[3]) biggest=3;
-
- if (biggest == 0)
- {
- if ( (net_worth[0] == net_worth[1]) || (net_worth[0] == net_worth[2]) || (net_worth[0] == net_worth[3]) )
- return(5);
- }
- if (biggest == 1)
- {
- if ( (net_worth[1] == net_worth[0]) || (net_worth[1] == net_worth[2]) || (net_worth[1] == net_worth[3]) )
- return(5);
- }
- if (biggest == 2)
- {
- if ( (net_worth[2] == net_worth[0]) || (net_worth[2] == net_worth[1]) || (net_worth[2] == net_worth[3]) )
- return(5);
- }
- if (biggest == 3)
- {
- if ( (net_worth[3] == net_worth[0]) || (net_worth[3] == net_worth[1]) || (net_worth[3] == net_worth[2]) )
- return(5);
- }
- return(biggest);
- }
-