src/lib/commands/nati.c

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  nati.c: List nation information
00029  * 
00030  *  Known contributors to this file:
00031  *     
00032  */
00033 
00034 #include <config.h>
00035 
00036 #include "commands.h"
00037 #include "optlist.h"
00038 
00039 int
00040 nati(void)
00041 {
00042     struct natstr *natp;
00043     struct sctstr sect;
00044     double hap;
00045     int mil;
00046     int civ;
00047     int cnum;
00048     int poplimit, safepop, uwpop;
00049     double pfac;
00050 
00051     if (player->argp[1]) {
00052         if (!(natp = natargp(player->argp[1], NULL)))
00053             return RET_SYN;
00054     } else
00055         natp = getnatp(player->cnum);
00056 
00057     cnum = natp->nat_cnum;
00058     if (!player->god && cnum != player->cnum) {
00059         pr("Only deities can request a nation report for another country.\n");
00060         return RET_FAIL;
00061     }
00062 
00063     pr("\n(#%i) %s Nation Report\t", cnum, cname(cnum));
00064     prdate();
00065     pr("Nation status is %s", natstate(natp));
00066     pr("     Bureaucratic Time Units: %d\n", natp->nat_btu);
00067     if (natp->nat_stat != STAT_UNUSED) {
00068         getsect(natp->nat_xcap, natp->nat_ycap, &sect);
00069         if (influx(natp))
00070             pr("No capital (was at %s).\n",
00071                xyas(sect.sct_x, sect.sct_y, cnum));
00072         else {
00073             civ = sect.sct_item[I_CIVIL];
00074             mil = sect.sct_item[I_MILIT];
00075             pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
00076                sect.sct_effic,
00077                (sect.sct_type ==
00078                 SCT_CAPIT ? "capital" : "mountain capital"),
00079                xyas(sect.sct_x, sect.sct_y, cnum), civ, splur(civ),
00080                mil);
00081         }
00082     }
00083     pr(" The treasury has $%.2f", (double)natp->nat_money);
00084     pr("     Military reserves: %ld\n", natp->nat_reserve);
00085     pr("Education..........%6.2f       Happiness.......%6.2f\n",
00086        natp->nat_level[NAT_ELEV], natp->nat_level[NAT_HLEV]);
00087     pr("Technology.........%6.2f       Research........%6.2f\n",
00088        natp->nat_level[NAT_TLEV], natp->nat_level[NAT_RLEV]);
00089     pr("Technology factor :%6.2f%%", tfact(cnum, 100.));
00090 
00091     if (opt_NO_PLAGUE)
00092         pfac = 0.0;
00093     else
00094         pfac = (natp->nat_level[NAT_TLEV] + 100.0) /
00095             (natp->nat_level[NAT_RLEV] + 100.0);
00096     pr("     Plague factor : %6.2f%%\n", pfac);
00097     pr("\n");
00098 
00099     poplimit = max_population(natp->nat_level[NAT_RLEV], SCT_MINE, 0);
00100     pr("Max population : %d\n", poplimit);
00101 
00102     safepop = (int)(poplimit / (1.0 + obrate * (double)etu_per_update));
00103     uwpop = (int)(poplimit / (1.0 + uwbrate * (double)etu_per_update));
00104     pr("Max safe population for civs/uws: %d/%d\n", safepop, uwpop);
00105 
00106     hap = hap_req(natp);
00107     if (hap > 0.0)
00108         pr("Happiness needed is %.2f\n", hap);
00109     else
00110         pr("No happiness needed\n");
00111 
00112     return RET_OK;
00113 }

Generated on Fri Mar 28 11:01:12 2008 for empserver by  doxygen 1.5.2