]> jfr.im git - irc/gameservirc.git/commitdiff
Implemented the definitions for the new items class and added some declarations into...
authorkainazzzo <redacted>
Tue, 21 Jun 2005 16:36:57 +0000 (16:36 +0000)
committerkainazzzo <redacted>
Tue, 21 Jun 2005 16:36:57 +0000 (16:36 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@337 bc333340-6410-0410-a689-9d09f3c113fa

13 files changed:
gameserv/.depend
gameserv/Makefile.in
gameserv/aClient.h
gameserv/config.cpp
gameserv/do_attack.cpp
gameserv/extern.h
gameserv/gameserv.cpp
gameserv/hash.cpp
gameserv/item.cpp
gameserv/item.h
gameserv/level.cpp
gameserv/player.cpp
gameserv/player.h

index 69d097743ba72ef7bb52279380539f3147d4cc32..a9a3c54574b05f48a6ca216001fddec549c074f6 100644 (file)
@@ -1,36 +1,38 @@
 # 1 "/home/gameserv/gameserv//"
-aClient.o: aClient.cpp aClient.h options.h player.h pouch.h extern.h \
-  level.h list.h listnode.h config.h
+aClient.o: aClient.cpp aClient.h options.h item.h player.h pouch.h \
+  extern.h level.h list.h listnode.h config.h
 # 1 "/home/gameserv/gameserv//"
-config.o: config.cpp extern.h player.h aClient.h options.h pouch.h \
-  level.h list.h listnode.h config.h flags.h
+config.o: config.cpp item.h player.h pouch.h extern.h level.h list.h \
+  listnode.h aClient.h options.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-c_forest.o: c_forest.cpp sockhelp.h aClient.h options.h player.h pouch.h \
-  list.h listnode.h extern.h level.h config.h flags.h
+c_forest.o: c_forest.cpp sockhelp.h aClient.h options.h item.h player.h \
+  pouch.h list.h listnode.h extern.h level.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-do_attack.o: do_attack.cpp aClient.h options.h player.h pouch.h extern.h \
-  level.h list.h listnode.h config.h flags.h
+do_attack.o: do_attack.cpp aClient.h options.h item.h player.h pouch.h \
+  extern.h level.h list.h listnode.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-gameserv.o: gameserv.cpp aClient.h options.h player.h pouch.h config.h \
-  extern.h level.h list.h listnode.h flags.h sockhelp.h
+gameserv.o: gameserv.cpp aClient.h options.h item.h player.h pouch.h \
+  config.h extern.h level.h list.h listnode.h flags.h sockhelp.h
 # 1 "/home/gameserv/gameserv//"
-hash.o: hash.cpp extern.h player.h aClient.h options.h pouch.h level.h \
-  list.h listnode.h config.h
+hash.o: hash.cpp item.h player.h pouch.h extern.h level.h list.h \
+  listnode.h aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
-level.o: level.cpp extern.h player.h aClient.h options.h pouch.h level.h \
-  list.h listnode.h config.h
+item.o: item.cpp item.h player.h pouch.h
 # 1 "/home/gameserv/gameserv//"
-log.o: log.cpp extern.h player.h aClient.h options.h pouch.h level.h \
-  list.h listnode.h config.h
+level.o: level.cpp item.h player.h pouch.h extern.h level.h list.h \
+  listnode.h aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
-news.o: news.cpp extern.h player.h aClient.h options.h pouch.h level.h \
-  list.h listnode.h config.h
+log.o: log.cpp extern.h item.h player.h pouch.h level.h list.h listnode.h \
+  aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
-player.o: player.cpp player.h aClient.h options.h pouch.h extern.h \
-  level.h list.h listnode.h config.h flags.h
+news.o: news.cpp extern.h item.h player.h pouch.h level.h list.h \
+  listnode.h aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
-sockhelp.o: sockhelp.cpp sockhelp.h extern.h player.h aClient.h options.h \
-  pouch.h level.h list.h listnode.h config.h
+player.o: player.cpp item.h player.h pouch.h extern.h level.h list.h \
+  listnode.h aClient.h options.h config.h flags.h
+# 1 "/home/gameserv/gameserv//"
+sockhelp.o: sockhelp.cpp sockhelp.h extern.h item.h player.h pouch.h \
+  level.h list.h listnode.h aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
 tcpclient.o: tcpclient.cpp sockhelp.h options.h list.h listnode.h \
-  aClient.h player.h pouch.h extern.h level.h config.h flags.h
+  aClient.h item.h player.h pouch.h extern.h level.h config.h flags.h
index adf50833819d0a7e0d945eb11cf29e577e9aa2de..f308688a1d77e15311d02eade154da15f7fbac94 100644 (file)
@@ -24,6 +24,7 @@ SRCS =        aClient.cpp \
        do_attack.cpp \
        gameserv.cpp \
        hash.cpp \
+       item.cpp \
        level.cpp \
        log.cpp \
        news.cpp \
index 8e6b672c7635d9a0fe426bf548fa5aea0a2035f8..64a462ea222159cf6816e05a11004337102010a3 100644 (file)
@@ -2,9 +2,11 @@
 #define ACLIENT_H
 
 #include <string.h>
+#include "item.h"
 #include "options.h"
 #include "player.h"
 #include <iostream>
+
 using std::ostream;
 
 class Player; // forward declaration
index c9f72304184b1d8f25cd3a39e41043044da28135..46f01343699aaa6d9aa7dd93f7b1268a02cbceb0 100644 (file)
@@ -2,6 +2,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include "item.h"
 #include "extern.h"
 #include "flags.h"
 
index 4f1ce64a2884bcc0885cec1d4810f8404d485641..222ebf01ea19a015977b6da3a976edc59602e302 100644 (file)
@@ -51,26 +51,26 @@ void do_attack(char *u)
   if (!player_fight(ni))
     {
       // Player's Hit
-      hit = ((ni->stats->strength + webonus[ni->stats->weapon]) / 2) +
-       (rand() % ((ni->stats->strength + webonus[ni->stats->weapon]) / 2)) - 
+      hit = ((ni->stats->strength + webonus[ni->stats->wea]) / 2) +
+       (rand() % ((ni->stats->strength + webonus[ni->stats->wea]) / 2)) - 
        fight->defense;
 
       // Opponent's Hit
       mhit = (fight->strength / 2) +
        (rand() % (fight->strength / 2) - (ni->stats->defense +
-                                          arbonus[ni->stats->armor]));
+                                          arbonus[ni->stats->arm]));
     }
   else
     {
       // Opponent's Hit
-      mhit = (((battle->stats->strength + webonus[battle->stats->weapon]) / 2) +
-             (rand() % ((battle->stats->strength + webonus[battle->stats->weapon])) / 2) -
-             (ni->stats->defense + arbonus[ni->stats->armor]));
+      mhit = (((battle->stats->strength + webonus[battle->stats->wea]) / 2) +
+             (rand() % ((battle->stats->strength + webonus[battle->stats->wea])) / 2) -
+             (ni->stats->defense + arbonus[ni->stats->arm]));
 
       // Player's Hit
-      hit = (((ni->stats->strength + webonus[ni->stats->weapon]) / 2) +
-            (rand() % ((ni->stats->strength + webonus[ni->stats->weapon])) / 2) -
-            (battle->stats->defense + arbonus[battle->stats->armor]));
+      hit = (((ni->stats->strength + webonus[ni->stats->wea]) / 2) +
+            (rand() % ((ni->stats->strength + webonus[ni->stats->wea])) / 2) -
+            (battle->stats->defense + arbonus[battle->stats->arm]));
     }
 
   if (!player_fight(ni))
