2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * mark.c: Display report for commodities
30 * Known contributors to this file:
39 #include "commodity.h"
51 pr("The market is disabled.\n");
55 if (player->argp[1] && player->argp[1]) {
56 p = getstarg(player->argp[1], "What commodity (or 'all')? ", buf);
59 if (!strcmp(p, "all"))
60 return display_mark(I_NONE, 0);
65 return display_mark(ip->i_uid, 0);
68 return display_mark(I_NONE, 1);
72 pr_mark(struct comstr *comm)
78 tleft = MARK_DELAY / 3600.0 - (now - comm->com_markettime) / 3600.0;
81 pr(" %3d $%12.2f %2d %5.2f hrs (%3d) %c %6d ",
82 comm->com_uid, comm->com_price, comm->com_maxbidder, tleft,
83 comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
84 if (comm->com_owner == player->cnum || player->god)
85 pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
90 display_mark(i_type only_itype, int only_cheapest)
96 int cheapest_items[I_MAX + 1];
99 /* Execute trades so report lists only lots that are still available. */
103 pr("\n Empire Market Report\n ");
105 pr(" lot high bid/unit by time left owner item amount sector\n");
106 pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
109 for (i = I_NONE + 1; i <= I_MAX; i++)
110 cheapest_items[i] = -1;
111 for (sellers = 0; getcomm(sellers, &comm); sellers++) {
112 if (comm.com_owner == 0)
114 if (CANT_HAPPEN(comm.com_type <= I_NONE || comm.com_type > I_MAX))
116 if (cheapest_items[comm.com_type] != -1) {
117 getcomm(cheapest_items[comm.com_type], &comm2);
118 if (comm.com_price < comm2.com_price) {
119 cheapest_items[comm.com_type] = sellers;
122 cheapest_items[comm.com_type] = sellers;
125 CANT_HAPPEN(only_itype != I_NONE); /* not implemented */
126 for (i = I_NONE + 1; i <= I_MAX; i++) {
127 if (cheapest_items[i] == -1)
129 getcomm(cheapest_items[i], &comm);
134 for (sellers = 0; getcomm(sellers, &comm); sellers++) {
135 if (comm.com_owner == 0)
137 if (only_itype != I_NONE && comm.com_type != only_itype)
144 pr("\nHmmmm, the market seems to be empty today.\n");
146 pr("\nLooks just like Christmas at K-mart, doesn't it!\n");