]> git.pond.sub.org Git - empserver/blob - src/lib/commands/nati.c
8ee170a552eadf9eb0fef276baed59f7168a833a
[empserver] / src / lib / commands / nati.c
1 /*
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
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  nati.c: List nation information
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include <config.h>
35
36 #include "commands.h"
37 #include "optlist.h"
38
39 int
40 nati(void)
41 {
42     struct natstr *natp;
43     struct sctstr sect;
44     double hap;
45     int mil;
46     int civ;
47     int cnum;
48     int poplimit, safepop, uwpop;
49     double pfac;
50
51     if (player->argp[1]) {
52         if (!(natp = natargp(player->argp[1], NULL)))
53             return RET_SYN;
54     } else
55         natp = getnatp(player->cnum);
56
57     cnum = natp->nat_cnum;
58     if (!player->god && cnum != player->cnum) {
59         pr("Only deities can request a nation report for another country.\n");
60         return RET_FAIL;
61     }
62
63     pr("\n(#%i) %s Nation Report\t", cnum, cname(cnum));
64     prdate();
65     pr("Nation status is %s", natstate(natp));
66     pr("     Bureaucratic Time Units: %d\n", natp->nat_btu);
67     if (natp->nat_stat != STAT_UNUSED) {
68         getsect(natp->nat_xcap, natp->nat_ycap, &sect);
69         if (influx(natp))
70             pr("No capital (was at %s).\n",
71                xyas(sect.sct_x, sect.sct_y, cnum));
72         else {
73             civ = sect.sct_item[I_CIVIL];
74             mil = sect.sct_item[I_MILIT];
75             pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
76                sect.sct_effic,
77                (sect.sct_type ==
78                 SCT_CAPIT ? "capital" : "mountain capital"),
79                xyas(sect.sct_x, sect.sct_y, cnum), civ, splur(civ),
80                mil);
81         }
82     }
83     pr(" The treasury has $%.2f", (double)natp->nat_money);
84     pr("     Military reserves: %ld\n", natp->nat_reserve);
85     pr("Education..........%6.2f       Happiness.......%6.2f\n",
86        natp->nat_level[NAT_ELEV], natp->nat_level[NAT_HLEV]);
87     pr("Technology.........%6.2f       Research........%6.2f\n",
88        natp->nat_level[NAT_TLEV], natp->nat_level[NAT_RLEV]);
89     pr("Technology factor :%6.2f%%", tfact(cnum, 100.));
90
91     if (opt_NO_PLAGUE)
92         pfac = 0.0;
93     else
94         pfac = (natp->nat_level[NAT_TLEV] + 100.0) /
95             (natp->nat_level[NAT_RLEV] + 100.0);
96     pr("     Plague factor : %6.2f%%\n", pfac);
97     pr("\n");
98
99     poplimit = max_population(natp->nat_level[NAT_RLEV], SCT_MINE, 0);
100     pr("Max population : %d\n", poplimit);
101
102     safepop = (int)(poplimit / (1.0 + obrate * (double)etu_per_update));
103     uwpop = (int)(poplimit / (1.0 + uwbrate * (double)etu_per_update));
104     pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
105
106     hap = hap_req(natp);
107     if (hap > 0.0)
108         pr("Happiness needed is %.2f\n", hap);
109     else
110         pr("No happiness needed\n");
111
112     return RET_OK;
113 }