]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/item.cpp
implemented equipping weapons and armor and saving what is equipped
[irc/gameservirc.git] / gameserv / item.cpp
index 69caa8cbdece388230449a2ad25318d12cac106d..16b02255ec4988d3cda237303b4e9c140b9c6070 100644 (file)
@@ -145,9 +145,14 @@ bool weapon::use(Player *p)
     return false;
   else
     {
+      if (p->getWeapon())
+       {
+         p->getWeapon()->undo(p);
+       }
       p->strength += mymodifiers[0];
       p->defense += mymodifiers[1];
       p->maxhp += mymodifiers[2];
+      p->setWeapon(*this);
     }
 
   return true;
@@ -220,9 +225,14 @@ bool armor::use(Player *p)
     return false;
   else
     {
+      if (p->getArmor())
+       {
+         p->getArmor()->undo(p);
+       }
       p->strength += mymodifiers[0];
       p->defense += mymodifiers[1];
       p->maxhp += mymodifiers[2];
+      p->setArmor(*this);
     }
 
   return true;