@@ -103,9 +103,9 @@ void do_attack(char *u)
            ni->stats->name.c_str(), ni->stats->name.c_str(),
            ni->stats->fight->name.c_str(), ni->stats->name.c_str());
            dragon.name = "DRAGON-" + ni->stats->name;
-           dragon.weapon = weapons[ni->stats->weapon];
-           dragon.strength = ni->stats->strength + webonus[ni->stats->weapon];
-           dragon.defense = ni->stats->defense + arbonus[ni->stats->armor];
+           dragon.weapon = weapons[ni->stats->wea];
+           dragon.strength = ni->stats->strength + webonus[ni->stats->wea];
+           dragon.defense = ni->stats->defense + arbonus[ni->stats->arm];
            dragon.hp = ni->stats->maxhp;
            dragon.maxhp = ni->stats->maxhp;
            save_dragon();
@@ -222,7 +222,7 @@ void do_attack(char *u)
 
              notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
                     "^B%d^B damage!", ni->stats->name.c_str(),
-                    weapons[ni->stats->weapon], hit);
+                    weapons[ni->stats->wea], hit);
            }
          else
            {
index 00d1d783dfd2275a293129b14f6375728c25852e..0bdc785979b44055e6b43cc39fa703d57698a807 100644 (file)
@@ -9,6 +9,7 @@
 #define WNA 16         // Weapons and armor
 
 #include <stdarg.h>
+#include "item.h"
 #include "player.h"
 #include "level.h"
 #include "list.h"
index 97caf63e2d88076cb352defe63827b0fce71cbef..a4ed61a167f9e872176e4300bb5a184b22a4be30 100644 (file)
@@ -386,16 +386,16 @@ void showstats(const char *u, const char *nick)
         notice(s_GameServ, sender->getNick(), "Hit Points: %d of %d", ni->stats->hp,
                  ni->stats->maxhp);
 
-        sprintf(buf, "Strength: %d", ni->stats->strength + webonus[ni->stats->weapon]);
+        sprintf(buf, "Strength: %d", ni->stats->strength + webonus[ni->stats->wea]);
         space = spaces(strlen(buf), " ");
         notice(s_GameServ, sender->getNick(), "%s%sDefense: %d",
-                 buf, space, ni->stats->defense + arbonus[ni->stats->armor]);
+                 buf, space, ni->stats->defense + arbonus[ni->stats->arm]);
         delete [] space;
 
