Monop game done.
This commit is contained in:
2
cross.mk
2
cross.mk
@@ -1,7 +1,7 @@
|
|||||||
DESTDIR = /usr/local/retrobsd
|
DESTDIR = /usr/local/retrobsd
|
||||||
MACHINE = mips
|
MACHINE = mips
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc -m32
|
||||||
|
|
||||||
AS = $(CC) -x assembler-with-cpp
|
AS = $(CC) -x assembler-with-cpp
|
||||||
LD = ld
|
LD = ld
|
||||||
|
|||||||
@@ -420,6 +420,7 @@ file /games/fish
|
|||||||
file /games/fortune
|
file /games/fortune
|
||||||
file /games/hangman
|
file /games/hangman
|
||||||
file /games/mille
|
file /games/mille
|
||||||
|
file /games/monop
|
||||||
file /games/morse
|
file /games/morse
|
||||||
file /games/number
|
file /games/number
|
||||||
file /games/ppt
|
file /games/ppt
|
||||||
@@ -445,6 +446,8 @@ file /games/lib/cfscores
|
|||||||
mode 0666
|
mode 0666
|
||||||
file /games/lib/fortunes.dat
|
file /games/lib/fortunes.dat
|
||||||
mode 0444
|
mode 0444
|
||||||
|
file /games/lib/cards.pck
|
||||||
|
mode 0444
|
||||||
|
|
||||||
#
|
#
|
||||||
# Files: /include
|
# Files: /include
|
||||||
@@ -733,6 +736,7 @@ file /share/man/cat6/fish.0
|
|||||||
file /share/man/cat6/fortune.0
|
file /share/man/cat6/fortune.0
|
||||||
file /share/man/cat6/hangman.0
|
file /share/man/cat6/hangman.0
|
||||||
file /share/man/cat6/mille.0
|
file /share/man/cat6/mille.0
|
||||||
|
file /share/man/cat6/monop.0
|
||||||
file /share/man/cat6/number.0
|
file /share/man/cat6/number.0
|
||||||
file /share/man/cat6/rain.0
|
file /share/man/cat6/rain.0
|
||||||
file /share/man/cat6/rogue.0
|
file /share/man/cat6/rogue.0
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ CFLAGS += -Werror -Wall -Os
|
|||||||
# Programs that live in subdirectories, and have makefiles of their own.
|
# Programs that live in subdirectories, and have makefiles of their own.
|
||||||
#
|
#
|
||||||
SUBDIR = adventure atc backgammon battlestar boggle btlgammon \
|
SUBDIR = adventure atc backgammon battlestar boggle btlgammon \
|
||||||
cribbage fortune hangman mille rogue sail trek
|
cribbage fortune hangman mille monop rogue sail trek
|
||||||
# TODO: monop quiz robots snake
|
# TODO: quiz robots snake
|
||||||
|
|
||||||
# C programs that live in the current directory and do not need
|
# C programs that live in the current directory and do not need
|
||||||
# explicit make lines.
|
# explicit make lines.
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
# Makefile: K.S.
|
# Makefile: K.S.
|
||||||
#
|
#
|
||||||
TOPSRC = $(shell cd ../../..; pwd)
|
TOPSRC = $(shell cd ../../..; pwd)
|
||||||
#include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
include $(TOPSRC)/cross.mk
|
#include $(TOPSRC)/cross.mk
|
||||||
CFLAGS = -DCROSS
|
#CFLAGS = -DCROSS -O
|
||||||
|
|
||||||
CFLAGS += -O -Werror -Wall
|
CFLAGS += -Werror -Wall
|
||||||
LIBS = -lc
|
LIBS = -lc
|
||||||
|
|
||||||
OBJS = monop.o cards.o execute.o getinp.o houses.o jail.o misc.o \
|
OBJS = monop.o cards.o execute.o getinp.o houses.o jail.o misc.o \
|
||||||
@@ -27,14 +27,14 @@ monop: $(OBJS)
|
|||||||
initdeck: initdeck.c deck.h
|
initdeck: initdeck.c deck.h
|
||||||
$(CC) -o initdeck $(LDFLAGS) $(CFLAGS) initdeck.c
|
$(CC) -o initdeck $(LDFLAGS) $(CFLAGS) initdeck.c
|
||||||
|
|
||||||
cards.pck: initdeck cards.inp
|
cards.pck: #initdeck cards.inp
|
||||||
./initdeck
|
./initdeck
|
||||||
|
|
||||||
$(MAN): $(MANSRC)
|
$(MAN): $(MANSRC)
|
||||||
$(MANROFF) $< > $@
|
$(MANROFF) $< > $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.0 *.elf $(MAN) monop initdeck cards.pck *.elf *.dis tags *~
|
rm -f *.o *.0 *.elf $(MAN) monop initdeck *.elf *.dis tags *~
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install monop $(DESTDIR)/games/
|
install monop $(DESTDIR)/games/
|
||||||
|
|||||||
BIN
src/games/monop/cards.pck
Normal file
BIN
src/games/monop/cards.pck
Normal file
Binary file not shown.
@@ -11,3 +11,5 @@ struct dk_st { /* deck description structure */
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct dk_st DECK;
|
typedef struct dk_st DECK;
|
||||||
|
|
||||||
|
void get_card(DECK *dp);
|
||||||
|
|||||||
@@ -28,42 +28,7 @@ DECK deck[2];
|
|||||||
|
|
||||||
FILE *inf, *outf;
|
FILE *inf, *outf;
|
||||||
|
|
||||||
main(ac, av)
|
void
|
||||||
int ac;
|
|
||||||
char *av[]; {
|
|
||||||
|
|
||||||
getargs(ac, av);
|
|
||||||
if ((inf = fopen(infile, "r")) == NULL) {
|
|
||||||
perror(infile);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
count();
|
|
||||||
/*
|
|
||||||
* allocate space for pointers.
|
|
||||||
*/
|
|
||||||
CC_D.offsets = calloc(CC_D.num_cards + 1, sizeof (long));
|
|
||||||
CH_D.offsets = calloc(CH_D.num_cards + 1, sizeof (long));
|
|
||||||
fseek(inf, 0L, 0);
|
|
||||||
if ((outf = fopen(outfile, "w")) == NULL) {
|
|
||||||
perror(outfile);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite(deck, sizeof (DECK), 2, outf);
|
|
||||||
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
|
|
||||||
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
|
|
||||||
putem();
|
|
||||||
|
|
||||||
fclose(inf);
|
|
||||||
fseek(outf, 0, 0L);
|
|
||||||
fwrite(deck, sizeof (DECK), 2, outf);
|
|
||||||
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
|
|
||||||
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
|
|
||||||
fclose(outf);
|
|
||||||
printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
getargs(ac, av)
|
getargs(ac, av)
|
||||||
int ac;
|
int ac;
|
||||||
char *av[]; {
|
char *av[]; {
|
||||||
@@ -74,9 +39,11 @@ char *av[]; {
|
|||||||
outfile = av[3];
|
outfile = av[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* count the cards
|
* count the cards
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
count() {
|
count() {
|
||||||
|
|
||||||
reg bool newline;
|
reg bool newline;
|
||||||
@@ -96,9 +63,11 @@ count() {
|
|||||||
newline = (c == '\n');
|
newline = (c == '\n');
|
||||||
in_deck->num_cards++;
|
in_deck->num_cards++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* put strings in the file
|
* put strings in the file
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
putem() {
|
putem() {
|
||||||
|
|
||||||
reg bool newline;
|
reg bool newline;
|
||||||
@@ -139,3 +108,40 @@ putem() {
|
|||||||
}
|
}
|
||||||
putc('\0', outf);
|
putc('\0', outf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(ac, av)
|
||||||
|
int ac;
|
||||||
|
char *av[]; {
|
||||||
|
|
||||||
|
getargs(ac, av);
|
||||||
|
if ((inf = fopen(infile, "r")) == NULL) {
|
||||||
|
perror(infile);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
count();
|
||||||
|
/*
|
||||||
|
* allocate space for pointers.
|
||||||
|
*/
|
||||||
|
CC_D.offsets = calloc(CC_D.num_cards + 1, sizeof (long));
|
||||||
|
CH_D.offsets = calloc(CH_D.num_cards + 1, sizeof (long));
|
||||||
|
fseek(inf, 0L, 0);
|
||||||
|
if ((outf = fopen(outfile, "w")) == NULL) {
|
||||||
|
perror(outfile);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite(deck, sizeof (DECK), 2, outf);
|
||||||
|
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
|
||||||
|
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
|
||||||
|
putem();
|
||||||
|
|
||||||
|
fclose(inf);
|
||||||
|
fseek(outf, 0, 0L);
|
||||||
|
fwrite(deck, sizeof (DECK), 2, outf);
|
||||||
|
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
|
||||||
|
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
|
||||||
|
fclose(outf);
|
||||||
|
printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#define execsh(sh) execl(sh, shell_name[roll(1, num_names)-1], NULL)
|
#define execsh(sh) execl(sh, shell_name[roll(1, num_names)-1], (char*)0)
|
||||||
|
|
||||||
static char *shell_def = "/bin/csh",
|
static char *shell_def = "/bin/csh",
|
||||||
*shell_name[] = {
|
*shell_name[] = {
|
||||||
@@ -274,18 +274,6 @@ quitgame()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine copies one structure to another
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
cpy_st(s1, s2, size)
|
|
||||||
reg int *s1, *s2, size; {
|
|
||||||
|
|
||||||
size /= 2;
|
|
||||||
while (size--)
|
|
||||||
*s1++ = *s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine looks up the users login shell
|
* This routine looks up the users login shell
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
@@ -46,8 +47,8 @@ over:
|
|||||||
else
|
else
|
||||||
printf("\"done\" is a reserved word. Please try again\n");
|
printf("\"done\" is a reserved word. Please try again\n");
|
||||||
for (i = 0; i < num_play; i++)
|
for (i = 0; i < num_play; i++)
|
||||||
cfree(play[i].name);
|
free(play[i].name);
|
||||||
cfree(play);
|
free(play);
|
||||||
goto blew_it;
|
goto blew_it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ int roll(int ndie, int nsides);
|
|||||||
int getinp(char *prompt, char *list[]);
|
int getinp(char *prompt, char *list[]);
|
||||||
int move_jail(int r1, int r2);
|
int move_jail(int r1, int r2);
|
||||||
int getyn(char *prompt);
|
int getyn(char *prompt);
|
||||||
|
int prop_worth(PLAY *plp);
|
||||||
|
|
||||||
void goto_jail(void);
|
void goto_jail(void);
|
||||||
void inc_tax(void);
|
void inc_tax(void);
|
||||||
@@ -121,3 +122,7 @@ void rent(SQUARE *sqp);
|
|||||||
void ret_card(PLAY *plr);
|
void ret_card(PLAY *plr);
|
||||||
void printhold(int pl);
|
void printhold(int pl);
|
||||||
void isnot_monop(MON *mp);
|
void isnot_monop(MON *mp);
|
||||||
|
void printsq(int sqn, bool eoln);
|
||||||
|
void add_list(int plr, OWN **head, int op_sqr);
|
||||||
|
void del_list(int plr, OWN **head, shrt op_sqr);
|
||||||
|
void set_ownlist(int pl);
|
||||||
|
|||||||
@@ -29,6 +29,44 @@ static shrt square[MAX_PRP+2];
|
|||||||
|
|
||||||
static int num_good,got_houses;
|
static int num_good,got_houses;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine sets up the list of mortgageable property
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
set_mlist() {
|
||||||
|
|
||||||
|
reg OWN *op;
|
||||||
|
|
||||||
|
num_good = 0;
|
||||||
|
for (op = cur_p->own_list; op; op = op->next)
|
||||||
|
if (! ((PROP*)op->sqr->desc)->morg) {
|
||||||
|
if (op->sqr->type == PRPTY && ((PROP*)op->sqr->desc)->houses)
|
||||||
|
got_houses++;
|
||||||
|
else {
|
||||||
|
names[num_good] = op->sqr->name;
|
||||||
|
square[num_good++] = sqnum(op->sqr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names[num_good++] = "done";
|
||||||
|
names[num_good--] = 0;
|
||||||
|
return num_good;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine actually mortgages the property.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
m(prop)
|
||||||
|
reg int prop; {
|
||||||
|
|
||||||
|
reg int price;
|
||||||
|
|
||||||
|
price = board[prop].cost/2;
|
||||||
|
((PROP*)board[prop].desc)->morg = TRUE;
|
||||||
|
printf("That got you $%d\n",price);
|
||||||
|
cur_p->money += price;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine is the command level response the mortgage command.
|
* This routine is the command level response the mortgage command.
|
||||||
* it gets the list of mortgageable property and asks which are to
|
* it gets the list of mortgageable property and asks which are to
|
||||||
@@ -57,45 +95,44 @@ mortgage() {
|
|||||||
if (prop == num_good)
|
if (prop == num_good)
|
||||||
return;
|
return;
|
||||||
m(square[prop]);
|
m(square[prop]);
|
||||||
notify(cur_p);
|
notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine sets up the list of mortgageable property
|
* This routine sets up the list of mortgaged property
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
set_mlist() {
|
set_umlist() {
|
||||||
|
|
||||||
reg OWN *op;
|
reg OWN *op;
|
||||||
|
|
||||||
num_good = 0;
|
num_good = 0;
|
||||||
for (op = cur_p->own_list; op; op = op->next)
|
for (op = cur_p->own_list; op; op = op->next)
|
||||||
if (! ((PROP*)op->sqr->desc)->morg)
|
if (((PROP*)op->sqr->desc)->morg) {
|
||||||
if (op->sqr->type == PRPTY && ((PROP*)op->sqr->desc)->houses)
|
names[num_good] = op->sqr->name;
|
||||||
got_houses++;
|
square[num_good++] = sqnum(op->sqr);
|
||||||
else {
|
}
|
||||||
names[num_good] = op->sqr->name;
|
|
||||||
square[num_good++] = sqnum(op->sqr);
|
|
||||||
}
|
|
||||||
names[num_good++] = "done";
|
names[num_good++] = "done";
|
||||||
names[num_good--] = 0;
|
names[num_good--] = 0;
|
||||||
return num_good;
|
return num_good;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine actually mortgages the property.
|
* This routine actually unmortgages the property
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
m(prop)
|
unm(prop)
|
||||||
reg int prop; {
|
reg int prop; {
|
||||||
|
|
||||||
reg int price;
|
reg int price;
|
||||||
|
|
||||||
price = board[prop].cost/2;
|
price = board[prop].cost/2;
|
||||||
((PROP*)board[prop].desc)->morg = TRUE;
|
((PROP*)board[prop].desc)->morg = FALSE;
|
||||||
printf("That got you $%d\n",price);
|
price += price/10;
|
||||||
cur_p->money += price;
|
printf("That cost you $%d\n",price);
|
||||||
|
cur_p->money -= price;
|
||||||
|
set_umlist();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -127,39 +164,15 @@ unmortgage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine sets up the list of mortgaged property
|
* This routine is a special execute for the force_morg routine
|
||||||
*/
|
*/
|
||||||
int
|
static void
|
||||||
set_umlist() {
|
fix_ex(com_num)
|
||||||
|
reg int com_num; {
|
||||||
|
|
||||||
reg OWN *op;
|
told_em = FALSE;
|
||||||
|
(*func[com_num])();
|
||||||
num_good = 0;
|
notify();
|
||||||
for (op = cur_p->own_list; op; op = op->next)
|
|
||||||
if (((PROP*)op->sqr->desc)->morg) {
|
|
||||||
names[num_good] = op->sqr->name;
|
|
||||||
square[num_good++] = sqnum(op->sqr);
|
|
||||||
}
|
|
||||||
names[num_good++] = "done";
|
|
||||||
names[num_good--] = 0;
|
|
||||||
return num_good;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine actually unmortgages the property
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
unm(prop)
|
|
||||||
reg int prop; {
|
|
||||||
|
|
||||||
reg int price;
|
|
||||||
|
|
||||||
price = board[prop].cost/2;
|
|
||||||
((PROP*)board[prop].desc)->morg = FALSE;
|
|
||||||
price += price/10;
|
|
||||||
printf("That cost you $%d\n",price);
|
|
||||||
cur_p->money -= price;
|
|
||||||
set_umlist();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -174,15 +187,3 @@ force_morg() {
|
|||||||
fix_ex(getinp("How are you going to fix it up? ",morg_coms));
|
fix_ex(getinp("How are you going to fix it up? ",morg_coms));
|
||||||
fixing = FALSE;
|
fixing = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine is a special execute for the force_morg routine
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
fix_ex(com_num)
|
|
||||||
reg int com_num; {
|
|
||||||
|
|
||||||
told_em = FALSE;
|
|
||||||
(*func[com_num])();
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
static char buf[80], /* output buffer */
|
static char *header = "Name Own Price Mg # Rent";
|
||||||
*header = "Name Own Price Mg # Rent";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine prints out the current board
|
* This routine prints out the current board
|
||||||
@@ -26,7 +25,6 @@ void
|
|||||||
where() {
|
where() {
|
||||||
|
|
||||||
reg int i;
|
reg int i;
|
||||||
char *bsp;
|
|
||||||
|
|
||||||
printf("%s Player\n", header);
|
printf("%s Player\n", header);
|
||||||
for (i = 0; i < num_play; i++) {
|
for (i = 0; i < num_play; i++) {
|
||||||
@@ -38,6 +36,19 @@ where() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine prints out the mortgage flag.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
printmorg(sqp)
|
||||||
|
reg SQUARE *sqp; {
|
||||||
|
|
||||||
|
if (((PROP*)sqp->desc)->morg)
|
||||||
|
printf(" * ");
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine prints out an individual square
|
* This routine prints out an individual square
|
||||||
*/
|
*/
|
||||||
@@ -49,7 +60,6 @@ reg bool eoln; {
|
|||||||
reg int rnt;
|
reg int rnt;
|
||||||
reg PROP *pp;
|
reg PROP *pp;
|
||||||
reg SQUARE *sqp;
|
reg SQUARE *sqp;
|
||||||
int i;
|
|
||||||
|
|
||||||
sqp = &board[sqn];
|
sqp = &board[sqn];
|
||||||
printf("%-10.10s", sqp->name);
|
printf("%-10.10s", sqp->name);
|
||||||
@@ -79,7 +89,7 @@ spec:
|
|||||||
if (pp->houses < 5)
|
if (pp->houses < 5)
|
||||||
if (pp->houses > 0)
|
if (pp->houses > 0)
|
||||||
printf("%d %4d", pp->houses,
|
printf("%d %4d", pp->houses,
|
||||||
pp->rent[pp->houses]);
|
pp->rent[(int)pp->houses]);
|
||||||
else
|
else
|
||||||
printf("0 %4d", pp->rent[0] * 2);
|
printf("0 %4d", pp->rent[0] * 2);
|
||||||
else
|
else
|
||||||
@@ -97,7 +107,7 @@ spec:
|
|||||||
}
|
}
|
||||||
printf(" %d 150", sqp->owner+1);
|
printf(" %d 150", sqp->owner+1);
|
||||||
printmorg(sqp);
|
printmorg(sqp);
|
||||||
printf("%d", play[sqp->owner].num_util);
|
printf("%d", play[(int)sqp->owner].num_util);
|
||||||
if (!eoln)
|
if (!eoln)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
break;
|
break;
|
||||||
@@ -111,27 +121,14 @@ spec:
|
|||||||
printf(" %d Railroad 200", sqp->owner+1);
|
printf(" %d Railroad 200", sqp->owner+1);
|
||||||
printmorg(sqp);
|
printmorg(sqp);
|
||||||
rnt = 25;
|
rnt = 25;
|
||||||
rnt <<= play[sqp->owner].num_rr - 1;
|
rnt <<= play[(int)sqp->owner].num_rr - 1;
|
||||||
printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
|
printf("%d %4d", play[(int)sqp->owner].num_rr, 25 << (play[(int)sqp->owner].num_rr - 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (eoln)
|
if (eoln)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine prints out the mortgage flag.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
printmorg(sqp)
|
|
||||||
reg SQUARE *sqp; {
|
|
||||||
|
|
||||||
if (((PROP*)sqp->desc)->morg)
|
|
||||||
printf(" * ");
|
|
||||||
else
|
|
||||||
printf(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine lists the holdings of the player given
|
* This routine lists the holdings of the player given
|
||||||
*/
|
*/
|
||||||
@@ -141,7 +138,6 @@ reg int pl; {
|
|||||||
|
|
||||||
reg OWN *op;
|
reg OWN *op;
|
||||||
reg PLAY *pp;
|
reg PLAY *pp;
|
||||||
char *bsp;
|
|
||||||
|
|
||||||
pp = &play[pl];
|
pp = &play[pl];
|
||||||
printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
|
printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
|
||||||
|
|||||||
@@ -15,6 +15,35 @@ reg SQUARE *sqrp; {
|
|||||||
add_list(player, &(play[player].own_list), cur_p->loc);
|
add_list(player, &(play[player].own_list), cur_p->loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine calculates the value for sorting of the
|
||||||
|
* given square.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
value(sqp)
|
||||||
|
reg SQUARE *sqp; {
|
||||||
|
|
||||||
|
reg int sqr;
|
||||||
|
|
||||||
|
sqr = sqnum(sqp);
|
||||||
|
switch (sqp->type) {
|
||||||
|
case SAFE:
|
||||||
|
return 0;
|
||||||
|
case SPEC:
|
||||||
|
return 1;
|
||||||
|
case UTIL:
|
||||||
|
if (sqr == 12)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 3;
|
||||||
|
case RR:
|
||||||
|
return 4 + sqr/10;
|
||||||
|
case PRPTY:
|
||||||
|
return 8 + (PROP *)(sqp->desc) - prop;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine adds an item to the list.
|
* This routine adds an item to the list.
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +55,6 @@ int op_sqr; {
|
|||||||
|
|
||||||
reg int val;
|
reg int val;
|
||||||
reg OWN *tp, *last_tp;
|
reg OWN *tp, *last_tp;
|
||||||
MON *mp;
|
|
||||||
OWN *op;
|
OWN *op;
|
||||||
|
|
||||||
op = calloc(1, sizeof (OWN));
|
op = calloc(1, sizeof (OWN));
|
||||||
@@ -35,7 +63,7 @@ int op_sqr; {
|
|||||||
last_tp = NULL;
|
last_tp = NULL;
|
||||||
for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next)
|
for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next)
|
||||||
if (val == value(tp->sqr)) {
|
if (val == value(tp->sqr)) {
|
||||||
cfree(op);
|
free(op);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -58,12 +86,11 @@ int plr;
|
|||||||
OWN **head;
|
OWN **head;
|
||||||
shrt op_sqr; {
|
shrt op_sqr; {
|
||||||
|
|
||||||
reg int i;
|
|
||||||
reg OWN *op, *last_op;
|
reg OWN *op, *last_op;
|
||||||
|
|
||||||
switch (board[op_sqr].type) {
|
switch (board[(int)op_sqr].type) {
|
||||||
case PRPTY:
|
case PRPTY:
|
||||||
((PROP*)board[op_sqr].desc)->mon_desc->num_own--;
|
((PROP*)board[(int)op_sqr].desc)->mon_desc->num_own--;
|
||||||
break;
|
break;
|
||||||
case RR:
|
case RR:
|
||||||
play[plr].num_rr--;
|
play[plr].num_rr--;
|
||||||
@@ -74,7 +101,7 @@ shrt op_sqr; {
|
|||||||
}
|
}
|
||||||
last_op = NULL;
|
last_op = NULL;
|
||||||
for (op = *head; op; op = op->next)
|
for (op = *head; op; op = op->next)
|
||||||
if (op->sqr == &board[op_sqr])
|
if (op->sqr == &board[(int)op_sqr])
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
last_op = op;
|
last_op = op;
|
||||||
@@ -82,34 +109,7 @@ shrt op_sqr; {
|
|||||||
*head = op->next;
|
*head = op->next;
|
||||||
else {
|
else {
|
||||||
last_op->next = op->next;
|
last_op->next = op->next;
|
||||||
cfree(op);
|
free(op);
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* This routine calculates the value for sorting of the
|
|
||||||
* given square.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
value(sqp)
|
|
||||||
reg SQUARE *sqp; {
|
|
||||||
|
|
||||||
reg int sqr;
|
|
||||||
|
|
||||||
sqr = sqnum(sqp);
|
|
||||||
switch (sqp->type) {
|
|
||||||
case SAFE:
|
|
||||||
return 0;
|
|
||||||
case SPEC:
|
|
||||||
return 1;
|
|
||||||
case UTIL:
|
|
||||||
if (sqr == 12)
|
|
||||||
return 2;
|
|
||||||
else
|
|
||||||
return 3;
|
|
||||||
case RR:
|
|
||||||
return 4 + sqr/10;
|
|
||||||
case PRPTY:
|
|
||||||
return 8 + (PROP *)(sqp->desc) - prop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,8 @@ bid() {
|
|||||||
cur_max = 0;
|
cur_max = 0;
|
||||||
num_in = num_play;
|
num_in = num_play;
|
||||||
while (num_in > 1 || (cur_max == 0 && num_in > 0)) {
|
while (num_in > 1 || (cur_max == 0 && num_in > 0)) {
|
||||||
i = ++i % num_play;
|
i++;
|
||||||
|
i %= num_play;
|
||||||
if (in[i]) {
|
if (in[i]) {
|
||||||
do {
|
do {
|
||||||
sprintf(buf, "%s: ", name_list[i]);
|
sprintf(buf, "%s: ", name_list[i]);
|
||||||
@@ -150,10 +151,12 @@ bid() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cur_max != 0) {
|
if (cur_max != 0) {
|
||||||
while (!in[i])
|
while (!in[i]) {
|
||||||
i = ++i % num_play;
|
i++;
|
||||||
|
i %= num_play;
|
||||||
|
}
|
||||||
printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max);
|
printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max);
|
||||||
buy(i, &board[cur_p->loc]);
|
buy(i, &board[(int)cur_p->loc]);
|
||||||
play[i].money -= cur_max;
|
play[i].money -= cur_max;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ void
|
|||||||
rent(sqp)
|
rent(sqp)
|
||||||
reg SQUARE *sqp; {
|
reg SQUARE *sqp; {
|
||||||
|
|
||||||
reg int rnt;
|
reg int rnt = 0;
|
||||||
reg PROP *pp;
|
reg PROP *pp;
|
||||||
PLAY *plp;
|
PLAY *plp;
|
||||||
|
|
||||||
plp = &play[sqp->owner];
|
plp = &play[(int)sqp->owner];
|
||||||
printf("Owned by %s\n", plp->name);
|
printf("Owned by %s\n", plp->name);
|
||||||
if (((PROP*)sqp->desc)->morg) {
|
if (((PROP*)sqp->desc)->morg) {
|
||||||
lucky("The thing is mortgaged. ");
|
lucky("The thing is mortgaged. ");
|
||||||
@@ -25,10 +25,10 @@ reg SQUARE *sqp; {
|
|||||||
printf("rent is %d\n", rnt=pp->rent[0] * 2);
|
printf("rent is %d\n", rnt=pp->rent[0] * 2);
|
||||||
else if (pp->houses < 5)
|
else if (pp->houses < 5)
|
||||||
printf("with %d houses, rent is %d\n",
|
printf("with %d houses, rent is %d\n",
|
||||||
pp->houses, rnt=pp->rent[pp->houses]);
|
pp->houses, rnt=pp->rent[(int)pp->houses]);
|
||||||
else
|
else
|
||||||
printf("with a hotel, rent is %d\n",
|
printf("with a hotel, rent is %d\n",
|
||||||
rnt=pp->rent[pp->houses]);
|
rnt=pp->rent[(int)pp->houses]);
|
||||||
else
|
else
|
||||||
printf("rent is %d\n", rnt = pp->rent[0]);
|
printf("rent is %d\n", rnt = pp->rent[0]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This routine rolls ndie nside-sided dice.
|
* This routine rolls ndie nside-sided dice.
|
||||||
*/
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
roll(ndie, nsides)
|
roll(ndie, nsides)
|
||||||
@@ -10,6 +11,6 @@ int ndie, nsides; {
|
|||||||
|
|
||||||
tot = 0;
|
tot = 0;
|
||||||
while (ndie--)
|
while (ndie--)
|
||||||
tot += rand() % nsides + 1;
|
tot += random() % nsides + 1;
|
||||||
return tot;
|
return tot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,44 +16,30 @@ static int used[MAX_PRP];
|
|||||||
|
|
||||||
static TRADE trades[2];
|
static TRADE trades[2];
|
||||||
|
|
||||||
trade() {
|
/*
|
||||||
|
* This routine sets up the list of tradable property.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
set_list(the_list)
|
||||||
|
reg OWN *the_list; {
|
||||||
|
|
||||||
reg int tradee, i;
|
reg int i;
|
||||||
|
reg OWN *op;
|
||||||
|
|
||||||
trading = TRUE;
|
i = 0;
|
||||||
for (i = 0; i < 2; i++) {
|
for (op = the_list; op; op = op->next)
|
||||||
trades[i].cash = 0;
|
if (!used[i])
|
||||||
trades[i].gojf = FALSE;
|
list[i++] = op->sqr->name;
|
||||||
trades[i].prop_list = NULL;
|
list[i++] = "done";
|
||||||
}
|
list[i--] = 0;
|
||||||
over:
|
return i;
|
||||||
if (num_play == 1) {
|
|
||||||
printf("There ain't no-one around to trade WITH!!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (num_play > 2) {
|
|
||||||
tradee = getinp("Which player do you wish to trade with? ",
|
|
||||||
name_list);
|
|
||||||
if (tradee == num_play)
|
|
||||||
return;
|
|
||||||
if (tradee == player) {
|
|
||||||
printf("You can't trade with yourself!\n");
|
|
||||||
goto over;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tradee = 1 - player;
|
|
||||||
get_list(0, player);
|
|
||||||
get_list(1, tradee);
|
|
||||||
if (getyn("Do you wish a summary? ") == 0)
|
|
||||||
summate();
|
|
||||||
if (getyn("Is the trade ok? ") == 0)
|
|
||||||
do_trade();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine gets the list of things to be trader for the
|
* This routine gets the list of things to be trader for the
|
||||||
* player, and puts in the structure given.
|
* player, and puts in the structure given.
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
get_list(struct_no, play_no)
|
get_list(struct_no, play_no)
|
||||||
int struct_no, play_no; {
|
int struct_no, play_no; {
|
||||||
|
|
||||||
@@ -102,26 +88,11 @@ once_more:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* This routine sets up the list of tradable property.
|
|
||||||
*/
|
|
||||||
set_list(the_list)
|
|
||||||
reg OWN *the_list; {
|
|
||||||
|
|
||||||
reg int i;
|
|
||||||
reg OWN *op;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for (op = the_list; op; op = op->next)
|
|
||||||
if (!used[i])
|
|
||||||
list[i++] = op->sqr->name;
|
|
||||||
list[i++] = "done";
|
|
||||||
list[i--] = 0;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* This routine summates the trade.
|
* This routine summates the trade.
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
summate() {
|
summate() {
|
||||||
|
|
||||||
reg bool some;
|
reg bool some;
|
||||||
@@ -148,17 +119,11 @@ summate() {
|
|||||||
printf("\t-- Nothing --\n");
|
printf("\t-- Nothing --\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* This routine actually executes the trade.
|
|
||||||
*/
|
|
||||||
do_trade() {
|
|
||||||
|
|
||||||
move_em(&trades[0], &trades[1]);
|
|
||||||
move_em(&trades[1], &trades[0]);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* This routine does a switch from one player to another
|
* This routine does a switch from one player to another
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
move_em(from, to)
|
move_em(from, to)
|
||||||
TRADE *from, *to; {
|
TRADE *from, *to; {
|
||||||
|
|
||||||
@@ -179,21 +144,69 @@ TRADE *from, *to; {
|
|||||||
}
|
}
|
||||||
set_ownlist(to->trader);
|
set_ownlist(to->trader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine actually executes the trade.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
do_trade() {
|
||||||
|
|
||||||
|
move_em(&trades[0], &trades[1]);
|
||||||
|
move_em(&trades[1], &trades[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
trade() {
|
||||||
|
|
||||||
|
reg int tradee, i;
|
||||||
|
|
||||||
|
trading = TRUE;
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
trades[i].cash = 0;
|
||||||
|
trades[i].gojf = FALSE;
|
||||||
|
trades[i].prop_list = NULL;
|
||||||
|
}
|
||||||
|
over:
|
||||||
|
if (num_play == 1) {
|
||||||
|
printf("There ain't no-one around to trade WITH!!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (num_play > 2) {
|
||||||
|
tradee = getinp("Which player do you wish to trade with? ",
|
||||||
|
name_list);
|
||||||
|
if (tradee == num_play)
|
||||||
|
return;
|
||||||
|
if (tradee == player) {
|
||||||
|
printf("You can't trade with yourself!\n");
|
||||||
|
goto over;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tradee = 1 - player;
|
||||||
|
get_list(0, player);
|
||||||
|
get_list(1, tradee);
|
||||||
|
if (getyn("Do you wish a summary? ") == 0)
|
||||||
|
summate();
|
||||||
|
if (getyn("Is the trade ok? ") == 0)
|
||||||
|
do_trade();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine lets a player resign
|
* This routine lets a player resign
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
resign() {
|
resign() {
|
||||||
|
|
||||||
reg int i, new_own;
|
reg int i, new_own = 0;
|
||||||
reg OWN *op;
|
reg OWN *op;
|
||||||
SQUARE *sqp;
|
SQUARE *sqp;
|
||||||
|
|
||||||
if (cur_p->money <= 0) {
|
if (cur_p->money <= 0) {
|
||||||
switch (board[cur_p->loc].type) {
|
switch (board[(int)cur_p->loc].type) {
|
||||||
case UTIL:
|
case UTIL:
|
||||||
case RR:
|
case RR:
|
||||||
case PRPTY:
|
case PRPTY:
|
||||||
new_own = board[cur_p->loc].owner;
|
new_own = board[(int)cur_p->loc].owner;
|
||||||
break;
|
break;
|
||||||
case SPEC:
|
case SPEC:
|
||||||
case CC:
|
case CC:
|
||||||
@@ -220,7 +233,7 @@ resign() {
|
|||||||
} while (new_own == player);
|
} while (new_own == player);
|
||||||
name_list[num_play] = "done";
|
name_list[num_play] = "done";
|
||||||
}
|
}
|
||||||
if (getyn("Do you really want to resign? ", yesno) != 0)
|
if (getyn("Do you really want to resign? ") != 0)
|
||||||
return;
|
return;
|
||||||
if (num_play == 1) {
|
if (num_play == 1) {
|
||||||
printf("Then NOBODY wins (not even YOU!)\n");
|
printf("Then NOBODY wins (not even YOU!)\n");
|
||||||
@@ -254,7 +267,7 @@ resign() {
|
|||||||
for (i = player; i < num_play; i++) {
|
for (i = player; i < num_play; i++) {
|
||||||
name_list[i] = name_list[i+1];
|
name_list[i] = name_list[i+1];
|
||||||
if (i + 1 < num_play)
|
if (i + 1 < num_play)
|
||||||
cpy_st(&play[i], &play[i+1], sizeof (PLAY));
|
play[i] = play[i+1];
|
||||||
}
|
}
|
||||||
name_list[num_play--] = 0;
|
name_list[num_play--] = 0;
|
||||||
for (i = 0; i < N_SQRS; i++)
|
for (i = 0; i < N_SQRS; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user