Annotation of 43BSD/games/monop/morg.c, revision 1.1

1.1     ! root        1: # include      "monop.ext"
        !             2: 
        !             3: /*
        !             4:  *     These routines deal with mortgaging.
        !             5:  */
        !             6: 
        !             7: static char    *names[MAX_PRP+2],
        !             8:                *morg_coms[]    = {
        !             9:                        "quit",         /*  0 */
        !            10:                        "print",        /*  1 */
        !            11:                        "where",        /*  2 */
        !            12:                        "own holdings", /*  3 */
        !            13:                        "holdings",     /*  4 */
        !            14:                        "shell",        /*  5 */
        !            15:                        "mortgage",     /*  6 */
        !            16:                        "unmortgage",   /*  7 */
        !            17:                        "buy",          /*  8 */
        !            18:                        "sell",         /*  9 */
        !            19:                        "card",         /* 10 */
        !            20:                        "pay",          /* 11 */
        !            21:                        "trade",        /* 12 */
        !            22:                        "resign",       /* 13 */
        !            23:                        "save game",    /* 14 */
        !            24:                        "restore game", /* 15 */
        !            25:                        0
        !            26:                };
        !            27: 
        !            28: static shrt    square[MAX_PRP+2];
        !            29: 
        !            30: static int     num_good,got_houses;
        !            31: 
        !            32: /*
        !            33:  *     This routine is the command level response the mortgage command.
        !            34:  * it gets the list of mortgageable property and asks which are to
        !            35:  * be mortgaged.
        !            36:  */
        !            37: mortgage() {
        !            38: 
        !            39:        reg int prop;
        !            40: 
        !            41:        for (;;) {
        !            42:                if (set_mlist() == 0) {
        !            43:                        if (got_houses)
        !            44:                                printf("You can't mortgage property with houses on it.\n");
        !            45:                        else
        !            46:                                printf("You don't have any un-mortgaged property.\n");
        !            47:                        return;
        !            48:                }
        !            49:                if (num_good == 1) {
        !            50:                        printf("Your only mortageable property is %s\n",names[0]);
        !            51:                        if (getyn("Do you want to mortgage it? ") == 0)
        !            52:                                m(square[0]);
        !            53:                        return;
        !            54:                }
        !            55:                prop = getinp("Which property do you want to mortgage? ",names);
        !            56:                if (prop == num_good)
        !            57:                        return;
        !            58:                m(square[prop]);
        !            59:                notify(cur_p);
        !            60:        }
        !            61: }
        !            62: /*
        !            63:  *     This routine sets up the list of mortgageable property
        !            64:  */
        !            65: set_mlist() {
        !            66: 
        !            67:        reg OWN *op;
        !            68: 
        !            69:        num_good = 0;
        !            70:        for (op = cur_p->own_list; op; op = op->next)
        !            71:                if (!op->sqr->desc->morg)
        !            72:                        if (op->sqr->type == PRPTY && op->sqr->desc->houses)
        !            73:                                got_houses++;
        !            74:                        else {
        !            75:                                names[num_good] = op->sqr->name;
        !            76:                                square[num_good++] = sqnum(op->sqr);
        !            77:                        }
        !            78:        names[num_good++] = "done";
        !            79:        names[num_good--] = 0;
        !            80:        return num_good;
        !            81: }
        !            82: /*
        !            83:  *     This routine actually mortgages the property.
        !            84:  */
        !            85: m(prop)
        !            86: reg int        prop; {
        !            87: 
        !            88:        reg int price;
        !            89: 
        !            90:        price = board[prop].cost/2;
        !            91:        board[prop].desc->morg = TRUE;
        !            92:        printf("That got you $%d\n",price);
        !            93:        cur_p->money += price;
        !            94: }
        !            95: /*
        !            96:  *     This routine is the command level repsponse to the unmortgage
        !            97:  * command.  It gets the list of mortgaged property and asks which are
        !            98:  * to be unmortgaged.
        !            99:  */
        !           100: unmortgage() {
        !           101: 
        !           102:        reg int prop;
        !           103: 
        !           104:        for (;;) {
        !           105:                if (set_umlist() == 0) {
        !           106:                        printf("You don't have any mortgaged property.\n");
        !           107:                        return;
        !           108:                }
        !           109:                if (num_good == 1) {
        !           110:                        printf("Your only mortaged property is %s\n",names[0]);
        !           111:                        if (getyn("Do you want to unmortgage it? ") == 0)
        !           112:                                unm(square[0]);
        !           113:                        return;
        !           114:                }
        !           115:                prop = getinp("Which property do you want to unmortgage? ",names);
        !           116:                if (prop == num_good)
        !           117:                        return;
        !           118:                unm(square[prop]);
        !           119:        }
        !           120: }
        !           121: /*
        !           122:  *     This routine sets up the list of mortgaged property
        !           123:  */
        !           124: set_umlist() {
        !           125: 
        !           126:        reg OWN *op;
        !           127: 
        !           128:        num_good = 0;
        !           129:        for (op = cur_p->own_list; op; op = op->next)
        !           130:                if (op->sqr->desc->morg) {
        !           131:                        names[num_good] = op->sqr->name;
        !           132:                        square[num_good++] = sqnum(op->sqr);
        !           133:                }
        !           134:        names[num_good++] = "done";
        !           135:        names[num_good--] = 0;
        !           136:        return num_good;
        !           137: }
        !           138: /*
        !           139:  *     This routine actually unmortgages the property
        !           140:  */
        !           141: unm(prop)
        !           142: reg int        prop; {
        !           143: 
        !           144:        reg int price;
        !           145: 
        !           146:        price = board[prop].cost/2;
        !           147:        board[prop].desc->morg = FALSE;
        !           148:        price += price/10;
        !           149:        printf("That cost you $%d\n",price);
        !           150:        cur_p->money -= price;
        !           151:        set_umlist();
        !           152: }
        !           153: /*
        !           154:  *     This routine forces the indebted player to fix his
        !           155:  * financial woes.
        !           156:  */
        !           157: force_morg() {
        !           158: 
        !           159:        told_em = fixing = TRUE;
        !           160:        while (cur_p->money <= 0)
        !           161:                fix_ex(getinp("How are you going to fix it up? ",morg_coms));
        !           162:        fixing = FALSE;
        !           163: }
        !           164: /*
        !           165:  *     This routine is a special execute for the force_morg routine
        !           166:  */
        !           167: fix_ex(com_num)
        !           168: reg int        com_num; {
        !           169: 
        !           170:        told_em = FALSE;
        !           171:        (*func[com_num])();
        !           172:        notify();
        !           173: }

unix.superglobalmegacorp.com

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