-        sprintf(buf, "Armor: %s", armors[ni->stats->armor]);
+        sprintf(buf, "Armor: %s", armors[ni->stats->arm]);
         space = spaces(strlen(buf), " ");
         notice(s_GameServ, sender->getNick(), "%s%sWeapon: %s", buf, space,
-                 weapons[ni->stats->weapon]);
+                 weapons[ni->stats->wea]);
         delete [] space;
 
         sprintf(buf, "Forest Fights: %d", ni->stats->forest_fights);
@@ -985,13 +985,13 @@ void do_set(char *u)
            return;
        }
 
-         target->stats->weapon = stringtoint(cmd2);
+         target->stats->wea = stringtoint(cmd2);
 
-         if (target->stats->weapon < 0)
-               target->stats->weapon = 0;
-         else if (target->stats->weapon >= WNA)
-               target->stats->weapon = WNA - 1;
-         notice(s_GameServ, u, "Weapon set to %s", weapons[target->stats->weapon]);
+         if (target->stats->wea < 0)
+               target->stats->wea = 0;
+         else if (target->stats->wea >= WNA)
+               target->stats->wea = WNA - 1;
+         notice(s_GameServ, u, "Weapon set to %s", weapons[target->stats->wea]);
          return;
        }
   }
@@ -1009,14 +1009,14 @@ void do_set(char *u)
            notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] ARMOR <NUMBER>");
            return;
        }
-         target->stats->armor = stringtoint(cmd2);
+         target->stats->arm = stringtoint(cmd2);
 
-         if (target->stats->armor < 0)
-             target->stats->armor = 0;
-         else if (target->stats->armor >= WNA)
-             target->stats->armor = WNA - 1;
+         if (target->stats->arm < 0)
+             target->stats->arm = 0;
+         else if (target->stats->arm >= WNA)
+             target->stats->arm = WNA - 1;
 
-         notice(s_GameServ, u, "Armor set to %s", armors[target->stats->armor]);
+         notice(s_GameServ, u, "Armor set to %s", armors[target->stats->arm]);
          return;
        }
   }
