date and time created 88/01/02 20:53:25 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 3 Jan 1988 12:53:25 +0000 (04:53 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 3 Jan 1988 12:53:25 +0000 (04:53 -0800)
SCCS-vsn: games/monop/jail.c 5.1

usr/src/games/monop/jail.c [new file with mode: 0644]

diff --git a/usr/src/games/monop/jail.c b/usr/src/games/monop/jail.c
new file mode 100644 (file)
index 0000000..bbdfc42
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)jail.c     5.1 (Berkeley) %G%";
+#endif /* not lint */
+
+# include      "monop.ext"
+
+/*
+ *     This routine uses a get-out-of-jail-free card to get the
+ * player out of jail.
+ */
+card() {
+
+       if (cur_p->loc != JAIL) {
+               printf("But you're not IN Jail\n");
+               return;
+       }
+       if (cur_p->num_gojf == 0) {
+               printf("But you don't HAVE a get out of jail free card\n");
+               return;
+       }
+       ret_card(cur_p);
+       cur_p->loc = 10;                        /* just visiting        */
+       cur_p->in_jail = 0;
+}
+/*
+ *     This routine returns the players get-out-of-jail-free card
+ * to a deck.
+ */
+ret_card(plr)
+reg PLAY       *plr; {
+
+       plr->num_gojf--;
+       if (CC_D.gojf_used)
+               CC_D.gojf_used = FALSE;
+       else
+               CH_D.gojf_used = FALSE;
+}
+/*
+ *     This routine deals with paying your way out of jail.
+ */
+pay() {
+
+       if (cur_p->loc != JAIL) {
+               printf("But you're not IN Jail\n");
+               return;
+       }
+       cur_p->loc = 10;
+       cur_p->money -= 50;
+       cur_p->in_jail = 0;
+       printf("That cost you $50\n");
+}
+/*
+ *     This routine deals with a move in jail
+ */
+move_jail(r1, r2)
+reg int        r1, r2; {
+
+       if (r1 != r2) {
+               printf("Sorry, that doesn't get you out\n");
+               if (++(cur_p->in_jail) == 3) {
+                       printf("It's your third turn and you didn't roll doubles.  You have to pay $50\n");
+                       cur_p->money -= 50;
+moveit:
+                       cur_p->loc = 10;
+                       cur_p->in_jail = 0;
+                       move(r1+r2);
+                       r1 = r2 - 1;    /* kludge: stop new roll w/doub */
+                       return TRUE;
+               }
+               return FALSE;
+       }
+       else {
+               printf("Double roll gets you out.\n");
+               goto moveit;
+       }
+}
+printturn() {
+
+       if (cur_p->loc != JAIL)
+               return;
+       printf("(This is your ");
+       switch (cur_p->in_jail) {
+         case 0:
+               printf("1st");
+               break;
+         case 1:
+               printf("2nd");
+               break;
+         case 2:
+               printf("3rd (and final)");
+               break;
+       }
+       printf(" turn in JAIL)\n");
+}