notice(s_GameServ, nick, "%ld.) %s (%ld)", (*item_iter2).getItem()->getID(), (*item_iter2).getItem()->getName().c_str(), count);
}
}
+
void do_tavern(char *u)
{
char *cmd = strtok(NULL, " ");
+
aClient *user;
Player *p;
}
else if (stricmp(cmd, "BUY") == 0)
{
+ int amt;
char *chid = strtok(NULL, " ");
+ char *amount = strtok(NULL, " ");
+
+ amt = stringtoint(amount);
if (!chid)
{
- notice(s_GameServ, u, "SYNTAX: TAVERN BUY #");
+ notice(s_GameServ, u, "SYNTAX: TAVERN BUY # [#]");
notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 6001");
+ notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 6001 10");
return;
}
long id = stringtoint(chid);
notice(s_GameServ, u, "To buy an item, type /msg %S TAVERN BUY #");
return;
}
- else if (user->stats->getGold() < tempItem->getItem()->price())
+ else if (!amount && user->stats->getGold() < tempItem->getItem()->price())
{
notice(s_GameServ, u, "You don't have enough gold!");
notice(s_GameServ, u, "Here is a list of what we have to offer:");
showTavern(user);
notice(s_GameServ, u, "To buy an item, type /msg %S TAVERN BUY #");
}
- else
+ else if (user->stats->getGold() < amt * tempItem->getItem()->price())
+ {
+ notice(s_GameServ, u, "You don't have enough gold!");
+ notice(s_GameServ, u, "Here is a list of what we have to offer:");
+ showTavern(user);
+ notice(s_GameServ, u, "To buy an item, type /msg %S TAVERN BUY # [#]");
+ }
+ else
{
- if (user->stats->inventory->addItem(tempItem->getItem()) == NULL)
+ if (amount)
{
- notice(s_GameServ, u, "You can't carry any more!");
- return;
+ int amt = stringtoint(amount);
+ if (amt < 0 || amount[0] == '-')
+ {
+ notice(s_GameServ, u, "You trying to steal from me?");
+ }
+ else if (user->stats->inventory->addItem(tempItem->getItem(), amt) == NULL)
+ {
+ notice(s_GameServ, u, "You can't carry that many!");
+ return;
+ }
+ notice(s_GameServ, u, "%d %s's coming right up!", amt, tempItem->getItem()->getName().c_str());
+ user->stats->subtractGold(tempItem->getItem()->price() * amt);
+ }
+ else
+ {
+ if (user->stats->inventory->addItem(tempItem->getItem()) == NULL)
+ {
+ notice(s_GameServ, u, "You can't carry any more!");
+ return;
+ }
+ notice(s_GameServ, u, "One %s coming right up!", tempItem->getItem()->getName().c_str());
+ user->stats->subtractGold(tempItem->getItem()->price());
}
- notice(s_GameServ, u, "One %s coming right up!", tempItem->getItem()->getName().c_str());
- user->stats->subtractGold(tempItem->getItem()->price());
}
}
else