]> git.pond.sub.org Git - empserver/blob - src/lib/subs/caploss.c
Update known contributors comment.
[empserver] / src / lib / subs / caploss.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2006, 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 files README, COPYING and CREDITS in the root of the source
23  *  tree for related information and legal notices.  It is expected
24  *  that future projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  caploss.c: Lose your capital (kiss of death)
29  * 
30  *  Known contributors to this file:
31  *     Steve McClure, 2000
32  */
33
34 #include <config.h>
35
36 #include "misc.h"
37 #include "player.h"
38 #include "nat.h"
39 #include "file.h"
40 #include "news.h"
41 #include "prototypes.h"
42 #include "optlist.h"
43
44 void
45 caploss(struct sctstr *sp, natid coun, s_char *msg)
46 {
47     struct natstr *natp;
48     struct lonstr loan;
49     struct comstr comm;
50     long lose;
51     long gain;
52     int loan_num = 0;
53     int comm_num = 0;
54
55     if (coun == 0)
56         return;
57     natp = getnatp(coun);
58     if ((xrel(natp, natp->nat_xcap) != xrel(natp, sp->sct_x)) ||
59         (yrel(natp, natp->nat_ycap) != yrel(natp, sp->sct_y)))
60         return;
61     if (coun == player->cnum) {
62         player->nstat &= ~CAP;
63         return;
64     }
65     /* Ok, has the country owner reset their capital yet after it was last sacked? */
66     if (natp->nat_flags & NF_SACKED)
67         return;                 /* No, so not really the capital yet, so return */
68     pr(msg, natp->nat_cnam);
69     gain = lose = natp->nat_money / 2;
70     if (lose < 3000)
71         lose = 3000;
72     natp->nat_money -= lose;
73     /* Your capital has now been sacked, no more sacking until you reset it */
74     natp->nat_flags |= NF_SACKED;
75     putnat(natp);
76     wu(0, coun, "* %s just sacked your capital! *\n", cname(player->cnum));
77
78     if (gain >= 0) {
79         gain = (0.2 + 0.8 * (sp->sct_effic / 100.0)) * gain;
80         player->dolcost -= gain;
81     } else
82         gain = 0;
83     wu(0, coun, "You lost $%ld and they gained $%ld\n", lose, gain);
84     wu(0, coun,
85        "Your capital has been moved to %s. You must use 'capital' to reset it.\n",
86        xyas(natp->nat_xcap, natp->nat_ycap, coun));
87     wu(0, 0, "%s just took %s's capital and gained $%d\n",
88        cname(player->cnum), cname(coun), -(int)(player->dolcost));
89     if (opt_LOANS) {
90         for (loan_num = 0; getloan(loan_num, &loan); loan_num++) {
91             if (loan.l_ldur != 0 && loan.l_loner == coun) {
92                 loan.l_loner = player->cnum;
93                 putloan(loan_num, &loan);
94                 pr("Loan %d has been transfered over to you\n", loan_num);
95             }
96         }
97     }
98     if (opt_MARKET) {
99         for (comm_num = 0; getcomm(comm_num, &comm); comm_num++) {
100             if (comm.com_owner == coun) {
101                 if (comm.com_owner == comm.com_maxbidder)
102                     comm.com_maxbidder = player->cnum;
103                 comm.com_owner = player->cnum;
104                 putcomm(comm_num, &comm);
105                 pr("You now own commodity #%d.\n", comm_num);
106             }
107         }
108     }
109     nreport(player->cnum, N_SACK_CAP, coun, 1);
110 }