2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
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.
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.
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
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.
28 * head.c: Print headlines of the Empire News
30 * Known contributors to this file:
48 static s_char *head_meanwhile(int val);
49 static s_char *head_describe(struct histstr *hp, int what);
50 static int head_printscoop(struct histstr (*hist)[MAXNOC], natid ano, natid vno);
51 static int head_findscoop(struct histstr (*hist)[MAXNOC], register natid maxcnum, natid *ano, natid *vno);
57 register struct histstr *hp;
58 register natid maxcnum;
64 struct histstr hist[MAXNOC][MAXNOC];
69 struct nstr_item nstr;
73 natp = getnatp(player->cnum);
74 if (player->argp[1] != 0 && *player->argp[1] != 0) {
75 news_per = days(atoi(player->argp[1]));
76 if (news_per > days(3))
79 /* replaced the following line with the one under it to
80 * fix headlines which never change.
81 * 3/3/90 bailey@math-cs.kent.edu
83 /* news_per = natp->nat_newstim; */
84 news_per = now - natp->nat_newstim;
85 pr("\n -=[ EMPIRE NEWS ]=-\n");
86 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
87 pr("! \"All the news that fits, we print.\" !\n");
88 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
89 pr(" %s", ctime(&now));
91 bzero((s_char *)hist, sizeof (hist));
92 snxtitem_all(&nstr, EF_NEWS);
94 while (nxtitem(&nstr, (s_char *)&news)) {
95 news_age = now - news.nws_when;
96 if (news_age > news_per)
98 if (news.nws_ano == news.nws_vno)
100 if ((i = rpt[(int)news.nws_vrb].r_good_will) == 0)
102 if (news_age > (news_per / 2))
103 hist[news.nws_ano][news.nws_vno].h_past += i;
105 hist[news.nws_ano][news.nws_vno].h_recent += i;
106 if (maxcnum < news.nws_ano)
107 maxcnum = news.nws_ano;
108 if (maxcnum < news.nws_vno)
109 maxcnum = news.nws_vno;
111 for (n=0; n<5; n++) {
112 if ((scoop = head_findscoop(hist, maxcnum, &actor, &victim))<10)
114 severity = head_printscoop(hist, actor, victim);
115 hp = &hist[actor][victim];
116 severity = hp->h_recent - hp->h_past;
117 if (severity <= -scoop/2 || severity >= scoop/2) {
118 pr("\t%s\n", head_meanwhile(severity));
119 (void) head_printscoop(hist, victim, actor);
123 pr("\nRelative calm prevails.\n");
129 head_printscoop(struct histstr (*hist)[MAXNOC], natid ano, natid vno)
131 register struct histstr *hp;
134 hp = &hist[ano][vno];
135 severity = abs(hp->h_past) > abs(hp->h_recent) ? 1 : 0;
136 severity += (hp->h_past >= 0) ? 2 : 0;
137 severity += (hp->h_recent >= 0) ? 4 : 0;
138 pr(head_describe(hp, severity), cname(ano), cname(vno));
147 head_meanwhile(int val)
153 return "On the other hand";
155 return "At the same time";
165 head_describe(struct histstr *hp, int what)
172 if (hp->h_recent > hp->h_past/2)
173 cp = "Bad relations between %s and %s worsen!";
175 cp = "Carnage wrought by %s on %s continues unabated!";
178 if (hp->h_recent < -16)
179 cp = "%s agression against %s has lessened slightly";
181 cp = "Peace talks may occur between %s & %s";
184 if (hp->h_recent < -16) {
186 cp = " ! WAR ! Reversal of prior %s -- %s relations";
187 else if (hp->h_recent >= -25)
188 cp = "VIOLENCE ERUPTS! -- %s wages war on %s";
190 cp = "%s wreaks havoc on %s!";
192 cp = "Breakdown in communication between %s & %s";
195 cp = "FLASH! %s turns on former ally, %s!";
198 cp = "%s \"makes friends\" with %s";
201 if (hp->h_past >= -25)
202 cp = "%s seems to have forgotten earlier disagreement with %s";
204 cp = "Tensions ease as %s attacks on %s seem at an end";
207 cp = "%s good deeds further growing alliance with %s";
210 if (hp->h_recent - hp->h_past < 12)
211 cp = "Honeymoon appears to be over between %s & %s";
213 cp = "Friendly relations between %s & %s have cooled";
220 * returns 9 if no scoops were found
225 head_findscoop(struct histstr (*hist)[MAXNOC], register natid maxcnum, natid *ano, natid *vno)
227 register struct histstr *hp;
238 for (i = 1; i < maxcnum; i++) {
239 for (j = 1; j < maxcnum; j++) {
241 k = abs(hp->h_recent / 2);
247 k = abs(hp->h_recent - hp->h_past);