]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_bank.cpp
10 char *cmd
= strtok(NULL
, " ");
11 char *amount
= strtok(NULL
, " ");
12 char *nick
= strtok(NULL
, " ");
17 if (!cmd
|| (!amount
&& stricmp(cmd
, "BALANCE") != 0) || (stricmp(cmd
, "TRANSFER") == 0 && !nick
))
19 notice(s_GameServ
, u
, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}");
20 notice (s_GameServ
, u
, "BANK BALANCE");
23 else if (!(user
= find(u
)))
25 notice(s_GameServ
, u
, "Fatal Error. Couldn't find your aClient. Contact a(n) <S "\
27 log("Fatal Error. Couldn't find %s while executing do_bank()", u
);
30 else if (isIgnore(user
))
33 log("Ignoring %s.", user
->getNick());
37 else if (!is_playing(user
))
39 notice(s_GameServ
, u
, "You must be playing to use the bank!");
42 else if (is_fighting(user
))
44 notice(s_GameServ
, u
, "You can't go to the bank during a fight!");
47 updateTS(user
->stats
);
48 if (stricmp(cmd
, "BALANCE") == 0)
53 else if (!isAlive(user
->stats
))
55 notice(s_GameServ
, u
, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!");
58 else if (!isstringnum(amount
) && stricmp(amount
, "ALL") != 0)
60 notice(s_GameServ
, u
, "I don't know how to convert alphabet letters into currency, sire!");
63 if (stringtoint(amount
) < 0)
65 notice(s_GameServ
, u
, "Sorry. This bank is not licensed "\
66 "to handle such sums of cash, noble Lord.");
71 if (stricmp(cmd
, "DEPOSIT") == 0)
73 if (p
->getBank() == 2000000000)
75 notice(s_GameServ
, u
, "Your bank account is full, sire!");
78 else if (stricmp(amount
, "ALL") == 0)
80 if (2000000000 - p
->getBank() < p
->getGold())
82 notice(s_GameServ
, u
, "You don't have enough room for all of your gold.");
83 notice(s_GameServ
, u
, "Depositing %ld gold into your account", (2000000000 - p
->getBank()));
84 p
->subtractGold((2000000000 - p
->getBank()));
85 p
->setBank(2000000000);
90 notice(s_GameServ
, u
, "Depositing %ld gold into your account!", p
->getGold());
91 p
->addBank(p
->getGold());
96 else if (stringtoint(amount
) > p
->getGold())
98 notice(s_GameServ
, u
, "Sire, you only have %ld gold!", p
->getGold());
104 if (2000000000 - p
->getBank() < stringtoint(amount
))
106 notice(s_GameServ
, u
, "You don't have room in your account for that much.");
107 notice(s_GameServ
, u
, "Capping off your account with %ld gold!", (2000000000 - p
->getBank()));
108 p
->subtractGold((2000000000 - p
->getBank()));
109 p
->setBank(2000000000);
114 notice(s_GameServ
, u
, "Depositing %d gold into your account!", stringtoint(amount
));
115 p
->addBank(stringtoint(amount
));
116 p
->subtractGold(stringtoint(amount
));
121 else if (stricmp(cmd
, "WITHDRAW") == 0)
123 if (p
->getGold() == 2000000000)
125 notice(s_GameServ
, u
, "You cannot carry any more gold, sire!");
129 else if (stricmp(amount
, "ALL") == 0)
131 if (2000000000 - p
->getGold() < p
->getBank())
133 notice(s_GameServ
, u
, "You don't have enough room to carry all that gold.");
134 notice(s_GameServ
, u
, "Withdrawing %ld gold from your account", (2000000000 - p
->getGold()));
135 p
->subtractBank((2000000000 - p
->getGold()));
136 p
->setGold(2000000000);
141 notice(s_GameServ
, u
, "Withdrawing %ld gold from your account!", p
->getBank());
142 p
->addGold(p
->getBank());
147 else if (stringtoint(amount
) > p
->getBank())
149 notice(s_GameServ
, u
, "Sire, you only have %ld gold in the bank!", p
->getBank());
155 if (2000000000 - p
->getGold() < stringtoint(amount
))
157 notice(s_GameServ
, u
, "You don't enough have room to carry that much gold!");
158 notice(s_GameServ
, u
, "You fill your pockets with %ld gold!",
159 (2000000000 - p
->getGold()));
160 p
->subtractBank((2000000000 - p
->getGold()));
161 p
->setGold(2000000000);
166 notice(s_GameServ
, u
, "Withdrawing %d gold from your account!", stringtoint(amount
));
167 p
->addGold(stringtoint(amount
));
168 p
->subtractBank(stringtoint(amount
));