]> git.pond.sub.org Git - empserver/blob - src/lib/commands/nati.c
Include config.h.
[empserver] / src / lib / commands / nati.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2005, 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 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.
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 "misc.h"
37 #include "player.h"
38 #include "nat.h"
39 #include "sect.h"
40 #include "file.h"
41 #include "xy.h"
42 #include "optlist.h"
43 #include "commands.h"
44
45 int
46 nati(void)
47 {
48     struct natstr *natp;
49     struct sctstr sect;
50     float hap;
51     int mil;
52     int civ;
53     int cnum;
54     int poplimit, safepop, uwpop;
55     double pfac;
56
57     if (player->argp[1])
58         cnum = natarg(player->argp[1], "for which country? ");
59     else
60         cnum = player->cnum;
61
62     if ((natp = getnatp(cnum)) == 0) {
63         pr("Bad country number %d\n", cnum);
64         return RET_SYN;
65     }
66
67     if (!player->god && cnum != player->cnum) {
68         pr("Only deities can request a nation "
69            "report for a different country than yourself.\n");
70         return RET_SYN;
71     }
72
73     pr("\n(#%i) %s Nation Report\t", cnum, cname(cnum));
74     prdate();
75     pr("Nation status is %s", natstate(natp));
76     pr("     Bureaucratic Time Units: %d\n", natp->nat_btu);
77     if (natp->nat_stat & STAT_INUSE) {
78         getsect(natp->nat_xcap, natp->nat_ycap, &sect);
79         if (influx(natp))
80             pr("No capital (was at %s).\n",
81                xyas(sect.sct_x, sect.sct_y, cnum));
82         else {
83             civ = sect.sct_item[I_CIVIL];
84             mil = sect.sct_item[I_MILIT];
85             pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
86                sect.sct_effic,
87                (sect.sct_type ==
88                 SCT_CAPIT ? "capital" : "mountain capital"),
89                xyas(sect.sct_x, sect.sct_y, cnum), civ, splur(civ),
90                mil);
91         }
92     }
93     pr(" The treasury has $%.2f", (double)natp->nat_money);
94     pr("     Military reserves: %ld\n", natp->nat_reserve);
95     pr("Education..........%6.2f       Happiness.......%6.2f\n",
96        (double)natp->nat_level[NAT_ELEV],
97        (double)natp->nat_level[NAT_HLEV]);
98     pr("Technology.........%6.2f       Research........%6.2f\n",
99        (double)natp->nat_level[NAT_TLEV],
100        (double)natp->nat_level[NAT_RLEV]);
101     pr("Technology factor :%6.2f%%", tfact(cnum, 100.));
102
103     if (opt_NO_PLAGUE)
104         pfac = 0.0;
105     else
106         pfac = ((double)natp->nat_level[NAT_TLEV] + 100.) /
107             ((double)natp->nat_level[NAT_RLEV] + 100.);
108     pr("     Plague factor : %6.2f%%\n", pfac);
109     pr("\n");
110
111     poplimit = max_population(natp->nat_level[NAT_RLEV], SCT_MINE, 0);
112     pr("Max population : %d\n", poplimit);
113
114     safepop =
115         (int)((double)poplimit / (1.0 + obrate * (double)etu_per_update));
116     uwpop =
117         (int)((double)poplimit / (1.0 + uwbrate * (double)etu_per_update));
118     safepop++;
119     if (((double)safepop * (1.0 + obrate * (double)etu_per_update)) >
120         ((double)poplimit + 0.0000001))
121         safepop--;
122     uwpop++;
123     if (((double)uwpop * (1.0 + uwbrate * (double)etu_per_update)) >
124         ((double)poplimit + 0.0000001))
125         uwpop--;
126
127     pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
128
129     hap = ((natp->nat_level[NAT_TLEV] - 40) / 40.0 +
130            natp->nat_level[NAT_ELEV] / 3.0);
131
132     if (hap > 0.0)
133         pr("Happiness needed is %f\n", hap);
134     else
135         pr("No happiness needed\n");
136
137     return RET_OK;
138 }