2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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 * shark.c: Transfer a loan by buying it out
30 * Known contributors to this file:
32 * Steve McClure, 1996-2000
63 pr("Loans are not enabled.\n");
66 p = getstarg(player->argp[1], "Transfer which loan #: ", buf);
74 /* Check if it's a valid loan to shark. That means, is it a valid loan,
75 not owed to this player, with a valid duration and it's been signed. */
76 if (!getloan(arg, &loan) || (loan.l_loner == player->cnum) ||
77 (loan.l_ldur == 0) || (loan.l_status != LS_SIGNED)) {
81 /* If we got here, we check to see if it's been defaulted on. */
82 owed = loan_owed(&loan, time(&now));
83 if (now <= loan.l_duedate) {
84 pr("There has been no default on loan %d\n", arg);
87 pr("That loan is worth $%.2f.\n", owed);
88 natp = getnatp(player->cnum);
89 payment = (long)ceil(owed * (1.0 + loan.l_irate / 100.0));
90 if (payment > natp->nat_money - 100.0) {
91 pr("You do not have enough to cover that loan\n");
95 "%s bought loan #%d. You now owe him!\n",
96 cname(player->cnum), arg);
98 "%s bought loan #%d out from under you for %ld\n",
99 cname(player->cnum), arg, payment);
100 pr("You now own loan #%d. Go break some legs.\n", arg);
102 oldie = getnatp(loan.l_loner);
103 oldie->nat_money += payment;
104 player->dolcost += payment;
105 loan.l_loner = player->cnum;