@@ -1317,7 +1317,7 @@ void do_register(char *u)
         if (!is_playing(user))
         {
            ListNode<aClient> *temp;
-           user->stats = new Player(user);
+           user->stats = new Player();
            user->stats->client = user; // Set the backwards pointer
            user->stats->reset(); // set the user up
            user->stats->setPassword(password);
@@ -1990,14 +1990,14 @@ void end_turn(aClient *user)
         // Opponent's Hit
         mhit = (fight->strength / 2) +
                (rand() % (fight->strength / 2) - (user->stats->defense +
-                arbonus[user->stats->armor]));
+                arbonus[user->stats->arm]));
     }
     else
     {
         // Opponent's Hit
-        mhit = (((battle->stats->strength + webonus[battle->stats->weapon]) / 2) +
-               (rand() % ((battle->stats->strength + webonus[battle->stats->weapon])) / 2) -
-               (user->stats->defense + arbonus[user->stats->armor]));
+        mhit = (((battle->stats->strength + webonus[battle->stats->wea]) / 2) +
+               (rand() % ((battle->stats->strength + webonus[battle->stats->wea])) / 2) -
+               (user->stats->defense + arbonus[user->stats->arm]));
     }
     if (!player_fight(user))
     {
@@ -2221,7 +2221,7 @@ int save_gs_dbase()
        clearYourTurn(it);
        outfile << it->name.c_str() << ' ' << it->level << ' ' << it->exp << ' ' << it->gold << ' ' << it->bank << ' '
                << it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' '
-               << it->armor << ' ' << it->weapon << ' '
+               << it->arm << ' ' << it->wea << ' '
                << it->forest_fights << ' ' << it->player_fights <<  ' ' 
                << it->getFlags() << ' ' << it->password << ' ' << it->inventory.Healing()
                << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP()
@@ -2339,8 +2339,8 @@ int load_gs_dbase()
        p->maxhp = stringtoint(strtok(NULL, " "));
        p->strength = stringtoint(strtok(NULL, " "));
        p->defense = stringtoint(strtok(NULL, " "));
-       p->armor = stringtoint(strtok(NULL, " "));
-       p->weapon = stringtoint(strtok(NULL, " "));
+       p->arm = stringtoint(strtok(NULL, " "));
+       p->wea = stringtoint(strtok(NULL, " "));
        p->forest_fights = stringtoint(strtok(NULL, " "));
        p->player_fights = stringtoint(strtok(NULL, " "));
        p->setFlags(stringtoint(strtok(NULL, " ")));
@@ -2517,14 +2517,14 @@ void do_store(char *u)
 
            p = user->stats;
 
-            if (p->weapon != 0)
-                notice(s_GameServ, u, "You have to sell your %s first!", weapons[p->weapon]);
+            if (p->wea != 0)
+                notice(s_GameServ, u, "You have to sell your %s first!", weapons[p->wea]);
             else if (p->gold < prices[wep - 1])
                 notice(s_GameServ, u, "You don't have enough gold for %s!", weapons[wep]);
             else
             {
                 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", weapons[wep]);
-                p->weapon = wep;
+                p->wea = wep;
                 p->gold -= prices[wep - 1];
             }
         }
@@ -2539,14 +2539,14 @@ void do_store(char *u)
 
            p = user->stats;
 
-            if (p->armor != 0)
-                notice(s_GameServ, u, "You have to sell your %s first!", armors[p->armor]);
+            if (p->arm != 0)
+                notice(s_GameServ, u, "You have to sell your %s first!", armors[p->arm]);
             else if (p->gold < prices[wep - 1])
                 notice(s_GameServ, u, "You don't have enough gold for %s!", armors[wep]);
             else
             {
                 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", armors[wep]);
-                p->armor = wep;
+                p->arm = wep;
                 p->gold -= prices[wep - 1];
             }
         }
