]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/item.cpp
added items to the tavern.dat, added the filename option to the config file
[irc/gameservirc.git] / gameserv / item.cpp
index a645cf3697e17b45c42802d935517c6f5b83346f..45827accc5d030ed452607c39c02f88c29d2f62e 100644 (file)
@@ -103,6 +103,7 @@ bool weapon::setData(char *datastr)
   try
     {
       char *temp;
+      temp = strtok(datastr, "~"); // Type
 
       mytype = WEAPON;
       // Grab the item's id
@@ -179,34 +180,31 @@ bool armor::setData(char *datastr)
   try
     {
       char *temp;
+      strtok(datastr, "~"); // Type
+
       mytype = ARMOR;
 
       // Grab the item's id
       temp = strtok(NULL, "~");
       id = stringtoint(temp);
-      log("id = %ld", id);
-      
+
       // Grab the item's name
       temp = strtok(NULL, "~");
       myname = temp;
-      log("name = %s", myname.c_str());
       
       // Grab the item's price
       temp = strtok(NULL, "~");
       myprice = stringtoint(temp);
-      log("price = %ld", myprice);
       
       // Grab the item's uses
       temp = strtok(NULL, "~");
       myuses = stringtoint(temp);
-      log("uses = %d", myuses);
       
       // Grab the item's modifiers
       for (int x = 0; x < 4; x++)
        {
          temp = strtok(NULL, "~");
          mymodifiers[x] = stringtoint(temp);
-         log("modifier %d = %ld", x, mymodifiers[x]);
        }
       // If we got here, we were successful
       return true;
@@ -250,14 +248,14 @@ bool potion::use(Player *p)
     return false;
   else
     {
-      p->strength += mymodifiers[0];
-      p->defense += mymodifiers[1];
-      p->maxhp += mymodifiers[2];
-      p->hp += mymodifiers[3];
-      p->forest_fights += mymodifiers[4];
-      p->player_fights += mymodifiers[5];
-      p->gold += mymodifiers[6];
-      p->bank += mymodifiers[7];
+      p->strength += myranges[0].random();
+      p->defense += myranges[1].random();
+      p->maxhp += myranges[2].random();
+      p->hp += myranges[3].random();
+      p->forest_fights += myranges[4].random();
+      p->player_fights += myranges[5].random();
+      p->gold += myranges[6].random();
+      p->bank += myranges[7].random();
     }
 
   if (myuses > 0)
@@ -277,7 +275,9 @@ bool potion::setData(char *datastr)
   try
     {
       char *temp;
-      
+
+      temp = strtok(datastr, "~"); // Type
+
       mytype = ARMOR;
       
       // Grab the item's id
@@ -297,10 +297,12 @@ bool potion::setData(char *datastr)
       myuses = stringtoint(temp);
       
       // Grab the item's modifiers
-      for (int x = 0; x < 5; x++)
+      for (int x = 0; x < 8; x++)
        {
          temp = strtok(NULL, "~");
-         mymodifiers[x] = stringtoint(temp);
+         myranges[x].low = stringtoint(temp);
+         temp = strtok(NULL, "~");
+         myranges[x].high = stringtoint(temp);
        }
     }
   catch(char *str)
@@ -389,3 +391,8 @@ bool itemContainer::operator!=(const itemContainer &right) const
 {
   return (*myitem == *right.myitem);
 }
+
+void itemContainer::setUses(int uses)
+{
+  myuses = uses;
+}