| Rules Applied | JavaKeywordRule | app0.txt | PPspaceRule | PPifndefRule | PPRule | PPdefineRule.DefineReplacementRule | snippets0b.txt | TypedefRule.DefineReplacementRule | FunctionPointerReferenceRule | OneDeclarationPerLineRule | ArrayDeclaration0Rule | AddBracesRule | LabelRemoverRule | voidstarsnippet.txt | ConflictingVariableDeclarationRule | StaticVariablesRule | StaticFunctionsRule | CharToShortRule | snippets0f.txt | MultipleAssignmentRule | ArrayDeclarationRule | StringRule | ZeroAssignmentRule | DeclarationAssignmentRule | PointerRule | ArrayIndexRule | BooleanUsageRule | ForceToBooleanRule | snippets1.txt | snippets2.txt | snippets2a.txt | snippets3.txt | ElseIfRule | PrintfRule | SprintfRule | stdin.txt | UninitializedVariableRule | InsertClassRule | (Final Version) | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| JavaKeywordRule app0.txt PPspaceRule PPifndefRule PPRule PPdefineRule.DefineReplacementRule snippets0b.txt TypedefRule.DefineReplacementRule FunctionPointerReferenceRule OneDeclarationPerLineRule ArrayDeclaration0Rule AddBracesRule LabelRemoverRule voidstarsnippet.txt ConflictingVariableDeclarationRule StaticVariablesRule StaticFunctionsRule CharToShortRule snippets0f.txt MultipleAssignmentRule ArrayDeclarationRule StringRule ZeroAssignmentRule DeclarationAssignmentRule PointerRule ArrayIndexRule BooleanUsageRule ForceToBooleanRule snippets1.txt snippets2.txt snippets2a.txt snippets3.txt ElseIfRule PrintfRule SprintfRule stdin.txt UninitializedVariableRule InsertClassRule final | #ifndef lint
static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
#endif
# include "monop.ext"
static char * names[N_MON + 2],
cur_prop[80];
static MON * monops[N_MON];
void buy_houses(void) {
regint num_mon;
reg MON * mp;
reg OWN * op;
bool good,
got_morg;
int i,
p;
over:do {
num_mon = 0;
good = TRUE;
got_morg = FALSE;
for (op = cur_p->own_list;op && op->sqr->type != PRPTY;op = op->next) continue;
while (op) if (op->sqr->desc->monop) {
mp = op->sqr->desc->mon_desc;
names[num_mon] = (monops[num_mon] = mp)->name;
num_mon++;
got_morg = good = FALSE;
for (i = 0;i < mp->num_in;i++) {
if (op->sqr->desc->morg) got_morg++;
if (op->sqr->desc->houses != 5) good++;
op = op->next;
}
if (!good || got_morg)--num_mon;
}
else op = op->next;
if (num_mon == 0) {
if (got_morg) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (num_mon == 1) buy_h(monops[0]);
else {
names[num_mon++] = "done";
names[num_mon--] = 0;
if ((p = getinp("Which property do you wish to buy houses for? ", names)) == num_mon) return;
buy_h(monops[p]);
continue;
}
}
while (false);
}
void buy_h(MON * mnp) {
regint i;
reg MON * mp;
regint price;
shrt input[3],
temp[3];
int tot;
PROP * pp;
mp = mnp;
price = mp->h_cost * 50;
blew_it:do {
list_cur(mp);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < mp->num_in;i++) {
pp = mp->sq[i]->desc;
over:if (pp->houses == 5) {
printf("%s (H):\n", mp->sq[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(cur_prop, "%s (%d): ", mp->sq[i]->name, pp->houses);
input[i] = get_int(cur_prop);
temp[i] = input[i] + pp->houses;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - pp->houses);
continue;
}
}
if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (tot = i = 0;i < mp->num_in;i++) tot += input[i];
if (tot) {
printf("You asked for %d houses for $%d\n", tot, tot * price);
if (getyn("Is that ok? ") == 0) {
cur_p->money -= tot * price;
for (tot = i = 0;i < mp->num_in;i++) mp->sq[i]->desc->houses = temp[i];
}
}
}
void sell_houses(void) {
regint num_mon;
reg MON * mp;
reg OWN * op;
bool good;
int p;
over:do {
num_mon = 0;
good = TRUE;
for (op = cur_p->own_list;op;op = op->next) if (op->sqr->type == PRPTY && op->sqr->desc->monop) {
mp = op->sqr->desc->mon_desc;
names[num_mon] = (monops[num_mon] = mp)->name;
num_mon++;
good = 0;
do if (!good && op->sqr->desc->houses != 0) good++;
while (op->next && op->sqr->desc->mon_desc == mp && (op = op->next));
if (!good)--num_mon;
}
if (num_mon == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (num_mon == 1) sell_h(monops[0]);
else {
names[num_mon++] = "done";
names[num_mon--] = 0;
if ((p = getinp("Which property do you wish to sell houses from? ", names)) == num_mon) return;
sell_h(monops[p]);
notify1();
continue;
}
}
while (false);
}
void sell_h(MON * mnp) {
regint i;
reg MON * mp;
regint price;
shrt input[3],
temp[3];
int tot;
PROP * pp;
mp = mnp;
price = mp->h_cost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
list_cur(mp);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < mp->num_in;i++) {
pp = mp->sq[i]->desc;
over:if (pp->houses == 0) {
printf("%s (0):\n", mp->sq[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (pp->houses < 5) (void) sprintf(cur_prop, "%s (%d): ", mp->sq[i]->name, pp->houses);
else (void) sprintf(cur_prop, "%s (H): ", mp->sq[i]->name);
input[i] = get_int(cur_prop);
temp[i] = pp->houses - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", pp->houses);
continue;
}
}
if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (tot = i = 0;i < mp->num_in;i++) tot += input[i];
if (tot) {
printf("You asked to sell %d houses for $%d\n", tot, tot * price);
if (getyn("Is that ok? ") == 0) {
cur_p->money += tot * price;
for (tot = i = 0;i < mp->num_in;i++) mp->sq[i]->desc->houses = temp[i];
}
}
}
void list_cur(register MON * mp) {
regint i;
reg SQUARE * sqp;
for (i = 0;i < mp->num_in;i++) {
sqp = mp->sq[i];
if (sqp->desc->houses == 5) printf("%s (H) ", sqp->name);
else printf("%s (%d) ", sqp->name, sqp->desc->houses);
}
putchar('\n');
}
| #ifndef lint
static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
#endif
# include "monop.ext"
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
mortgagedPropertyCount = FALSE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = FALSE;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(register MON * monopoly) {
regint i;
reg SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| #ifndef lint
static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
#endif
#include "monop.ext"
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
mortgagedPropertyCount = FALSE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = FALSE;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(register MON * monopoly) {
regint i;
reg SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| #if !defined(lint)
static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
#endif
#include "monop.ext"
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
mortgagedPropertyCount = FALSE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = FALSE;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(register MON * monopoly) {
regint i;
reg SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
mortgagedPropertyCount = FALSE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = FALSE;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
regint numberOfMonopolies;
reg MON * monopoly;
reg OWN * propertyList;
bool good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = TRUE;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
regint i;
reg MON * monopoly;
regint price;
shrt input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(register MON * monopoly) {
regint i;
reg SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
register int numberOfMonopolies;
register MON * monopoly;
register OWN * propertyList;
boolean good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
register int i;
register MON * monopoly;
register int price;
char input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
register int numberOfMonopolies;
register MON * monopoly;
register OWN * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
register int i;
register MON * monopoly;
register int price;
char input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(register MON * monopoly) {
register int i;
register SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static MON * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
int numberOfMonopolies;
MON * monopoly;
OWN * propertyList;
boolean good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(MON * _monopoly) {
int i;
MON * monopoly;
int price;
char input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
int numberOfMonopolies;
MON * monopoly;
OWN * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(MON * _monopoly) {
int i;
MON * monopoly;
int price;
char input[3],
temp[3];
int total;
PROP * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(MON * monopoly) {
int i;
SQUARE * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static Monopoly * monops[NUMBER_OF_MONOPOLIES];
void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3],
temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3],
temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2],
currentProperty[80];
static Monopoly * monops[NUMBER_OF_MONOPOLIES];
public static void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good,
mortgagedPropertyCount;
int i,
propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3],
temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
public static void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3],
temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char sccsid[] = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static char * names[NUMBER_OF_MONOPOLIES + 2];
static char currentProperty[80];
static Monopoly * monops[NUMBER_OF_MONOPOLIES];
public static void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
boolean mortgagedPropertyCount;
int i;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3];
char temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
public static void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char input[3];
char temp[3];
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char[] sccsid = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static String[NUMBER_OF_MONOPOLIES + 2] names;
static char[80] currentProperty;
static Monopoly[NUMBER_OF_MONOPOLIES] * monops;
public static void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
boolean mortgagedPropertyCount;
int i;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) continue;
while (propertyList) if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) mortgagedPropertyCount++;
if (propertyList->square1->description->houseCount != 5) good++;
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount)--numberOfMonopolies;
}
else propertyList = propertyList->next;
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) printf("You can't build on mortgaged monopolies.\n");
else if (!good) printf("You can't build any more.\n");
else printf("But you don't have any monopolies!!\n");
return;
}
if (numberOfMonopolies == 1) buyHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) return;
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
public static void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do if (!good && propertyList->square1->description->houseCount != 0) good++;
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good)--numberOfMonopolies;
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) sellHouse(monops[0]);
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) return;
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) (void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
else (void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) total += input[i];
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) printf("%s (H) ", square->name);
else printf("%s (%d) ", square->name, square->description->houseCount);
}
putchar('\n');
}
| static char[] sccsid = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static String[NUMBER_OF_MONOPOLIES + 2] names;
static char[80] currentProperty;
static Monopoly[NUMBER_OF_MONOPOLIES] * monops;
public static void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
boolean mortgagedPropertyCount;
int i;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) {
continue;
}
while (propertyList) {
if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) {
mortgagedPropertyCount++;
}
if (propertyList->square1->description->houseCount != 5) {
good++;
}
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount) {
--numberOfMonopolies;
}
}
else {
propertyList = propertyList->next;
}
}
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) {
printf("You can't build on mortgaged monopolies.\n");
}
else {
if (!good) {
printf("You can't build any more.\n");
}
else {
printf("But you don't have any monopolies!!\n");
}
}
return;
}
if (numberOfMonopolies == 1) {
buyHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) {
return;
}
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
blew_it:do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
public static void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
over:do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do {
if (!good && propertyList->square1->description->houseCount != 0) {
good++;
}
}
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good) {
--numberOfMonopolies;
}
}
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) {
sellHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) {
return;
}
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
blew_it:do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
over:if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) {
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
}
else {
(void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
}
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
err:printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) {
printf("%s (H) ", square->name);
}
else {
printf("%s (%d) ", square->name, square->description->houseCount);
}
}
putchar('\n');
}
| static char[] sccsid = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static String[NUMBER_OF_MONOPOLIES + 2] names;
static char[80] currentProperty;
static Monopoly[NUMBER_OF_MONOPOLIES] * monops;
public static void buyHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
boolean mortgagedPropertyCount;
int i;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) {
continue;
}
while (propertyList) {
if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) {
mortgagedPropertyCount++;
}
if (propertyList->square1->description->houseCount != 5) {
good++;
}
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount) {
--numberOfMonopolies;
}
}
else {
propertyList = propertyList->next;
}
}
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) {
printf("You can't build on mortgaged monopolies.\n");
}
else {
if (!good) {
printf("You can't build any more.\n");
}
else {
printf("But you don't have any monopolies!!\n");
}
}
return;
}
if (numberOfMonopolies == 1) {
buyHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) {
return;
}
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
public static void sellHouses(void) {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do {
if (!good && propertyList->square1->description->houseCount != 0) {
good++;
}
}
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good) {
--numberOfMonopolies;
}
}
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) {
sellHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) {
return;
}
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) {
(void) sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
}
else {
(void) sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
}
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) {
printf("%s (H) ", square->name);
}
else {
printf("%s (%d) ", square->name, square->description->houseCount);
}
}
putchar('\n');
}
| static char[] sccsid = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static String[NUMBER_OF_MONOPOLIES + 2] names;
static char[80] currentProperty;
static Monopoly[NUMBER_OF_MONOPOLIES] * monops;
public static void buyHouses() {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
boolean mortgagedPropertyCount;
int i;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount = false;
for (propertyList = currentPlayer->ownedPropertyList;propertyList && propertyList->square1->type != TYPE_PROPERTY;propertyList = propertyList->next) {
continue;
}
while (propertyList) {
if (propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList->square1->description->isMortgaged) {
mortgagedPropertyCount++;
}
if (propertyList->square1->description->houseCount != 5) {
good++;
}
propertyList = propertyList->next;
}
if (!good || mortgagedPropertyCount) {
--numberOfMonopolies;
}
}
else {
propertyList = propertyList->next;
}
}
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount) {
printf("You can't build on mortgaged monopolies.\n");
}
else {
if (!good) {
printf("You can't build any more.\n");
}
else {
printf("But you don't have any monopolies!!\n");
}
}
return;
}
if (numberOfMonopolies == 1) {
buyHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) {
return;
}
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
public static void sellHouses() {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList;
boolean good;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY && propertyList->square1->description->isMonopoly) {
monopoly = propertyList->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do {
if (!good && propertyList->square1->description->houseCount != 0) {
good++;
}
}
while (propertyList->next && propertyList->square1->description->monopolyDescription == monopoly && (propertyList = propertyList->next));
if (!good) {
--numberOfMonopolies;
}
}
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) {
sellHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) {
return;
}
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) {
sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
}
else {
sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
}
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square = monopoly->squares[i];
if (square->description->houseCount == 5) {
printf("%s (H) ", square->name);
}
else {
printf("%s (%d) ", square->name, square->description->houseCount);
}
}
putchar('\n');
}
| static char[] sccsid = "@(#)houses.c 5.5 (Berkeley) 6/1/90";
static String[NUMBER_OF_MONOPOLIES + 2] names;
static char[80] currentProperty;
static Monopoly[NUMBER_OF_MONOPOLIES] * monops;
public static void buyHouses() {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList2;
boolean good;
boolean mortgagedPropertyCount1;
int i;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
mortgagedPropertyCount1 = false;
for (propertyList2 = currentPlayer->ownedPropertyList;propertyList2 && propertyList2->square1->type != TYPE_PROPERTY;propertyList2 = propertyList2->next) {
continue;
}
while (propertyList2) {
if (propertyList2->square1->description->isMonopoly) {
monopoly = propertyList2->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
mortgagedPropertyCount1 = good = false;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
if (propertyList2->square1->description->isMortgaged) {
mortgagedPropertyCount1++;
}
if (propertyList2->square1->description->houseCount != 5) {
good++;
}
propertyList2 = propertyList2->next;
}
if (!good || mortgagedPropertyCount1) {
--numberOfMonopolies;
}
}
else {
propertyList2 = propertyList2->next;
}
}
if (numberOfMonopolies == 0) {
if (mortgagedPropertyCount1) {
printf("You can't build on mortgaged monopolies.\n");
}
else {
if (!good) {
printf("You can't build any more.\n");
}
else {
printf("But you don't have any monopolies!!\n");
}
}
return;
}
if (numberOfMonopolies == 1) {
buyHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to buy houses for? ", names)) == numberOfMonopolies) {
return;
}
buyHouse(monops[propertyIndex]);
continue;
}
}
while (false);
}
void buyHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 50;
do {
printCurrentHouses(monopoly);
printf("Houses will cost $%d\n", price);
printf("How many houses do you wish to buy for\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 5) {
printf("%s (H):\n", monopoly->squares[i]->name);
input[i] = 0;
temp[i] = 5;
continue;
}
sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
input[i] = getInteger(currentProperty);
temp[i] = input[i] + property->houseCount;
if (temp[i] > 5) {
printf("That's too many. The most you can buy is %d\n", 5 - property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked for %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money -= total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
public static void sellHouses() {
int numberOfMonopolies;
Monopoly * monopoly;
OwnedPropertyList * propertyList3;
boolean good;
int propertyIndex;
do {
numberOfMonopolies = 0;
good = true;
for (propertyList3 = currentPlayer->ownedPropertyList;propertyList3;propertyList3 = propertyList3->next) {
if (propertyList3->square1->type == TYPE_PROPERTY && propertyList3->square1->description->isMonopoly) {
monopoly = propertyList3->square1->description->monopolyDescription;
names[numberOfMonopolies] = (monops[numberOfMonopolies] = monopoly)->name;
numberOfMonopolies++;
good = 0;
do {
if (!good && propertyList3->square1->description->houseCount != 0) {
good++;
}
}
while (propertyList3->next && propertyList3->square1->description->monopolyDescription == monopoly && (propertyList3 = propertyList3->next));
if (!good) {
--numberOfMonopolies;
}
}
}
if (numberOfMonopolies == 0) {
printf("You don't have any houses to sell!!\n");
return;
}
if (numberOfMonopolies == 1) {
sellHouse(monops[0]);
}
else {
names[numberOfMonopolies++] = "done";
names[numberOfMonopolies--] = 0;
if ((propertyIndex = getinp("Which property do you wish to sell houses from? ", names)) == numberOfMonopolies) {
return;
}
sellHouse(monops[propertyIndex]);
notify1();
continue;
}
}
while (false);
}
void sellHouse(Monopoly * _monopoly) {
int i;
Monopoly * monopoly;
int price;
char[3] input;
char[3] temp;
int total;
Property * property;
monopoly = _monopoly;
price = monopoly->houseCost * 25;
do {
printf("Houses will get you $%d apiece\n", price);
printCurrentHouses(monopoly);
printf("How many houses do you wish to sell from\n");
for (i = 0;i < monopoly->housesInMonopoly;i++) {
property = monopoly->squares[i]->description;
if (property->houseCount == 0) {
printf("%s (0):\n", monopoly->squares[i]->name);
input[i] = temp[i] = 0;
continue;
}
if (property->houseCount < 5) {
sprintf(currentProperty, "%s (%d): ", monopoly->squares[i]->name, property->houseCount);
}
else {
sprintf(currentProperty, "%s (H): ", monopoly->squares[i]->name);
}
input[i] = getInteger(currentProperty);
temp[i] = property->houseCount - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", property->houseCount);
continue;
}
}
if (monopoly->housesInMonopoly == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
printf("That makes the spread too wide. Try again\n");
continue;
}
else {
if (monopoly->housesInMonopoly == 2 && abs(temp[0] - temp[1]) > 1) {
printf("That makes the spread too wide. Try again\n");
continue;
}
}
}
while (false);
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
total += input[i];
}
if (total) {
printf("You asked to sell %d houses for $%d\n", total, total * price);
if (getYesOrNo("Is that ok? ") == 0) {
currentPlayer->money += total * price;
for (total = i = 0;i < monopoly->housesInMonopoly;i++) {
monopoly->squares[i]->description->houseCount = temp[i];
}
}
}
}
void printCurrentHouses(Monopoly * monopoly) {
int i;
Square * square2;
for (i = 0;i < monopoly->housesInMonopoly;i++) {
square2 = monopoly->squares[i];
if (square2->description->houseCount == 5) {
printf("%s (H) ", square2->name);
}
else {
printf("%s (%d) ", sq |