@@ -2562,7 +2562,7 @@ void do_store(char *u)
 
         if (stricmp(item, "WEAPON") == 0)
         {
-            if (p->weapon == 0)
+            if (p->wea == 0)
             {
                 notice(s_GameServ, u, "You want me to chop off your hands?");
                 return;
@@ -2570,27 +2570,27 @@ void do_store(char *u)
             else if (p->gold == 2000000000)
             {
                 notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
-                p->weapon = 0;
+                p->wea = 0;
             }
-            else if (2000000000 - p->gold < (prices[p->weapon - 1] / 2))
+            else if (2000000000 - p->gold < (prices[p->wea - 1] / 2))
             {
                 notice(s_GameServ, u, "Thank you for your business! You now have as much gold as you can carry.");
                 notice(s_GameServ, u, "However, you have no weapon... can I interest you in the %s?", weapons[WNA - 1]);
                 p->gold = 2000000000;
-                p->weapon = 0;
+                p->wea = 0;
             }
             else
            {
-                notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no weapon!", (prices[p->weapon - 1] / 2));
-                p->gold += (prices[p->weapon - 1] / 2);
-                p->weapon = 0;
+                notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no weapon!", (prices[p->wea - 1] / 2));
+                p->gold += (prices[p->wea - 1] / 2);
+                p->wea = 0;
             }
         }
         else if (stricmp(item, "ARMOR") == 0)
         {
            p = user->stats;
 
-            if (p->armor == 0)
+            if (p->arm == 0)
             {
                 notice(s_GameServ, u, "I don't think you can be any more naked...");
                 return;
@@ -2598,22 +2598,22 @@ void do_store(char *u)
             if (p->gold == 2000000000)
             {
                 notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
-                p->armor = 0;
+                p->arm = 0;
             }
-            else if (2000000000 - p->gold < (prices[p->armor - 1] / 2))
+            else if (2000000000 - p->gold < (prices[p->arm - 1] / 2))
             {
                 notice(s_GameServ, u, "Thank you for your business! You now have as much gold as you can carry.");
                 notice(s_GameServ, u, "However, you have no armor... can I interest you in %s?", armors[WNA - 1]);
                p->gold = 2000000000;
-                p->armor = 0;
+                p->arm = 0;
             }
             else
             {
                 notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no armor!",
-                         (prices[p->armor - 1] / 2));
+                         (prices[p->arm - 1] / 2));
 
-                p->gold += (prices[p->armor - 1] / 2);
-                p->armor = 0;
+                p->gold += (prices[p->arm - 1] / 2);
+                p->arm = 0;
             }
        }
         else
@@ -3033,7 +3033,7 @@ void do_dragon(char *u)
        "your %s, and venture into the hot, dark cave. "\
        "You are surprised at the angle of descent as you climb "\
        "lower and lower, deeper into the dragon's den.", 
