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