| Rules Applied | JavaKeywordRule | app0.txt | PPspaceRule | PPifndefRule | PPRule | PPdefineRule.DefineReplacementRule | snippets0.txt | snippets0b.txt | TypedefRule.DefineReplacementRule | OneDeclarationPerLineRule | ConflictingFileAndVariableRule | SizeofRule | ArrayDeclaration0Rule | AddBracesRule | LabelRemoverRule | voidstarsnippet.txt | ConflictingVariableDeclarationRule | StaticVariablesRule | StaticFunctionsRule | pointercast.txt | CharToShortRule | fileIO.txt | ShorthandOperatorsRule | snippets0f.txt | MultipleAssignmentRule | ArrayDeclarationRule | StringRule | CallocRule | ZeroComparisonRule | DeclarationAssignmentRule | PointerRule | LossOfPrecisionRule | ForceToBooleanRule | ErrorHandlingRule | FopenRule | FreadRule | snippets2.txt | snippets2a.txt | snippets3.txt | PrintfRule | stdin.txt | IOExceptionRule | UninitializedVariableRule | InsertClassRule | ImportRule | (Final Version) | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| JavaKeywordRule app0.txt PPspaceRule PPifndefRule PPRule PPdefineRule.DefineReplacementRule snippets0.txt snippets0b.txt TypedefRule.DefineReplacementRule OneDeclarationPerLineRule ConflictingFileAndVariableRule SizeofRule ArrayDeclaration0Rule AddBracesRule LabelRemoverRule voidstarsnippet.txt ConflictingVariableDeclarationRule StaticVariablesRule StaticFunctionsRule pointercast.txt CharToShortRule fileIO.txt ShorthandOperatorsRule snippets0f.txt MultipleAssignmentRule ArrayDeclarationRule StringRule CallocRule ZeroComparisonRule DeclarationAssignmentRule PointerRule LossOfPrecisionRule ForceToBooleanRule ErrorHandlingRule FopenRule FreadRule snippets2.txt snippets2a.txt snippets3.txt PrintfRule stdin.txt IOExceptionRule UninitializedVariableRule InsertClassRule ImportRule final | #ifndef lint
static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
#endif
# include "monop.ext"
# include "pathnames.h"
# define GOJF 'F' /* char for get-out-of-jail-free cards */
# ifndef DEV
static char * cardfile = _PATH_CARDS;
# else
static char * cardfile = "cards.pck";
# endif
static FILE * deckf;
void init_decks(void) {
if ((deckf = fopen(cardfile, "r")) == NULL) {
file_err:perror(cardfile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckf) != 2) {
perror(cardfile);
exit(1);
}
set_up( & CC_D);
set_up( & CH_D);
}
void set_up(DECK * dp) {
regint r1,
r2;
int i;
dp->offsets = (long * ) calloc(sizeof (long) , dp->num_cards);
if (fread(dp->offsets, sizeof (long) , dp->num_cards, deckf) != dp->num_cards) {
perror(cardfile);
exit(1);
}
dp->last_card = 0;
dp->gojf_used = FALSE;
for (i = 0;i < dp->num_cards;i++) {
reglong temp;
r1 = roll(1, dp->num_cards) - 1;
r2 = roll(1, dp->num_cards) - 1;
temp = dp->offsets[r2];
dp->offsets[r2] = dp->offsets[r1];
dp->offsets[r1] = temp;
}
}
void get_card(DECK * dp) {
regchar type_maj,
type_min;
regint num;
int i,
per_h,
per_H,
num_h,
num_H;
OWN * op;
do {
fseek(deckf, dp->offsets[dp->last_card], 0);
dp->last_card =++(dp->last_card) % dp->num_cards;
type_maj = getc(deckf);
}
while (dp->gojf_used && type_maj == GOJF);
type_min = getc(deckf);
num = getw(deckf);
printmes();
switch (type_maj) {
case '+':
if (type_min == 'A') {
for (i = 0;i < num_play;i++) if (i != player) play[i].money -= num;
num = num * (num_play - 1);
}
cur_p->money += num;
break;
case '-':
if (type_min == 'A') {
for (i = 0;i < num_play;i++) if (i != player) play[i].money += num;
num = num * (num_play - 1);
}
cur_p->money -= num;
break;
case 'M':
switch (type_min) {
case 'F':
num -= cur_p->loc;
if (num < 0) num += 40;
break;
case 'J':
goto_jail();
return;
case 'R':
spec = TRUE;
num = (int) ((cur_p->loc + 5) / 10) * 10 + 5 - cur_p->loc;
break;
case 'U':
spec = TRUE;
if (cur_p->loc >= 12 && cur_p->loc < 28) num = 28 - cur_p->loc;
else {
num = 12 - cur_p->loc;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (dp == & CC_D) {
per_h = 40;
per_H = 115;
}
else {
per_h = 25;
per_H = 100;
}
num_h = num_H = 0;
for (op = cur_p->own_list;op;op = op->next) if (op->sqr->type == PRPTY) if (op->sqr->desc->houses == 5)++num_H;
else num_h += op->sqr->desc->houses;
num = per_h * num_h + per_H * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) lucky("");
else cur_p->money -= num;
break;
case GOJF:
cur_p->num_gojf++;
dp->gojf_used = TRUE;
break;
}
spec = FALSE;
}
void printmes(void) {
regchar c;
printline();
fflush(stdout);
while ((c = getc(deckf)) != '\0') putchar(c);
printline();
fflush(stdout);
}
| #ifndef lint
static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
#endif
# include "monop.ext"
# include "pathnames.h"
# define GOJF 'F' /* char for get-out-of-jail-free cards */
# ifndef DEV
static char * cardFile = CARD_FILE;
# else
static char * cardFile = "cards.pck";
# endif
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == NULL) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & CC_D);
shuffleDeck( & CH_D);
}
void shuffleDeck(DECK * cardDeck) {
regint r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = FALSE;
for (i = 0;i < cardDeck->numCards;i++) {
reglong temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
regchar majorType,
minorType;
regint num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = TRUE;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = TRUE;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & CC_D) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = TRUE;
break;
}
isSpecialCard = FALSE;
}
void printCardMessage(void) {
regchar c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| #ifndef lint
static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
#endif
#include "monop.ext"
#include "pathnames.h"
#define GOJF 'F' /* char for get-out-of-jail-free cards */
#ifndef DEV
static char * cardFile = CARD_FILE;
#else
static char * cardFile = "cards.pck";
#endif
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == NULL) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & CC_D);
shuffleDeck( & CH_D);
}
void shuffleDeck(DECK * cardDeck) {
regint r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = FALSE;
for (i = 0;i < cardDeck->numCards;i++) {
reglong temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
regchar majorType,
minorType;
regint num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = TRUE;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = TRUE;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & CC_D) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = TRUE;
break;
}
isSpecialCard = FALSE;
}
void printCardMessage(void) {
regchar c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| #if !defined(lint)
static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
#endif
#include "monop.ext"
#include "pathnames.h"
#define GOJF 'F' /* char for get-out-of-jail-free cards */
#if !defined(DEV)
static char * cardFile = CARD_FILE;
#else
static char * cardFile = "cards.pck";
#endif
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == NULL) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & CC_D);
shuffleDeck( & CH_D);
}
void shuffleDeck(DECK * cardDeck) {
regint r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = FALSE;
for (i = 0;i < cardDeck->numCards;i++) {
reglong temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
regchar majorType,
minorType;
regint num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = TRUE;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = TRUE;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & CC_D) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = TRUE;
break;
}
isSpecialCard = FALSE;
}
void printCardMessage(void) {
regchar c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == NULL) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & CC_D);
shuffleDeck( & CH_D);
}
void shuffleDeck(DECK * cardDeck) {
regint r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = FALSE;
for (i = 0;i < cardDeck->numCards;i++) {
reglong temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
regchar majorType,
minorType;
regint num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = TRUE;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = TRUE;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & CC_D) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = TRUE;
break;
}
isSpecialCard = FALSE;
}
void printCardMessage(void) {
regchar c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == NULL) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(DECK * cardDeck) {
register int r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
register long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
register char majorType,
minorType;
register int num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
register char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(DECK * cardDeck) {
register int r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
register long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
register char majorType,
minorType;
register int num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
register char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (DECK) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(DECK * cardDeck) {
int r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(DECK * cardDeck) {
char majorType,
minorType;
int num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OWN * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (CardDeck) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1,
r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType,
minorType;
int num;
int i,
perHouse,
perHotel,
num_h,
num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (CardDeck) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof (cardDeck) , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof (long) , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof (long) , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char sccsid[] = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money -= num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) if (i != currentPlayerNumber) players[i].money += num;
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) num += 40;
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) num = 28 - currentPlayer->location;
else {
num = 12 - currentPlayer->location;
if (num < 0) num += 40;
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) if (propertyList->square1->type == TYPE_PROPERTY) if (propertyList->square1->description->houseCount == 5)++num_H;
else num_h += propertyList->square1->description->houseCount;
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) printLuckyMessage("");
else currentPlayer->money -= num;
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') putchar(c);
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
file_err:perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money -= num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money += num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) {
num = 28 - currentPlayer->location;
}
else {
num = 12 - currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY) {
if (propertyList->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks(void) {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money -= num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money += num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) {
num = 28 - currentPlayer->location;
}
else {
num = 12 - currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY) {
if (propertyList->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage(void) {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money -= num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money += num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) {
num = 28 - currentPlayer->location;
}
else {
num = 12 - currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList = currentPlayer->ownedPropertyList;propertyList;propertyList = propertyList->next) {
if (propertyList->square1->type == TYPE_PROPERTY) {
if (propertyList->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage() {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & deck[0]);
shuffleDeck( & deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money -= num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < numberOfPlayers;i++) {
if (i != currentPlayerNumber) {
players[i].money += num;
}
}
num = num * (numberOfPlayers - 1);
}
currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
gotoJail();
return;
case 'R':
isSpecialCard = true;
num = (int) ((currentPlayer->location + 5) / 10) * 10 + 5 - currentPlayer->location;
break;
case 'U':
isSpecialCard = true;
if (currentPlayer->location >= 12 && currentPlayer->location < 28) {
num = 28 - currentPlayer->location;
}
else {
num = 12 - currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
isSpecialCard = false;
}
void printCardMessage() {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = roll(1, cardDeck->numCards) - 1;
r2 = roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long * ) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
char c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
fseek(deckFile, cardDeck->offsets[cardDeck->lastCard], 0);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
int c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
deckFile.rewind();
deckFile.skip(cardDeck->offsets[cardDeck->lastCard]);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num = num * (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
int c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
if ((deckFile = fopen(cardFile, "r")) == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
deckFile.rewind();
deckFile.skip(cardDeck->offsets[cardDeck->lastCard]);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
int c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
deckFile = fopen(cardFile, "r");
if (deckFile == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
deckFile.rewind();
deckFile.skip(cardDeck->offsets[cardDeck->lastCard]);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_h = num_H = 0;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
int c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
deckFile = fopen(cardFile, "r");
if (deckFile == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDeck->offsets[r1];
cardDeck->offsets[r1] = temp;
}
}
static void getCard(CardDeck * cardDeck) {
char majorType;
char minorType;
int num;
int i;
int perHouse;
int perHotel;
int num_h;
int num_H;
OwnedPropertyList * propertyList1;
do {
deckFile.rewind();
deckFile.skip(cardDeck->offsets[cardDeck->lastCard]);
cardDeck->lastCard =++(cardDeck->lastCard) % cardDeck->numCards;
majorType = getc(deckFile);
}
while (cardDeck->getOutOfJailFreeUsed && majorType == GET_OUT_OF_JAIL_FREE);
minorType = getc(deckFile);
num = getw(deckFile);
printCardMessage();
switch (majorType) {
case '+':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money -= num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money += num;
break;
case '-':
if (minorType == 'A') {
for (i = 0;i < Monop.numberOfPlayers;i++) {
if (i != Monop.currentPlayerNumber) {
Monop.players[i].money += num;
}
}
num *= (Monop.numberOfPlayers - 1);
}
Monop.currentPlayer->money -= num;
break;
case 'M':
switch (minorType) {
case 'F':
num -= Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
break;
case 'J':
SpecialMoves.gotoJail();
return;
case 'R':
Monop.isSpecialCard = true;
num = (int) ((Monop.currentPlayer->location + 5) / 10) * 10 + 5 - Monop.currentPlayer->location;
break;
case 'U':
Monop.isSpecialCard = true;
if (Monop.currentPlayer->location >= 12 && Monop.currentPlayer->location < 28) {
num = 28 - Monop.currentPlayer->location;
}
else {
num = 12 - Monop.currentPlayer->location;
if (num < 0) {
num += 40;
}
}
break;
case 'B':
num = - num;
break;
}
Execute.move(num);
break;
case 'T':
if (cardDeck == & Monop.deck[0]) {
perHouse = 40;
perHotel = 115;
}
else {
perHouse = 25;
perHotel = 100;
}
num_H = 0;
num_h = num_H;
for (propertyList1 = Monop.currentPlayer->ownedPropertyList;propertyList1;propertyList1 = propertyList1->next) {
if (propertyList1->square1->type == TYPE_PROPERTY) {
if (propertyList1->square1->description->houseCount == 5) {
++num_H;
}
else {
num_h += propertyList1->square1->description->houseCount;
}
}
}
num = perHouse * num_h + perHotel * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
if (num == 0) {
printLuckyMessage("");
}
else {
Monop.currentPlayer->money -= num;
}
break;
case GET_OUT_OF_JAIL_FREE:
Monop.currentPlayer->getOutOfJailFreeCardCount++;
cardDeck->getOutOfJailFreeUsed = true;
break;
}
Monop.isSpecialCard = false;
}
void printCardMessage() {
int c;
printLine();
fflush(stdout);
while ((c = getc(deckFile)) != '\0') {
putchar(c);
}
printLine();
fflush(stdout);
}
| static char[] sccsid = "@(#)cards.c 5.4 (Berkeley) 6/1/90";
public final static char GOJF = 'F';
static char * cardFile = CARD_FILE;
static FILE * deckFile;
static void initializeDecks() {
deckFile = fopen(cardFile, "r");
if (deckFile == 0) {
perror(cardFile);
exit(1);
}
if (fread(Monop.deck, sizeof () , 2, deckFile) != 2) {
perror(cardFile);
exit(1);
}
shuffleDeck( & Monop.deck[0]);
shuffleDeck( & Monop.deck[1]);
}
void shuffleDeck(CardDeck * cardDeck) {
int r1;
int r2;
int i;
cardDeck->offsets = (long) calloc(sizeof () , cardDeck->numCards);
if (fread(cardDeck->offsets, sizeof () , cardDeck->numCards, deckFile) != cardDeck->numCards) {
perror(cardFile);
exit(1);
}
cardDeck->lastCard = 0;
cardDeck->getOutOfJailFreeUsed = false;
for (i = 0;i < cardDeck->numCards;i++) {
long temp;
r1 = Roll.roll(1, cardDeck->numCards) - 1;
r2 = Roll.roll(1, cardDeck->numCards) - 1;
temp = cardDeck->offsets[r2];
cardDeck->offsets[r2] = cardDec |