-       armors[p->armor], weapons[p->weapon]);
+       armors[p->arm], weapons[p->wea]);
     notice(s_GameServ, u, "You come to the end of the cave to find "\
        "a tooth. It is a large tooth... bigger than your torso."\
        " Suddenly the darkness lifts from the gleam of an eye "\
index 3d0dffc620c912027057fe99b50eb78a8e6db891..9c6b12204c29dbb46ac7c8a7558774268fb7e2b5 100644 (file)
@@ -1,3 +1,4 @@
+#include "item.h"
 #include "extern.h"
 #include <ctype.h>
 
index 455ca2b827a38b6ae33579912e662ed5ab149299..d98d744fb3687529dc78de8f67dd577752883ae5 100644 (file)
@@ -1,6 +1,4 @@
 #include "item.h"
-#include "extern.h"
-#include <string.h>
 
 item::item(char *name, int p, int uses, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8)
 {
@@ -36,6 +34,26 @@ item::~item()
 {
 }
 
+bool item::operator<(const item &right) const
+{
+  return myname < right.myname;
+}
+
+bool item::operator>(const item &right) const
+{
+  return myname > right.myname;
+}
+
+bool item::operator==(const item &right) const
+{
+  return myname == right.myname;
+}
+
+bool item::operator!=(const item &right) const
+{
+  return myname != right.myname;
+}
+
 bool weapon::use(Player *p)
 {
   //  weapon(char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0)
index a0a75af3c501bea28c255df69fe4cac429cdeebc..ea2edc370b687930572036258b4764f0d65860bb 100644 (file)
@@ -1,27 +1,33 @@
 #ifndef ITEM_H
 #define ITEM_H
 
-#include "player.h"
+
 #include <string.h>
+#include "player.h"
 
 class item
 {
  public:
-  item(char *name, int p=0, int uses = 1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
-  item(string name, int p=0, int uses = 1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
+  item(char *name=NULL, int p=0, int uses=1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
+  item(string name=NULL, int p=0, int uses=1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
   virtual ~item();
   
   int uses() { return myuses; };
   long int price() { return myprice; };
   
   virtual bool use(Player *p) = 0;
-  virtual void undo(Player *p) = 0;
+  virtual void undo() = 0;
+
+  bool operator<(const item &right) const;
+  bool operator>(const item &right) const;
+  bool operator==(const item &right) const;
+  bool operator!=(const item &right) const;
   
  protected:
-  string myname;
-  long int myprice;
-  int mymodifiers[8];
-  int myuses;
+  string myname;         // Name to use in game & sorting
+  long int myprice;      // How much does this item cost to buy (half to sell)
+  int mymodifiers[8];    // Up to 8 different modifiers handled in the sub-classes
+  int myuses;            // How many times you can use this item
 };
 
 class weapon : public item
@@ -33,7 +39,16 @@ class weapon : public item
   virtual bool use(Player *p);
   virtual void undo(Player *p);
 };
-typedef weapon armor; // Weapons and armor are logically the same if they can both modify strength, defense, and maxhp
+
+class armor : public item
+{
+  armor(char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+  armor(string name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+  virtual ~armor();
+
+  virtual bool use(Player *p);
+  virtual void undo(Player *p);
+};
 
 class potion : public item
 {
index d17ae3ae214d0c578ff1c4980366aa70633d7fab..7aa9472bdb5cfd7f559514d25b5f490afdc330f6 100644 (file)
@@ -1,3 +1,4 @@
+#include "item.h"
 #include "extern.h"
 #include <fstream>
 #include "level.h"
index 372ebe1fbb726ca903065c27fbc6cde467ba5d25..3d3887b52f8e13704634f985e8db41c3e86dfe68 100644 (file)
@@ -1,3 +1,4 @@
+#include "item.h"
 #include "player.h"
 #include "pouch.h"
 #include "extern.h"
@@ -16,8 +17,8 @@ void Player::reset()
     maxhp = 10;
     strength = 0;
     defense = 0;
-    armor = 1;
-    weapon = 1;
+    arm = 1;
+    wea = 1;
     level = 1;
     forest_fights = forestfights;
     player_fights = 3;
@@ -40,18 +41,6 @@ Player::Player()
     #endif
 }
 
-Player::Player(aClient *user)
-{
-
-    if (user)
-    {
-       setData(user->stats);
-       name = user->getNick();
-    }
-    else
-       setData(NULL);
-}
-
 Player::Player(char *n)
 {
     reset(); // Set defaults
@@ -115,8 +104,8 @@ void Player::setData(Player *right)
         maxhp = right->maxhp;
         strength = right->strength;
         defense = right->defense;
-        armor = right->armor;
-        weapon = right->weapon;
+        arm = right->arm;
+        wea = right->wea;
         level = right->level;
         forest_fights = right->forest_fights;
         player_fights = right->player_fights;
index 48fb67e478a99581e0b321d39ff88c4a48876af7..096bb45c1112ec2c9c3fca4ee3583c6bdb93cdf5 100644 (file)
@@ -2,19 +2,23 @@
 #define PLAYER_H
 
 #include <string>
-#include "aClient.h"
+
 #include "pouch.h"
+#include "item.h"
 
 using namespace std;
 
 typedef struct monster_ Monster;
 
 class aClient; // forward declaration
+class item;    // forward declaration
+class weapon;  // forward declaration
+class armor;   // forward declaration
+class potion;  // forward declaration
 
 class Player {
 public:
     Player();
-    Player(aClient *);
     Player(char *);
     Player(string);
     ~Player();
@@ -28,6 +32,14 @@ public:
     long int addFlag(long int);     // Adds a flag to the client's flags
     long int remFlag(long int);     // Removes a flag from the client's current flags
 
+    int wea;
+    int arm; // delete soon
+
+    weapon *getWeapon() { return w; };
+    armor *getArmor() { return a; };
+
+    void setWeapon (weapon &);  // Set a player's weapon to some item
+    void setArmor (armor &);    // Set a player's weapon to some item
 
     string name;               // Player's Name
     int level;                 // Player's level (1-12)
@@ -38,8 +50,6 @@ public:
     int maxhp;                  // Maximum Hit Points
     int strength;               // Player's Strength
     int defense;                // Player's defensive strength
-    int armor;                  // Number for the player's armor
-    int weapon;                 // Number for the player's weapon
     int forest_fights;          // Amount of forest fights left today
     int player_fights;          // Amount of player<->player fights for today
     string password;           // Player's encrypted password
@@ -54,6 +64,8 @@ public:
 
 private:
     long int flags;            // Player's current flags
+    weapon *w;                  // Player's weapon
+    armor *a;                   // Player's armor
 };
 
 struct monster_ {