2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * mark.c: Display report for commodities
30 * Known contributors to this file:
41 #include "commodity.h"
51 pr("The market is disabled.\n");
54 if (player->argp[1] && *(player->argp[1]))
55 return display_mark(player->argp[1]);
57 return display_mark(" ");
61 pr_mark(struct comstr *comm)
65 extern int MARK_DELAY;
68 tleft = MARK_DELAY / 3600.0 - (now - comm->com_markettime) / 3600.0;
71 pr(" %3d $%12.2f %2d %5.2f hrs (%3d) %c %6d ",
75 tleft, comm->com_owner, comm->com_type, comm->com_amount);
76 if (comm->com_owner == player->cnum || player->god)
77 pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
82 display_mark(s_char *arg)
92 int cheapest_items[I_MAX + 2];
96 /* First, we execute all trades, so that we can only buy what is available. */
100 p = getstarg(arg, "What commodity (or 'all')? ", buf);
104 for (ip = &ichr[0]; ip && ip->i_mnem; ip++)
109 pr("\n Empire Market Report\n ");
111 pr(" lot high bid/unit by time left owner item amount sector\n");
112 pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
115 if (strcmp(arg, "all"))
119 /* Ok, just printing the lowest of all of them */
120 for (i = 0; i < I_MAX + 2; i++)
121 cheapest_items[i] = -1;
122 for (sellers = 0; getcomm(sellers, &comm); sellers++) {
123 if (comm.com_owner == 0)
125 for (i = 0, ip = &ichr[0]; ip && ip->i_mnem; ip++, i++)
126 if (ip->i_mnem == comm.com_type)
130 if (cheapest_items[i] != -1) {
131 getcomm(cheapest_items[i], &comm2);
132 if (comm.com_maxprice < comm2.com_maxprice) {
133 cheapest_items[i] = sellers;
136 cheapest_items[i] = sellers;
139 for (i = 0; i < I_MAX + 2; i++) {
140 if (cheapest_items[i] == -1)
142 getcomm(cheapest_items[i], &comm);
147 /* Ok, print them all, or all of this type */
148 for (sellers = 0; getcomm(sellers, &comm); sellers++) {
149 if (comm.com_owner == 0)
151 if (c && comm.com_type != c)
158 pr("\nHmmmm, the market seems to be empty today.\n");
160 pr("\nLooks just like Christmas at K-mart, doesn't it!\n");