public class PropertyFunctions { static boolean[] in = new boolean[Monop.MAX_PL]; static void buy(int player, Sqr_st sqrp) { Monop.trading = false; sqrp.owner = player; add_list(player, Monop.play[player].own_list, Monop.cur_p.loc); } static void add_list(int plr, Own_st head, int op_sqr) { int val = 0; Own_st tp = null; Own_st last_tp = null; Mon_st mp = null; Own_st op = new Own_st(); op.sqr = Monop.board[op_sqr]; val = value(op.sqr); last_tp = null; for (tp = head;tp != null && value(tp.sqr) < val;tp = tp.next) { if (val == value(tp.sqr)) { return; } else { last_tp = tp; } } op.next = tp; if (last_tp != null) { last_tp.next = op; } else { head = op; } if ( ! Monop.trading) { Misc.set_ownlist(plr); } } static void del_list(int plr, Own_st head, int op_sqr) { Own_st op = null; Own_st last_op = null; switch (Monop.board[op_sqr].type) { case Monop.PRPTY: Monop.board[op_sqr].desc.mon_desc.num_own--; break; case Monop.RR: Monop.play[plr].num_rr--; break; case Monop.UTIL: Monop.play[plr].num_util--; break; } last_op = null; for (op = head;op != null;op = op.next) { if (op.sqr == Monop.board[op_sqr]) { break; } else { last_op = op; } } if (last_op == null) { head = op.next; } else { last_op.next = op.next; } } static int value(Sqr_st sqp) { int sqr = Monop.sqnum(sqp); switch (sqp.type) { case Monop.SAFE: return 0; default : return 1; case Monop.UTIL: if (sqr == 12) { return 2; } else { return 3; } case Monop.RR: return 4 + sqr / 10; case Monop.PRPTY: return 8 + CUtils.indexOf(Monop.prop, sqp.desc); } } static void bid() { int i = 0; int num_in = 0; int cur_max = 0; String buf = new String(); int cur_bid = 0; System.out.println("\nSo it goes up for auction. Type your bid after your name"); for (i = 0;i < Monop.num_play;i++) { in[i] = true; } i = - 1; cur_max = 0; num_in = Monop.num_play; while (num_in > 1 || (cur_max == 0 && num_in > 0)) { i =++i % Monop.num_play; if (in[i]) { do { buf = (Monop.name_list[i]) + ": "; cur_bid = Misc.get_int(buf); if (cur_bid == 0) { in[i] = false; if (--num_in == 0) { break; } } else if (cur_bid <= cur_max) { System.out.println("You must bid higher than " + cur_max + " to stay in"); System.out.println("(bid of 0 drops you out)"); } } while (cur_bid != 0 && cur_bid <= cur_max); cur_max = cur_bid != 0 ? cur_bid:cur_max; } } if (cur_max != 0) { while ( ! in[i]) { i =++i % Monop.num_play; } System.out.println("It goes to " + (Monop.play[i].name) + " (" + (i + 1) + ") for $" + cur_max); buy(i, Monop.board[Monop.cur_p.loc]); Monop.play[i].money -= cur_max; } else { System.out.println("Nobody seems to want it, so we'll leave it for later"); } } static int prop_worth(Plr_st plp) { Own_st op = null; int worth = 0; for (op = plp.own_list;op != null;op = op.next) { if (op.sqr.type == Monop.PRPTY && op.sqr.desc.monop) { worth += op.sqr.desc.mon_desc.h_cost * 50 * op.sqr.desc.houses; } worth += op.sqr.cost; } return worth; } }