]> git.pond.sub.org Git - empserver/blob - src/lib/commands/nati.c
Update copyright notice
[empserver] / src / lib / commands / nati.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                Ken Stevens, Steve McClure, Markus Armbruster
5  *
6  *  Empire 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 3 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, see <http://www.gnu.org/licenses/>.
18  *
19  *  ---
20  *
21  *  See files README, COPYING and CREDITS in the root of the source
22  *  tree for related information and legal notices.  It is expected
23  *  that future projects/authors will amend these files as needed.
24  *
25  *  ---
26  *
27  *  nati.c: List nation information
28  *
29  *  Known contributors to this file:
30  *
31  */
32
33 #include <config.h>
34
35 #include "commands.h"
36 #include "optlist.h"
37
38 int
39 nati(void)
40 {
41     struct natstr *natp;
42     struct sctstr sect;
43     double hap;
44     int mil;
45     int civ;
46     int cnum;
47     int poplimit, safepop, uwpop;
48     double pfac;
49
50     if (player->argp[1]) {
51         if (!(natp = natargp(player->argp[1], NULL)))
52             return RET_SYN;
53     } else
54         natp = getnatp(player->cnum);
55
56     cnum = natp->nat_cnum;
57     if (!player->god && cnum != player->cnum) {
58         pr("Only deities can request a nation report for another country.\n");
59         return RET_FAIL;
60     }
61
62     pr("\n(#%d) %s Nation Report\t", cnum, cname(cnum));
63     prdate();
64     pr("Nation status is %s", natstate(natp));
65     pr("     Bureaucratic Time Units: %d\n", natp->nat_btu);
66     if (natp->nat_stat != STAT_UNUSED) {
67         getsect(natp->nat_xcap, natp->nat_ycap, &sect);
68         if (influx(natp))
69             pr("No capital (was at %s).\n",
70                xyas(sect.sct_x, sect.sct_y, player->cnum));
71         else {
72             civ = sect.sct_item[I_CIVIL];
73             mil = sect.sct_item[I_MILIT];
74             pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
75                sect.sct_effic,
76                sect.sct_type == SCT_CAPIT ? "capital" : "mountain capital",
77                xyas(sect.sct_x, sect.sct_y, player->cnum),
78                civ, splur(civ), mil);
79         }
80     }
81     pr(" The treasury has $%.2f", (double)natp->nat_money);
82     pr("     Military reserves: %d\n", natp->nat_reserve);
83     pr("Education..........%6.2f       Happiness.......%6.2f\n",
84        natp->nat_level[NAT_ELEV], natp->nat_level[NAT_HLEV]);
85     pr("Technology.........%6.2f       Research........%6.2f\n",
86        natp->nat_level[NAT_TLEV], natp->nat_level[NAT_RLEV]);
87     pr("Technology factor :%6.2f%%", tfact(cnum, 100.));
88
89     if (opt_NO_PLAGUE)
90         pfac = 0.0;
91     else
92         pfac = (natp->nat_level[NAT_TLEV] + 100.0) /
93             (natp->nat_level[NAT_RLEV] + 100.0);
94     pr("     Plague factor : %6.2f%%\n", pfac);
95     pr("\n");
96
97     poplimit = max_population(natp->nat_level[NAT_RLEV], SCT_MINE, 0);
98     pr("Max population : %d\n", poplimit);
99
100     safepop = (int)(poplimit / (1.0 + obrate * (double)etu_per_update));
101     uwpop = (int)(poplimit / (1.0 + uwbrate * (double)etu_per_update));
102     pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
103
104     hap = hap_req(natp);
105     if (hap > 0.0)
106         pr("Happiness needed is %.2f\n", hap);
107     else
108         pr("No happiness needed\n");
109
110     return RET_OK;
111 }