]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
added a parameter to the tavern buy command that allows you to specify how many items...
[irc/gameservirc.git] / gameserv / gameserv.cpp
index 5db8f88caf7aad46a6e185055829d05df01d3a5a..ca0e951458b550cc26d8cbce41d0e8b49335dedb 100644 (file)
@@ -2666,9 +2666,11 @@ void showinventory(Player *from, aClient *to)
          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;
   
@@ -2713,12 +2715,17 @@ void do_tavern(char *u)
     }
   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);
@@ -2732,22 +2739,47 @@ void do_tavern(char *u)
                  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