|
|
1.1 ! root 1: # include "monop.ext" ! 2: ! 3: /* ! 4: * This routine deals with buying property, setting all the ! 5: * appropriate flags. ! 6: */ ! 7: buy(player, sqrp) ! 8: reg int player; ! 9: reg SQUARE *sqrp; { ! 10: ! 11: trading = FALSE; ! 12: sqrp->owner = player; ! 13: add_list(player, &(play[player].own_list), cur_p->loc); ! 14: } ! 15: /* ! 16: * This routine adds an item to the list. ! 17: */ ! 18: add_list(plr, head, op_sqr) ! 19: int plr; ! 20: OWN **head; ! 21: int op_sqr; { ! 22: ! 23: reg int val; ! 24: reg OWN *tp, *last_tp; ! 25: MON *mp; ! 26: OWN *op; ! 27: ! 28: op = calloc(1, sizeof (OWN)); ! 29: op->sqr = &board[op_sqr]; ! 30: val = value(op->sqr); ! 31: last_tp = NULL; ! 32: for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next) ! 33: if (val == value(tp->sqr)) { ! 34: cfree(op); ! 35: return; ! 36: } ! 37: else ! 38: last_tp = tp; ! 39: op->next = tp; ! 40: if (last_tp != NULL) ! 41: last_tp->next = op; ! 42: else ! 43: *head = op; ! 44: if (!trading) ! 45: set_ownlist(plr); ! 46: } ! 47: /* ! 48: * This routine deletes property from the list. ! 49: */ ! 50: del_list(plr, head, op_sqr) ! 51: int plr; ! 52: OWN **head; ! 53: shrt op_sqr; { ! 54: ! 55: reg int i; ! 56: reg OWN *op, *last_op; ! 57: ! 58: switch (board[op_sqr].type) { ! 59: case PRPTY: ! 60: board[op_sqr].desc->mon_desc->num_own--; ! 61: break; ! 62: case RR: ! 63: play[plr].num_rr--; ! 64: break; ! 65: case UTIL: ! 66: play[plr].num_util--; ! 67: break; ! 68: } ! 69: last_op = NULL; ! 70: for (op = *head; op; op = op->next) ! 71: if (op->sqr == &board[op_sqr]) ! 72: break; ! 73: else ! 74: last_op = op; ! 75: if (last_op == NULL) ! 76: *head = op->next; ! 77: else { ! 78: last_op->next = op->next; ! 79: cfree(op); ! 80: } ! 81: } ! 82: /* ! 83: * This routine calculates the value for sorting of the ! 84: * given square. ! 85: */ ! 86: value(sqp) ! 87: reg SQUARE *sqp; { ! 88: ! 89: reg int sqr; ! 90: ! 91: sqr = sqnum(sqp); ! 92: switch (sqp->type) { ! 93: case SAFE: ! 94: return 0; ! 95: case SPEC: ! 96: return 1; ! 97: case UTIL: ! 98: if (sqr == 12) ! 99: return 2; ! 100: else ! 101: return 3; ! 102: case RR: ! 103: return 4 + sqr/10; ! 104: case PRPTY: ! 105: return 8 + (PROP *)(sqp->desc) - prop; ! 106: } ! 107: } ! 108: /* ! 109: * This routine accepts bids for the current peice ! 110: * of property. ! 111: */ ! 112: bid() { ! 113: ! 114: static bool in[MAX_PL]; ! 115: reg int i, num_in, cur_max; ! 116: char buf[80]; ! 117: int cur_bid; ! 118: ! 119: printf("\nSo it goes up for auction. Type your bid after your name\n"); ! 120: for (i = 0; i < num_play; i++) ! 121: in[i] = TRUE; ! 122: i = -1; ! 123: cur_max = 0; ! 124: num_in = num_play; ! 125: while (num_in > 1 || (cur_max == 0 && num_in > 0)) { ! 126: i = ++i % num_play; ! 127: if (in[i]) { ! 128: do { ! 129: sprintf(buf, "%s: ", name_list[i]); ! 130: cur_bid = get_int(buf); ! 131: if (cur_bid == 0) { ! 132: in[i] = FALSE; ! 133: if (--num_in == 0) ! 134: break; ! 135: } ! 136: else if (cur_bid <= cur_max) { ! 137: printf("You must bid higher than %d to stay in\n", cur_max); ! 138: printf("(bid of 0 drops you out)\n"); ! 139: } ! 140: } while (cur_bid != 0 && cur_bid <= cur_max); ! 141: cur_max = (cur_bid ? cur_bid : cur_max); ! 142: } ! 143: } ! 144: if (cur_max != 0) { ! 145: while (!in[i]) ! 146: i = ++i % num_play; ! 147: printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max); ! 148: buy(i, &board[cur_p->loc]); ! 149: play[i].money -= cur_max; ! 150: } ! 151: else ! 152: printf("Nobody seems to want it, so we'll leave it for later\n"); ! 153: } ! 154: /* ! 155: * This routine calculates the value of the property ! 156: * of given player. ! 157: */ ! 158: prop_worth(plp) ! 159: reg PLAY *plp; { ! 160: ! 161: reg OWN *op; ! 162: reg int worth; ! 163: ! 164: worth = 0; ! 165: for (op = plp->own_list; op; op = op->next) { ! 166: if (op->sqr->type == PRPTY && op->sqr->desc->monop) ! 167: worth += op->sqr->desc->mon_desc->h_cost * 50 * ! 168: op->sqr->desc->houses; ! 169: worth += op->sqr->cost; ! 170: } ! 171: return worth; ! 172: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.