From: kainazzzo Date: Mon, 22 Jan 2007 04:24:50 +0000 (+0000) Subject: Added do_bank.cpp, do_check.cpp, do_equip.cpp, and do_fight.cpp X-Git-Url: https://jfr.im/git/irc/gameservirc.git/commitdiff_plain/585b7bdee94740677f19c9c609cd626fdc0bc1b1 Added do_bank.cpp, do_check.cpp, do_equip.cpp, and do_fight.cpp Updated dependencies, and removed functions from gameserv.cpp corresponding to the individual files git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@475 bc333340-6410-0410-a689-9d09f3c113fa --- diff --git a/gameserv/.depend b/gameserv/.depend index 63a86fb..7041eb1 100644 --- a/gameserv/.depend +++ b/gameserv/.depend @@ -9,6 +9,13 @@ do_admin.o: do_admin.cpp extern.h config.h options.h aClient.h player.h \ script.h flags.h do_attack.o: do_attack.cpp aClient.h options.h player.h script.h extern.h \ config.h flags.h level.h item.h +do_bank.o: do_bank.cpp extern.h config.h options.h aClient.h player.h \ + script.h flags.h +do_check.o: do_check.cpp extern.h config.h options.h flags.h +do_equip.o: do_equip.cpp extern.h config.h options.h aClient.h player.h \ + script.h pouch.h item.h level.h flags.h +do_fight.o: do_fight.cpp extern.h config.h options.h aClient.h player.h \ + script.h flags.h find.o: find.cpp extern.h config.h options.h item.h level.h player.h \ script.h gameserv.o: gameserv.cpp aClient.h options.h player.h script.h config.h \ diff --git a/gameserv/Makefile.in b/gameserv/Makefile.in index 08adf61..957984b 100644 --- a/gameserv/Makefile.in +++ b/gameserv/Makefile.in @@ -27,6 +27,10 @@ TSRCS = aClient.cpp \ c_forest.cpp \ do_admin.cpp \ do_attack.cpp \ + do_bank.cpp \ + do_check.cpp \ + do_equip.cpp \ + do_fight.cpp \ find.cpp \ gameserv.cpp \ hash.cpp \ diff --git a/gameserv/do_bank.cpp b/gameserv/do_bank.cpp new file mode 100644 index 0000000..d48def6 --- /dev/null +++ b/gameserv/do_bank.cpp @@ -0,0 +1,172 @@ +#include "extern.h" +#include "aClient.h" +#include "player.h" +#include "flags.h" + + +void do_bank(char *u) +{ + char *cmd = strtok(NULL, " "); + char *amount = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + + aClient *user; + Player *p; + + if (!cmd || (!amount && stricmp(cmd, "BALANCE") != 0) || (stricmp(cmd, "TRANSFER") == 0 && !nick)) + { + notice(s_GameServ, u, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}"); + notice (s_GameServ, u, "BANK BALANCE"); + return; + } + else if (!(user = find(u))) + { + notice(s_GameServ, u, "Fatal Error. Couldn't find your aClient. Contact a(n) getNick()); +#endif + return; + } + else if (!is_playing(user)) + { + notice(s_GameServ, u, "You must be playing to use the bank!"); + return; + } + else if (is_fighting(user)) + { + notice(s_GameServ, u, "You can't go to the bank during a fight!"); + return; + } + updateTS(user->stats); + if (stricmp(cmd, "BALANCE") == 0) + { + showBankBalance(u); + return; + } + else if (!isAlive(user->stats)) + { + notice(s_GameServ, u, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!"); + return; + } + else if (!isstringnum(amount) && stricmp(amount, "ALL") != 0) + { + notice(s_GameServ, u, "I don't know how to convert alphabet letters into currency, sire!"); + return; + } + if (stringtoint(amount) < 0) + { + notice(s_GameServ, u, "Sorry. This bank is not licensed "\ + "to handle such sums of cash, noble Lord."); + return; + } + p = user->stats; + + if (stricmp(cmd, "DEPOSIT") == 0) + { + if (p->getBank() == 2000000000) + { + notice(s_GameServ, u, "Your bank account is full, sire!"); + return; + } + else if (stricmp(amount, "ALL") == 0) + { + if (2000000000 - p->getBank() < p->getGold()) + { + notice(s_GameServ, u, "You don't have enough room for all of your gold."); + notice(s_GameServ, u, "Depositing %ld gold into your account", (2000000000 - p->getBank())); + p->subtractGold((2000000000 - p->getBank())); + p->setBank(2000000000); + showBankBalance(u); + } + else + { + notice(s_GameServ, u, "Depositing %ld gold into your account!", p->getGold()); + p->addBank(p->getGold()); + p->setGold(0); + showBankBalance(u); + } + } + else if (stringtoint(amount) > p->getGold()) + { + notice(s_GameServ, u, "Sire, you only have %ld gold!", p->getGold()); + showBankBalance(u); + return; + } + else + { + if (2000000000 - p->getBank() < stringtoint(amount)) + { + notice(s_GameServ, u, "You don't have room in your account for that much."); + notice(s_GameServ, u, "Capping off your account with %ld gold!", (2000000000 - p->getBank())); + p->subtractGold((2000000000 - p->getBank())); + p->setBank(2000000000); + showBankBalance(u); + } + else + { + notice(s_GameServ, u, "Depositing %d gold into your account!", stringtoint(amount)); + p->addBank(stringtoint(amount)); + p->subtractGold(stringtoint(amount)); + showBankBalance(u); + } + } + } + else if (stricmp(cmd, "WITHDRAW") == 0) + { + if (p->getGold() == 2000000000) + { + notice(s_GameServ, u, "You cannot carry any more gold, sire!"); + showBankBalance(u); + return; + } + else if (stricmp(amount, "ALL") == 0) + { + if (2000000000 - p->getGold() < p->getBank()) + { + notice(s_GameServ, u, "You don't have enough room to carry all that gold."); + notice(s_GameServ, u, "Withdrawing %ld gold from your account", (2000000000 - p->getGold())); + p->subtractBank((2000000000 - p->getGold())); + p->setGold(2000000000); + showBankBalance(u); + } + else + { + notice(s_GameServ, u, "Withdrawing %ld gold from your account!", p->getBank()); + p->addGold(p->getBank()); + p->setBank(0); + showBankBalance(u); + } + } + else if (stringtoint(amount) > p->getBank()) + { + notice(s_GameServ, u, "Sire, you only have %ld gold in the bank!", p->getBank()); + showBankBalance(u); + return; + } + else + { + if (2000000000 - p->getGold() < stringtoint(amount)) + { + notice(s_GameServ, u, "You don't enough have room to carry that much gold!"); + notice(s_GameServ, u, "You fill your pockets with %ld gold!", + (2000000000 - p->getGold())); + p->subtractBank((2000000000 - p->getGold())); + p->setGold(2000000000); + showBankBalance(u); + } + else + { + notice(s_GameServ, u, "Withdrawing %d gold from your account!", stringtoint(amount)); + p->addGold(stringtoint(amount)); + p->subtractBank(stringtoint(amount)); + showBankBalance(u); + } + } + } +} diff --git a/gameserv/do_check.cpp b/gameserv/do_check.cpp new file mode 100644 index 0000000..02fd9ff --- /dev/null +++ b/gameserv/do_check.cpp @@ -0,0 +1,29 @@ +#include "extern.h" +#include "flags.h" + +void do_check(char *u) +{ + int days, hours, minutes, seconds; + long complete; + complete = (lastrefresh + refreshperiod) - time(NULL); + days = complete / 86400; + hours = (complete % 86400) / 3600; + minutes = (complete % 86400) % 3600 / 60; + seconds = (complete % 86400) % 3600 % 60; + + notice(s_GameServ, u, "Time left to next refresh: %dd %dh %dm %ds", + days, hours, minutes, seconds); + + if (isRolloverForestFights()) + { + complete = (lastrollover + rolloverperiod) - time(NULL); + + days = complete / 86400; + hours = (complete % 86400) / 3600; + minutes = (complete % 86400) % 3600 / 60; + seconds = (complete % 86400) % 3600 % 60; + + notice(s_GameServ, u, "Time left to next rollover: %dd %dh %dm %ds", + days, hours, minutes, seconds); + } +} diff --git a/gameserv/do_equip.cpp b/gameserv/do_equip.cpp new file mode 100644 index 0000000..9e0aaed --- /dev/null +++ b/gameserv/do_equip.cpp @@ -0,0 +1,64 @@ +#include "extern.h" +#include "config.h" +#include "aClient.h" +#include "pouch.h" +#include "item.h" +#include "flags.h" + +void do_equip(char *u) +{ + aClient *user; + pouch *p; + itemContainer *equip; + int id; + + char *item = strtok(NULL, " "); + + if (!item || int(item[0]) < 48 || int(item[0] > 57)) + { + notice(s_GameServ, u, "SYNTAX: EQUIP ####"); + notice(s_GameServ, u, "Type /msg getNick()); +#endif + return; + } + else if (!is_playing(user)) + { + notice(s_GameServ, u, "You must be playing to equip weapons and armor!"); + return; + } + id = stringtoint(item); + if (!is_fighting(user)) + updateTS(user->stats); + p = user->stats->inventory; + + + if (!(equip = p->Find(id))) + { + if (!p->isEmpty()) + { + notice(s_GameServ, u, "You aren't carrying that item!"); + } + showinventory(user->stats, user); + } + else if (equip->getItem()->getType() != ARMOR && equip->getItem()->getType() != WEAPON) + { + notice(s_GameServ, u, "You can't use %s like that. Try /msg getItem()->getName().c_str()); + } + else + { + // Use the item + notice(s_GameServ, u, "You equip %s.", equip->getItem()->getName().c_str()); + equip->use(user->stats); + } +} diff --git a/gameserv/do_fight.cpp b/gameserv/do_fight.cpp new file mode 100644 index 0000000..34bf7cd --- /dev/null +++ b/gameserv/do_fight.cpp @@ -0,0 +1,135 @@ +#include "extern.h" +#include "aClient.h" +#include "player.h" +#include "config.h" +#include "flags.h" + +void do_fight(char *u) +{ + aClient *ni; + Player *battle; + + char *nick = strtok(NULL, " "); + + if (!nick) + { + notice(s_GameServ, u, "SYNTAX: /msg getNick()); +#endif + return; + } + else if (!is_playing(ni)) + { + notice(s_GameServ, u, "You are not playing!"); + return; + } + + updateTS(ni->stats); + + if (ni->stats->getPlayerFights() <= 0) + { + ni->stats->setPlayerFights(0); // just to be safe + notice(s_GameServ, u, "You are out of player fights for the "\ + "day. You have to wait until tomorrow!"); + } + else if (!(battle = findplayer(nick))) + { + notice(s_GameServ, u, "Player %s not found!", nick); + } + else if (!isAlive(ni->stats)) + { + notice(s_GameServ, u, "You are dead. Wait until tomorrow to fight others!"); + } + else if (!is_playing(battle->getClient())) + { + notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick); + } + + /* offline fighting not available yet + else if (!(fight = finduser(nick))) + { + ni->stats->battle = battle; + battle->battle = ni; + setYourTurn(ni->stats); + clearYourTurn(battle->stats); + + notice(s_GameServ, u, "You decide to fight %s while they're "\ + "not in the realm!", + battle->stats->name.c_str()); + display_players(u); + } + */ + else if (stricmp(ni->stats->getName().c_str(), battle->getName().c_str()) == 0) + { + notice(s_GameServ, u, "Are you trying to commit suicide!?"); + } + else if (!isAlive(battle)) + { + notice(s_GameServ, u, "They are dead. Cannot fight dead players!"); + } + else if (player_fight(battle->getClient())) + { + notice(s_GameServ, u, "%s is fighting %s already!", battle->getName().c_str(), battle->getBattle()->stats->getName().c_str()); + } + else if (master_fight(battle->getClient())) + { + notice(s_GameServ, u, "%s is fighting their master!", battle->getName().c_str()); + } + else if (is_fighting(battle->getClient())) + { + notice(s_GameServ, u, "%s is fighting %s already!", battle->getName().c_str(), battle->getMonster()->name.c_str()); + } + else if (!isAdmin(ni) && isFairFights() && (ni->stats->getStrength()/2 - battle->getDefense()) > battle->getHP()) + { + notice(s_GameServ, u, "Fair fighting is enabled, and you're too strong for %s!", battle->getName().c_str()); + } + else if (ni->stats->getLevel() - battle->getLevel() > maxbfightdistance) + { + // You can't fight someone below you by more than X level(s) + // level 12 can fight level (12 - X) but not < (12 - X) + notice(s_GameServ, u, "You may not fight %s. You're too strong!", + battle->getName().c_str()); + } + else if (battle->getLevel() - ni->stats->getLevel() > maxafightdistance) + { + // You can't fight someone above you by more than X level(S) + // level 1 can fight level (1 + X), but not > (1 + X) + notice(s_GameServ, u, "%s, do you really have a death wish? Try the forest you "\ + "weakling!", ni->stats->getName().c_str()); + } + else + { + // Set your battle pointer to the other player + ni->stats->setBattle(battle->getClient()); + + // Set the other player's battle pointer to you + battle->setBattle(ni); + + // The initiator gets the first move (perhaps this should be 50/50) + setYourTurn(ni->stats); + clearYourTurn(battle); + + // Initiate Battle sequence! + ni->stats->subtractPlayerFights(1); + + notice(s_GameServ, u, "You challenge %s to an online duel!", battle->getName().c_str()); + notice(s_GameServ, c_Forest, "%s walks up and hits %s in the face! Let's see who will bite the dust.", + ni->stats->getName().c_str(), battle->getName().c_str()); /* DrLnet - Modified by Kain*/ + + notice(s_GameServ, battle->getClient()->getNick(), "%s has challenged you to an online duel!", ni->stats->getName().c_str()); + notice(s_GameServ, battle->getClient()->getNick(), "%s gets to go first "\ + "because they initiated!", ni->stats->getName().c_str()); + notice(s_GameServ, battle->getClient()->getNick(), "Please wait while %s decides what to do.", ni->stats->getName().c_str()); + display_players(ni); + } +} diff --git a/gameserv/extern.h b/gameserv/extern.h index 4e3cf10..ea137be 100644 --- a/gameserv/extern.h +++ b/gameserv/extern.h @@ -175,6 +175,32 @@ E void saveNews(char *filename, list &news); E void showNews(char *nick, list &news); /** gameserv.cpp **/ +E void do_admin(char *u); +E void do_attack(char *u); +E void do_bank(char *u); +E void do_check(char *u); +E void do_equip(char *u); +E void do_fight(char *u); +E void do_heal(char *u); +E void do_help(char *u); +E void do_identify(char *u); +E void do_inventory(char *u); +E void do_refresh(char *u); +E void do_register(char *u); +E void do_list(char *u); +E void do_logout(char *u); +E void do_master(char *u); +E void do_dragon(char *u); +E void do_play(char *u); +E void do_quitg(char *u); +E void do_reset(char *u); +E void do_run(char *u); +E void do_set(char *u); +E void do_stats(char *u); +E void do_store(char *u); +E void do_tavern(char *u); +E void do_use(char *u); + E item *findItemByID(int id); E int hpbonus[LEVELS - 1]; E int strbonus[LEVELS - 1]; diff --git a/gameserv/gameserv.cpp b/gameserv/gameserv.cpp index e5d9b19..ce27a50 100644 --- a/gameserv/gameserv.cpp +++ b/gameserv/gameserv.cpp @@ -41,12 +41,7 @@ toplist myToplist; // List of the top 10 players bool shuttingdown; -void do_admin(char *u); -void do_attack(char *u); -void do_bank(char *u); -void do_check(char *u); -void do_equip(char *u); -void do_fight(char *u); + void do_heal(char *u); void do_help(char *u); void do_identify(char *u); @@ -342,32 +337,7 @@ void gameserv(char *source, char *buf) cmd--; // Same thing :) } -void do_check(char *u) -{ - int days, hours, minutes, seconds; - long complete; - complete = (lastrefresh + refreshperiod) - time(NULL); - days = complete / 86400; - hours = (complete % 86400) / 3600; - minutes = (complete % 86400) % 3600 / 60; - seconds = (complete % 86400) % 3600 % 60; - - notice(s_GameServ, u, "Time left to next refresh: %dd %dh %dm %ds", - days, hours, minutes, seconds); - - if (isRolloverForestFights()) - { - complete = (lastrollover + rolloverperiod) - time(NULL); - - days = complete / 86400; - hours = (complete % 86400) / 3600; - minutes = (complete % 86400) % 3600 / 60; - seconds = (complete % 86400) % 3600 % 60; - - notice(s_GameServ, u, "Time left to next rollover: %dd %dh %dm %ds", - days, hours, minutes, seconds); - } -} + void do_list(char *u) { @@ -1076,198 +1046,6 @@ void do_stats(char *u) showstats(u, nick); } - - - - -void do_fight(char *u) -{ - aClient *ni; - Player *battle; - - char *nick = strtok(NULL, " "); - - if (!nick) - { - notice(s_GameServ, u, "SYNTAX: /msg getNick()); -#endif - return; - } - else if (!is_playing(ni)) - { - notice(s_GameServ, u, "You are not playing!"); - return; - } - - updateTS(ni->stats); - - if (ni->stats->getPlayerFights() <= 0) - { - ni->stats->setPlayerFights(0); // just to be safe - notice(s_GameServ, u, "You are out of player fights for the "\ - "day. You have to wait until tomorrow!"); - } - else if (!(battle = findplayer(nick))) - { - notice(s_GameServ, u, "Player %s not found!", nick); - } - else if (!isAlive(ni->stats)) - { - notice(s_GameServ, u, "You are dead. Wait until tomorrow to fight others!"); - } - else if (!is_playing(battle->getClient())) - { - notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick); - } - - /* offline fighting not available yet - else if (!(fight = finduser(nick))) - { - ni->stats->battle = battle; - battle->battle = ni; - setYourTurn(ni->stats); - clearYourTurn(battle->stats); - - notice(s_GameServ, u, "You decide to fight %s while they're "\ - "not in the realm!", - battle->stats->name.c_str()); - display_players(u); - } - */ - else if (stricmp(ni->stats->getName().c_str(), battle->getName().c_str()) == 0) - { - notice(s_GameServ, u, "Are you trying to commit suicide!?"); - } - else if (!isAlive(battle)) - { - notice(s_GameServ, u, "They are dead. Cannot fight dead players!"); - } - else if (player_fight(battle->getClient())) - { - notice(s_GameServ, u, "%s is fighting %s already!", battle->getName().c_str(), battle->getBattle()->stats->getName().c_str()); - } - else if (master_fight(battle->getClient())) - { - notice(s_GameServ, u, "%s is fighting their master!", battle->getName().c_str()); - } - else if (is_fighting(battle->getClient())) - { - notice(s_GameServ, u, "%s is fighting %s already!", battle->getName().c_str(), battle->getMonster()->name.c_str()); - } - else if (!isAdmin(ni) && isFairFights() && (ni->stats->getStrength()/2 - battle->getDefense()) > battle->getHP()) - { - notice(s_GameServ, u, "Fair fighting is enabled, and you're too strong for %s!", battle->getName().c_str()); - } - else if (ni->stats->getLevel() - battle->getLevel() > maxbfightdistance) - { - // You can't fight someone below you by more than X level(s) - // level 12 can fight level (12 - X) but not < (12 - X) - notice(s_GameServ, u, "You may not fight %s. You're too strong!", - battle->getName().c_str()); - } - else if (battle->getLevel() - ni->stats->getLevel() > maxafightdistance) - { - // You can't fight someone above you by more than X level(S) - // level 1 can fight level (1 + X), but not > (1 + X) - notice(s_GameServ, u, "%s, do you really have a death wish? Try the forest you "\ - "weakling!", ni->stats->getName().c_str()); - } - else - { - // Set your battle pointer to the other player - ni->stats->setBattle(battle->getClient()); - - // Set the other player's battle pointer to you - battle->setBattle(ni); - - // The initiator gets the first move (perhaps this should be 50/50) - setYourTurn(ni->stats); - clearYourTurn(battle); - - // Initiate Battle sequence! - ni->stats->subtractPlayerFights(1); - - notice(s_GameServ, u, "You challenge %s to an online duel!", battle->getName().c_str()); - notice(s_GameServ, c_Forest, "%s walks up and hits %s in the face! Let's see who will bite the dust.", - ni->stats->getName().c_str(), battle->getName().c_str()); /* DrLnet - Modified by Kain*/ - - notice(s_GameServ, battle->getClient()->getNick(), "%s has challenged you to an online duel!", ni->stats->getName().c_str()); - notice(s_GameServ, battle->getClient()->getNick(), "%s gets to go first "\ - "because they initiated!", ni->stats->getName().c_str()); - notice(s_GameServ, battle->getClient()->getNick(), "Please wait while %s decides what to do.", ni->stats->getName().c_str()); - display_players(ni); - } -} - -void do_equip(char *u) -{ - aClient *user; - pouch *p; - itemContainer *equip; - int id; - - char *item = strtok(NULL, " "); - - if (!item || int(item[0]) < 48 || int(item[0] > 57)) - { - notice(s_GameServ, u, "SYNTAX: EQUIP ####"); - notice(s_GameServ, u, "Type /msg getNick()); -#endif - return; - } - else if (!is_playing(user)) - { - notice(s_GameServ, u, "You must be playing to equip weapons and armor!"); - return; - } - id = stringtoint(item); - if (!is_fighting(user)) - updateTS(user->stats); - p = user->stats->inventory; - - - if (!(equip = p->Find(id))) - { - if (!p->isEmpty()) - { - notice(s_GameServ, u, "You aren't carrying that item!"); - } - showinventory(user->stats, user); - } - else if (equip->getItem()->getType() != ARMOR && equip->getItem()->getType() != WEAPON) - { - notice(s_GameServ, u, "You can't use %s like that. Try /msg getItem()->getName().c_str()); - } - else - { - // Use the item - notice(s_GameServ, u, "You equip %s.", equip->getItem()->getName().c_str()); - equip->use(user->stats); - } -} - void do_use(char *u) { aClient *user; @@ -1854,172 +1632,7 @@ void do_tavern(char *u) return; } -void do_bank(char *u) -{ - char *cmd = strtok(NULL, " "); - char *amount = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - - aClient *user; - Player *p; - - if (!cmd || (!amount && stricmp(cmd, "BALANCE") != 0) || (stricmp(cmd, "TRANSFER") == 0 && !nick)) - { - notice(s_GameServ, u, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}"); - notice (s_GameServ, u, "BANK BALANCE"); - return; - } - else if (!(user = find(u))) - { - notice(s_GameServ, u, "Fatal Error. Couldn't find your aClient. Contact a(n) getNick()); -#endif - return; - } - else if (!is_playing(user)) - { - notice(s_GameServ, u, "You must be playing to use the bank!"); - return; - } - else if (is_fighting(user)) - { - notice(s_GameServ, u, "You can't go to the bank during a fight!"); - return; - } - updateTS(user->stats); - if (stricmp(cmd, "BALANCE") == 0) - { - showBankBalance(u); - return; - } - else if (!isAlive(user->stats)) - { - notice(s_GameServ, u, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!"); - return; - } - else if (!isstringnum(amount) && stricmp(amount, "ALL") != 0) - { - notice(s_GameServ, u, "I don't know how to convert alphabet letters into currency, sire!"); - return; - } - if (stringtoint(amount) < 0) - { - notice(s_GameServ, u, "Sorry. This bank is not licensed "\ - "to handle such sums of cash, noble Lord."); - return; - } - p = user->stats; - - if (stricmp(cmd, "DEPOSIT") == 0) - { - if (p->getBank() == 2000000000) - { - notice(s_GameServ, u, "Your bank account is full, sire!"); - return; - } - else if (stricmp(amount, "ALL") == 0) - { - if (2000000000 - p->getBank() < p->getGold()) - { - notice(s_GameServ, u, "You don't have enough room for all of your gold."); - notice(s_GameServ, u, "Depositing %ld gold into your account", (2000000000 - p->getBank())); - p->subtractGold((2000000000 - p->getBank())); - p->setBank(2000000000); - showBankBalance(u); - } - else - { - notice(s_GameServ, u, "Depositing %ld gold into your account!", p->getGold()); - p->addBank(p->getGold()); - p->setGold(0); - showBankBalance(u); - } - } - else if (stringtoint(amount) > p->getGold()) - { - notice(s_GameServ, u, "Sire, you only have %ld gold!", p->getGold()); - showBankBalance(u); - return; - } - else - { - if (2000000000 - p->getBank() < stringtoint(amount)) - { - notice(s_GameServ, u, "You don't have room in your account for that much."); - notice(s_GameServ, u, "Capping off your account with %ld gold!", (2000000000 - p->getBank())); - p->subtractGold((2000000000 - p->getBank())); - p->setBank(2000000000); - showBankBalance(u); - } - else - { - notice(s_GameServ, u, "Depositing %d gold into your account!", stringtoint(amount)); - p->addBank(stringtoint(amount)); - p->subtractGold(stringtoint(amount)); - showBankBalance(u); - } - } - } - else if (stricmp(cmd, "WITHDRAW") == 0) - { - if (p->getGold() == 2000000000) - { - notice(s_GameServ, u, "You cannot carry any more gold, sire!"); - showBankBalance(u); - return; - } - else if (stricmp(amount, "ALL") == 0) - { - if (2000000000 - p->getGold() < p->getBank()) - { - notice(s_GameServ, u, "You don't have enough room to carry all that gold."); - notice(s_GameServ, u, "Withdrawing %ld gold from your account", (2000000000 - p->getGold())); - p->subtractBank((2000000000 - p->getGold())); - p->setGold(2000000000); - showBankBalance(u); - } - else - { - notice(s_GameServ, u, "Withdrawing %ld gold from your account!", p->getBank()); - p->addGold(p->getBank()); - p->setBank(0); - showBankBalance(u); - } - } - else if (stringtoint(amount) > p->getBank()) - { - notice(s_GameServ, u, "Sire, you only have %ld gold in the bank!", p->getBank()); - showBankBalance(u); - return; - } - else - { - if (2000000000 - p->getGold() < stringtoint(amount)) - { - notice(s_GameServ, u, "You don't enough have room to carry that much gold!"); - notice(s_GameServ, u, "You fill your pockets with %ld gold!", - (2000000000 - p->getGold())); - p->subtractBank((2000000000 - p->getGold())); - p->setGold(2000000000); - showBankBalance(u); - } - else - { - notice(s_GameServ, u, "Withdrawing %d gold from your account!", stringtoint(amount)); - p->addGold(stringtoint(amount)); - p->subtractBank(stringtoint(amount)); - showBankBalance(u); - } - } - } -} + void do_dragon(char *u) {