Annotation of 43BSDReno/games/monop/jail.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)jail.c     5.3 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: # include      "monop.ext"
        !            25: 
        !            26: /*
        !            27:  *     This routine uses a get-out-of-jail-free card to get the
        !            28:  * player out of jail.
        !            29:  */
        !            30: card() {
        !            31: 
        !            32:        if (cur_p->loc != JAIL) {
        !            33:                printf("But you're not IN Jail\n");
        !            34:                return;
        !            35:        }
        !            36:        if (cur_p->num_gojf == 0) {
        !            37:                printf("But you don't HAVE a get out of jail free card\n");
        !            38:                return;
        !            39:        }
        !            40:        ret_card(cur_p);
        !            41:        cur_p->loc = 10;                        /* just visiting        */
        !            42:        cur_p->in_jail = 0;
        !            43: }
        !            44: /*
        !            45:  *     This routine returns the players get-out-of-jail-free card
        !            46:  * to a deck.
        !            47:  */
        !            48: ret_card(plr)
        !            49: reg PLAY       *plr; {
        !            50: 
        !            51:        plr->num_gojf--;
        !            52:        if (CC_D.gojf_used)
        !            53:                CC_D.gojf_used = FALSE;
        !            54:        else
        !            55:                CH_D.gojf_used = FALSE;
        !            56: }
        !            57: /*
        !            58:  *     This routine deals with paying your way out of jail.
        !            59:  */
        !            60: pay() {
        !            61: 
        !            62:        if (cur_p->loc != JAIL) {
        !            63:                printf("But you're not IN Jail\n");
        !            64:                return;
        !            65:        }
        !            66:        cur_p->loc = 10;
        !            67:        cur_p->money -= 50;
        !            68:        cur_p->in_jail = 0;
        !            69:        printf("That cost you $50\n");
        !            70: }
        !            71: /*
        !            72:  *     This routine deals with a move in jail
        !            73:  */
        !            74: move_jail(r1, r2)
        !            75: reg int        r1, r2; {
        !            76: 
        !            77:        if (r1 != r2) {
        !            78:                printf("Sorry, that doesn't get you out\n");
        !            79:                if (++(cur_p->in_jail) == 3) {
        !            80:                        printf("It's your third turn and you didn't roll doubles.  You have to pay $50\n");
        !            81:                        cur_p->money -= 50;
        !            82: moveit:
        !            83:                        cur_p->loc = 10;
        !            84:                        cur_p->in_jail = 0;
        !            85:                        move(r1+r2);
        !            86:                        r1 = r2 - 1;    /* kludge: stop new roll w/doub */
        !            87:                        return TRUE;
        !            88:                }
        !            89:                return FALSE;
        !            90:        }
        !            91:        else {
        !            92:                printf("Double roll gets you out.\n");
        !            93:                goto moveit;
        !            94:        }
        !            95: }
        !            96: printturn() {
        !            97: 
        !            98:        if (cur_p->loc != JAIL)
        !            99:                return;
        !           100:        printf("(This is your ");
        !           101:        switch (cur_p->in_jail) {
        !           102:          case 0:
        !           103:                printf("1st");
        !           104:                break;
        !           105:          case 1:
        !           106:                printf("2nd");
        !           107:                break;
        !           108:          case 2:
        !           109:                printf("3rd (and final)");
        !           110:                break;
        !           111:        }
        !           112:        printf(" turn in JAIL)\n");
        !           113: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.