]> jfr.im git - irc/gameservirc.git/commitdiff
Shrunk the dependencies immensely with forward declarations in all H files instead...
authorkainazzzo <redacted>
Thu, 23 Jun 2005 17:13:10 +0000 (17:13 +0000)
committerkainazzzo <redacted>
Thu, 23 Jun 2005 17:13:10 +0000 (17:13 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@339 bc333340-6410-0410-a689-9d09f3c113fa

14 files changed:
gameserv/.depend
gameserv/Makefile.in
gameserv/aClient.h
gameserv/c_forest.cpp
gameserv/config.cpp
gameserv/extern.h
gameserv/gameserv.cpp
gameserv/hash.cpp
gameserv/item.cpp
gameserv/item.h
gameserv/list.h
gameserv/player.cpp
gameserv/player.h
gameserv/pouch.h

index a9a3c54574b05f48a6ca216001fddec549c074f6..631569065deba87fdf96d5b36c5265dacede04a3 100644 (file)
@@ -1,38 +1,40 @@
 # 1 "/home/gameserv/gameserv//"
-aClient.o: aClient.cpp aClient.h options.h item.h player.h pouch.h \
-  extern.h level.h list.h listnode.h config.h
+aClient.o: aClient.cpp aClient.h options.h player.h extern.h level.h \
+  list.h listnode.h config.h
 # 1 "/home/gameserv/gameserv//"
-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 item.h player.h \
-  pouch.h list.h listnode.h extern.h level.h config.h flags.h
+config.o: config.cpp extern.h player.h level.h list.h listnode.h \
+  aClient.h options.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-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
+c_forest.o: c_forest.cpp sockhelp.h aClient.h options.h player.h list.h \
+  listnode.h extern.h level.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-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
+do_attack.o: do_attack.cpp aClient.h options.h player.h extern.h level.h \
+  list.h listnode.h config.h flags.h
 # 1 "/home/gameserv/gameserv//"
-hash.o: hash.cpp item.h player.h pouch.h extern.h level.h list.h \
-  listnode.h aClient.h options.h config.h
+gameserv.o: gameserv.cpp aClient.h options.h player.h config.h extern.h \
+  level.h list.h listnode.h pouch.h flags.h sockhelp.h item.h
 # 1 "/home/gameserv/gameserv//"
-item.o: item.cpp item.h player.h pouch.h
+hash.o: hash.cpp extern.h player.h level.h list.h listnode.h aClient.h \
+  options.h config.h
 # 1 "/home/gameserv/gameserv//"
-level.o: level.cpp item.h player.h pouch.h extern.h level.h list.h \
-  listnode.h aClient.h options.h config.h
+item.o: item.cpp item.h player.h
 # 1 "/home/gameserv/gameserv//"
-log.o: log.cpp extern.h item.h player.h pouch.h level.h list.h listnode.h \
+level.o: level.cpp item.h extern.h player.h level.h list.h listnode.h \
   aClient.h options.h config.h
 # 1 "/home/gameserv/gameserv//"
-news.o: news.cpp extern.h item.h player.h pouch.h level.h list.h \
-  listnode.h aClient.h options.h config.h
+log.o: log.cpp extern.h player.h level.h list.h listnode.h aClient.h \
+  options.h config.h
+# 1 "/home/gameserv/gameserv//"
+pouch.o: pouch.cpp pouch.h item.h
+# 1 "/home/gameserv/gameserv//"
+news.o: news.cpp extern.h player.h level.h list.h listnode.h aClient.h \
+  options.h config.h
 # 1 "/home/gameserv/gameserv//"
 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
+sockhelp.o: sockhelp.cpp sockhelp.h extern.h player.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 item.h player.h pouch.h extern.h level.h config.h flags.h
+  aClient.h player.h extern.h level.h config.h flags.h
index f308688a1d77e15311d02eade154da15f7fbac94..cd4ef201756fb17bf27e5da2f964cd5c0e84b8d3 100644 (file)
@@ -28,6 +28,7 @@ SRCS =        aClient.cpp \
        level.cpp \
        log.cpp \
        news.cpp \
+       pouch.cpp \
        player.cpp \
        sockhelp.cpp \
        tcpclient.cpp
index 64a462ea222159cf6816e05a11004337102010a3..b711021410fbd9c5e548df096a2393cab8328495 100644 (file)
@@ -2,7 +2,6 @@
 #define ACLIENT_H
 
 #include <string.h>
-#include "item.h"
 #include "options.h"
 #include "player.h"
 #include <iostream>
index 86ddcb46df07a77040b36cd205f9b07d6597b90c..762d1e7710fce19fe736b743f3a022e85689b373 100644 (file)
@@ -81,6 +81,7 @@ void do_forest(char *u)
                p->master = NULL; // Just to make sure
                display_monster(u);
            }
+           /*
            else if (eventnum < 12 && eventnum >= 10) // 2% for finding potions
            {
                notice(s_GameServ, u, "Fortune smiles upon thee!");
@@ -110,6 +111,7 @@ void do_forest(char *u)
                        break;
                }
            }
+           */
            else if (eventnum < 10 && eventnum >= 5) // 5% for the fountain
            {
                if (p->hp < p->maxhp)
index 46f01343699aaa6d9aa7dd93f7b1268a02cbceb0..c9f72304184b1d8f25cd3a39e41043044da28135 100644 (file)
@@ -2,7 +2,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "item.h"
 #include "extern.h"
 #include "flags.h"
 
index 0bdc785979b44055e6b43cc39fa703d57698a807..00d1d783dfd2275a293129b14f6375728c25852e 100644 (file)
@@ -9,7 +9,6 @@
 #define WNA 16         // Weapons and armor
 
 #include <stdarg.h>
-#include "item.h"
 #include "player.h"
 #include "level.h"
 #include "list.h"
index a4ed61a167f9e872176e4300bb5a184b22a4be30..18bd0fe246f5cdb58199af991df577d179ba77b5 100644 (file)
@@ -1,18 +1,21 @@
 #include "aClient.h"
 #include "config.h"
 #include "extern.h"
+#include "player.h"
+#include "pouch.h"
 #include "flags.h"
 #include "list.h"
 #include "level.h"
 #include "sockhelp.h"
+#include "item.h"
 
 #include <cctype>
 #include <fstream>
 #include <stdlib.h>
+#include <list>
+#include <iterator>
 
-using std::ifstream;
-using std::ofstream;
-using std::ios;
+using namespace std;
 
 #if defined(HAVE_CRYPT_H)
 
@@ -402,20 +405,7 @@ void showstats(const char *u, const char *nick)
         space = spaces(strlen(buf), " ");
         notice(s_GameServ, sender->getNick(), "%s%sPlayer Fights: %d", buf, space, ni->stats->player_fights);
         delete [] space;
-       Pouch *inv = &ni->stats->inventory;
-
-       notice(s_GameServ, u, "Potions");
-       sprintf(buf, "Healing: %d", inv->Healing());
-       space = spaces(strlen(buf), " ");
-       notice(s_GameServ, sender->getNick(), "%s%sHP: %d", buf, 
-               space, inv->HP());
-       delete [] space;
-
-       sprintf(buf, "Strength: %d", inv->Strength());
-       space = spaces(strlen(buf), " ");
-       notice(s_GameServ, sender->getNick(), "%s%sDefense: %d", buf, 
-               space, inv->Defense());
-       delete [] space;
+       showinventory(ni, ni);
     }
     else
     {
@@ -678,7 +668,7 @@ void do_set(char *u)
     }
   else if (!name)
     {
-      notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|WEAPON|ARMOR|HP POTIONS|STRENGTH POTIONS|DEFENSE POTIONS|HEALING POTIONS|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+      notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
       return;
     }
   else if (!(target = findplayer(name)))
@@ -970,137 +960,6 @@ void do_set(char *u)
          return;
        }
   }
-  else if (stricmp(cmd, "WEAPON") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] WEAPON <NUMBER>");
-           return;
-       }
-
-         target->stats->wea = stringtoint(cmd2);
-
-         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;
-       }
-  }
-  else if (stricmp(cmd, "ARMOR") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] ARMOR <NUMBER>");
-           return;
-       }
-         target->stats->arm = stringtoint(cmd2);
-
-         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->arm]);
-         return;
-       }
-  }
-  else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-         cmd2 = strtok(NULL, " ");
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HP POTIONS <NUMBER>");
-           return;
-       }
-         target->stats->inventory.setHP(abs(stringtoint(cmd2)));
-
-         notice(s_GameServ, u, "HP Potions set to %d", target->stats->inventory.HP());
-         return;
-       }
-  }
-  else if (stricmp(cmd, "HEALING") == 0 && stricmp(cmd2, "POTIONS") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-         cmd2 = strtok(NULL, " ");
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HEALING POTIONS <NUMBER>");
-           return;
-       }
-         target->stats->inventory.setHealing(abs(stringtoint(cmd2)));
-         notice(s_GameServ, u, "Healing Potions set to %d", target->stats->inventory.Healing());
-         return;
-       }
-  }
-  else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-         cmd2 = strtok(NULL, " ");
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] STRENGTH POTIONS <NUMBER>");
-           return;
-       }
-         target->stats->inventory.setStrength(abs(stringtoint(cmd2)));
-         notice(s_GameServ, u, "Strength Potions set to %d", target->stats->inventory.Strength());
-         return;
-       }
-  }
-  else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") == 0)
-  {
-    if (!isAdmin(user))
-       {
-         notice(s_GameServ, u, "Admins Only!");
-         return;         
-       }
-    else
-       {
-         cmd2 = strtok(NULL, " ");
-       if (!cmd2)
-       {
-           notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] DEFENSE POTIONS <NUMBER>");
-           return;
-       }
-         target->stats->inventory.setDefense(abs(stringtoint(cmd2)));
-         notice(s_GameServ, u, "Defense Potions set to %d", target->stats->inventory.Defense());
-         return;
-       }
-  }
   else if (stricmp(cmd, "ALIVE") == 0)
   {
      if (!isAdmin(user))
@@ -1163,7 +1022,7 @@ void do_set(char *u)
   else
   {
      notice(s_GameServ, u, "Unknown command: SET %s", cmd);
-     notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|WEAPON|ARMOR|HP POTIONS|STRENGTH POTIONS|DEFENSE POTIONS|HEALING POTIONS|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+     notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
      return;
   }
 }
@@ -1784,6 +1643,7 @@ void do_fight(char *u)
 
 void do_use(char *u)
 {
+  /*
     aClient *user;
     Pouch *p;
 
@@ -1912,6 +1772,8 @@ void do_use(char *u)
     }
 
     end_turn(user); // If they're fighting, end their turn
+  */
+  return;
 }
 void do_run(char *u)
 {
@@ -2223,9 +2085,10 @@ int save_gs_dbase()
                << it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' '
                << it->arm << ' ' << it->wea << ' '
                << it->forest_fights << ' ' << it->player_fights <<  ' ' 
-               << it->getFlags() << ' ' << it->password << ' ' << it->inventory.Healing()
+               << it->getFlags() << ' ' << it->password << ' ' 
+/* fixing this << it->inventory.Healing()
                << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP()
-               << ' ' << it->lastlogin << endl;
+               << ' ' */ << it->lastlogin << endl;
        ptr = ptr->Next();
     }
    }
@@ -2325,12 +2188,12 @@ int load_gs_dbase()
     }
 
     while (infile.getline(buf, 1024, '\n'))
-    {
+      {
        temp = new aClient;
        tempname = strtok(buf, " ");
        temp->stats = new Player(tempname);
        p = temp->stats;
-
+       
        p->level = stringtoint(strtok(NULL, " "));
        p->exp = stringtoint(strtok(NULL, " "));
        p->gold = stringtoint(strtok(NULL, " "));
@@ -2345,290 +2208,292 @@ int load_gs_dbase()
        p->player_fights = stringtoint(strtok(NULL, " "));
        p->setFlags(stringtoint(strtok(NULL, " ")));
 
+       
+       
        password = strtok(NULL, " ");
        p->password = password;
        temp->setNick("Not Playing");
-       #ifdef P10
+#ifdef P10
        temp->setRealNick("Not Playing");
-       #endif
-
-       p->inventory.reset(); // Set inventory to all 0s
+#endif
+       
+       p->inventory->clear(); // Set inventory to all 0s
        // Old player databases didn't have these three extra values
        // If they come up null, leave them to 0 as the default.
        // On the next gameserv database save, it will save the values.
        tempname = strtok(NULL, " ");
-       if (tempname)
-           p->inventory.setHealing(stringtoint(tempname));
-
+       //      if (tempname)
+       //  p->inventory.setHealing(stringtoint(tempname));
+       
        tempname = strtok(NULL, " ");
-       if (tempname)
-           p->inventory.setStrength(stringtoint(tempname));
-
+       //if (tempname)
+       //   p->inventory.setStrength(stringtoint(tempname));
+       
        tempname = strtok(NULL, " ");
-       if (tempname)
-           p->inventory.setDefense(stringtoint(tempname));
-
+       //if (tempname)
+       //    p->inventory.setDefense(stringtoint(tempname));
+       
        tempname = strtok(NULL, " ");
-       if (tempname)
-           p->inventory.setHP(stringtoint(tempname));
-
+       //if (tempname)
+       //  p->inventory.setHP(stringtoint(tempname));
+       
         tempname = strtok(NULL, " ");
        if (tempname)
-           p->lastlogin = stringtoint(tempname);
+         p->lastlogin = stringtoint(tempname);
        else
-           p->lastlogin = time(NULL);
-
+         p->lastlogin = time(NULL);
+       
        unsigned long hv = iHASH((unsigned char *) temp->stats->name.c_str());
-
+       
        temp->stats->client = NULL;
        players[hv].insertAtBack(temp);
        delete temp;
-    }
-delete [] buf;
-infile.close();
-return 1;
+      }
+    delete [] buf;
+    infile.close();
+    return 1;
 }
 
 bool passcmp(const char *encrypted, char *plaintext)
 {
-    char salt[3];
-    char *plaintext2, *plainToencrypt;
-    bool same = false;
-
-    plaintext2 = new char[strlen(encrypted) + strlen(plaintext)]; // Extra
-    strcpy(plaintext2, plaintext);
-   
-    salt[0] = encrypted[0];
-    salt[1] = encrypted[1];
-    salt[3] = '\0';
-
-    plainToencrypt = crypt(plaintext2, salt);
-
-    same = (strcmp((const char *)encrypted, plainToencrypt) == 0 ? true : false);
-
-    delete []plaintext2;
-
-    return same;
+  char salt[3];
+  char *plaintext2, *plainToencrypt;
+  bool same = false;
+  
+  plaintext2 = new char[strlen(encrypted) + strlen(plaintext)]; // Extra
+  strcpy(plaintext2, plaintext);
+  
+  salt[0] = encrypted[0];
+  salt[1] = encrypted[1];
+  salt[3] = '\0';
+  
+  plainToencrypt = crypt(plaintext2, salt);
+  
+  same = (strcmp((const char *)encrypted, plainToencrypt) == 0 ? true : false);
+  
+  delete []plaintext2;
+  
+  return same;
 }
 
 bool check_password(char *name, char *plaintext)
 {
-    aClient *client;
-
-    if (!(client = findplayer(name)))
-       return false;
-    else
+  aClient *client;
+  
+  if (!(client = findplayer(name)))
+    return false;
+  else
     {
-       return passcmp(client->stats->password.c_str(), plaintext);
+      return passcmp(client->stats->password.c_str(), plaintext);
     }
 }
 
 void do_store(char *u)
 {
-    char *cmd = strtok(NULL, " ");
-    char *item = strtok(NULL, " ");
-    char *num = strtok(NULL, " ");
-    char *space;
-    int wep;
-    aClient *user;
-    Player *p;
-
-    if (!cmd || !item)
+  char *cmd = strtok(NULL, " ");
+  char *item = strtok(NULL, " ");
+  char *num = strtok(NULL, " ");
+  char *space;
+  int wep;
+  aClient *user;
+  Player *p;
+  
+  if (!cmd || !item)
     {
-       notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
-       notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
-       notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
-       return;
+      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
+      notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
+      notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
+      return;
     }
-    else if (!(user = find(u)))
+  else if (!(user = find(u)))
     {
-       log("Fatal Error: could not find %s in client list", u);
-       return;
+      log("Fatal Error: could not find %s in client list", u);
+      return;
     }
-    else if (isIgnore(user))
+  else if (isIgnore(user))
     {
-       #ifdef DEBUGMODE
-           log("Ignoring %s.", user->getNick());
-       #endif
-       return;
+#ifdef DEBUGMODE
+      log("Ignoring %s.", user->getNick());
+#endif
+      return;
     }
-    else if (!is_playing(user))
+  else if (!is_playing(user))
     {
-       notice(s_GameServ, u, "You must be playing to use the store!");
-       return;
+      notice(s_GameServ, u, "You must be playing to use the store!");
+      return;
     }
-    else if (!isAlive(user->stats))
+  else if (!isAlive(user->stats))
     {
-       notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
-       return;
+      notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
+      return;
     }
-    updateTS(user->stats);
-
-    if (stricmp(cmd, "LIST") == 0)
+  updateTS(user->stats);
+  
+  if (stricmp(cmd, "LIST") == 0)
     {
-       if (stricmp(item, "WEAPONS") == 0)
+      if (stricmp(item, "WEAPONS") == 0)
        {
-            notice(s_GameServ, u, "Welcome to Kain's Armory");
-            notice(s_GameServ, u, "Here are the weapons we have available for the killing, sire:");
-           for (int x = 1; x < WNA; x++)
+         notice(s_GameServ, u, "Welcome to Kain's Armory");
+         notice(s_GameServ, u, "Here are the weapons we have available for the killing, sire:");
+         for (int x = 1; x < WNA; x++)
             {
-                space = spaces(strlen(weapons[x]), ".");
-                notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, weapons[x], space, prices[x - 1]);
-                free(space);
+             space = spaces(strlen(weapons[x]), ".");
+             notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, weapons[x], space, prices[x - 1]);
+             free(space);
             }
-           notice(s_GameServ, u, "To purchase a weapon, type /msg %S STORE BUY \ 2NUM\ 2.");
-            notice(s_GameServ, u, "Where num. is the weapon number from the menu above.");
-
+         notice(s_GameServ, u, "To purchase a weapon, type /msg %S STORE BUY \ 2NUM\ 2.");
+         notice(s_GameServ, u, "Where num. is the weapon number from the menu above.");
+         
        }
-       else if (stricmp(item, "ARMOR") == 0)
+      else if (stricmp(item, "ARMOR") == 0)
        {
-           notice(s_GameServ, u, "Welcome to Kain's Armory");
-           notice(s_GameServ, u, "I hope you enjoy the fine armor we have available for your protection:");
-           for (int x = 1; x < WNA; x++)
+         notice(s_GameServ, u, "Welcome to Kain's Armory");
+         notice(s_GameServ, u, "I hope you enjoy the fine armor we have available for your protection:");
+         for (int x = 1; x < WNA; x++)
             {
-               space = spaces(strlen(armors[x]), ".");
-               notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, armors[x], space, prices[x - 1]);
-               free(space);
+             space = spaces(strlen(armors[x]), ".");
+             notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, armors[x], space, prices[x - 1]);
+             free(space);
            }
-            notice(s_GameServ, u, "To purchase armor, type /msg %S store buy armor num.");
-            notice(s_GameServ, u, "Where num. is the armor number from the menu above.");
-
-
+         notice(s_GameServ, u, "To purchase armor, type /msg %S store buy armor num.");
+         notice(s_GameServ, u, "Where num. is the armor number from the menu above.");
+         
+         
        }
     } else if (stricmp(cmd, "BUY") == 0) {
-       if (!num)
+      if (!num)
        {
-           notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
-           return;
+         notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
+         return;
        }
-       else if (!isstringnum(num))
+      else if (!isstringnum(num))
        {
-           notice(s_GameServ, u, "You must specify a number between 1 and %d. Not %s!", WNA - 1, num);
-           return;
+         notice(s_GameServ, u, "You must specify a number between 1 and %d. Not %s!", WNA - 1, num);
+         return;
        }
-       if (stricmp(item, "WEAPON") == 0)
+      if (stricmp(item, "WEAPON") == 0)
         {
-            wep = stringtoint(num);
-            if (wep >= WNA || wep < 1)
+         wep = stringtoint(num);
+         if (wep >= WNA || wep < 1)
             {
-               notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
-                return;
+             notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
+             return;
             }
-
-           p = user->stats;
-
-            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
+         
+         p = user->stats;
+         
+         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->wea = wep;
-                p->gold -= prices[wep - 1];
+             notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", weapons[wep]);
+             p->wea = wep;
+             p->gold -= prices[wep - 1];
             }
         }
-       else if (stricmp(item, "ARMOR") == 0)
+      else if (stricmp(item, "ARMOR") == 0)
         {
-            wep = stringtoint(num);
-            if (wep >= WNA || wep < 1)
+         wep = stringtoint(num);
+         if (wep >= WNA || wep < 1)
             {
-               notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
-                return;
+             notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
+             return;
             }
-
-           p = user->stats;
-
-            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
+         
+         p = user->stats;
+         
+         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->arm = wep;
-                p->gold -= prices[wep - 1];
+             notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", armors[wep]);
+             p->arm = wep;
+             p->gold -= prices[wep - 1];
             }
         }
-       else
+      else
        {
-           notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
-           return;
+         notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
+         return;
        }
     }
-    else if (stricmp(cmd, "SELL" ) == 0)
+  else if (stricmp(cmd, "SELL" ) == 0)
     {
-       p = user->stats;
-
-        if (stricmp(item, "WEAPON") == 0)
+      p = user->stats;
+      
+      if (stricmp(item, "WEAPON") == 0)
         {
-            if (p->wea == 0)
+         if (p->wea == 0)
             {
-                notice(s_GameServ, u, "You want me to chop off your hands?");
-                return;
+             notice(s_GameServ, u, "You want me to chop off your hands?");
+             return;
             }
-            else if (p->gold == 2000000000)
+         else if (p->gold == 2000000000)
             {
-                notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
-                p->wea = 0;
+             notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
+             p->wea = 0;
             }
-            else if (2000000000 - p->gold < (prices[p->wea - 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->wea = 0;
+             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->wea = 0;
             }
-            else
+         else
            {
-                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;
+             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)
+      else if (stricmp(item, "ARMOR") == 0)
         {
-           p = user->stats;
-
-            if (p->arm == 0)
+         p = user->stats;
+         
+         if (p->arm == 0)
             {
-                notice(s_GameServ, u, "I don't think you can be any more naked...");
-                return;
+             notice(s_GameServ, u, "I don't think you can be any more naked...");
+             return;
             }
-            if (p->gold == 2000000000)
+         if (p->gold == 2000000000)
             {
-                notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
-                p->arm = 0;
+             notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
+             p->arm = 0;
             }
-            else if (2000000000 - p->gold < (prices[p->arm - 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->arm = 0;
+             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->arm = 0;
             }
-            else
+         else
             {
-                notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no armor!",
-                         (prices[p->arm - 1] / 2));
-
-                p->gold += (prices[p->arm - 1] / 2);
-                p->arm = 0;
+             notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no armor!",
+                    (prices[p->arm - 1] / 2));
+             
+             p->gold += (prices[p->arm - 1] / 2);
+             p->arm = 0;
             }
        }
-        else
+      else
        {
-           notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
-           notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
-           notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
+         notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
+         notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
+         notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
        }
     }
-    else
+  else
     {
-       notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
-       notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
-       notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
-       return;
+      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
+      notice(s_GameServ, u, "        \ 2STORE SELL {ARMOR | WEAPON}\ 2");
+      notice(s_GameServ, u, "        \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
+      return;
     }
 }
 void do_inventory(char *u)
@@ -2655,24 +2520,41 @@ void do_inventory(char *u)
     updateTS(user->stats);
     showinventory(user, user);
 }
+
 void showinventory(aClient *from, aClient *to)
 {
-    char *nick = to->getNick();
+  char *nick = to->getNick();
 
-    if (!to)
-       to = from;
-    if (is_playing(from))
+  if (!to)
+    to = from;
+  
+  if (is_playing(from))
     {
-       Pouch *p = &from->stats->inventory;
-       notice(s_GameServ, nick, "Inventory for %s:", from->stats->name.c_str());
-       notice(s_GameServ, nick, " Healing Potions: %d", p->Healing());
-       notice(s_GameServ, nick, "Strength Potions: %d", p->Strength());
-       notice(s_GameServ, nick, " Defense Potions: %d", p->Defense());
-       notice(s_GameServ, nick, "      HP Potions: %d", p->HP());
+      if (from->stats->inventory->isEmpty())
+       {
+         notice(s_GameServ, nick, "You aren't carrying anything");
+         return;
+       }
+
+      list <item*> *items;
+      items = from->stats->inventory->getItems();
+
+      list <item*>::iterator item_iter;
+      item_iter = items->begin();
+
+      notice(s_GameServ, nick, "Inventory for %s:", from->stats->name.c_str());
+      while (item_iter != items->end())
+       {
+         int x = 0;
+         notice(s_GameServ, nick, "%d.) %s", x, (*item_iter)->getName().c_str());
+       }
+
     }
+
 }
 void do_tavern(char *u)
 {
+  /*
     char *cmd = strtok(NULL, " ");
     long int price;
 
@@ -2810,6 +2692,8 @@ void do_tavern(char *u)
        notice(s_GameServ, u, "Improper Syntax.");
        notice(s_GameServ, u, "Type /msg %S HELP TAVERN for help");
     }
+  */
+  return;
 }
 
 void do_bank(char *u)
index 9c6b12204c29dbb46ac7c8a7558774268fb7e2b5..3d0dffc620c912027057fe99b50eb78a8e6db891 100644 (file)
@@ -1,4 +1,3 @@
-#include "item.h"
 #include "extern.h"
 #include <ctype.h>
 
index d98d744fb3687529dc78de8f67dd577752883ae5..d23620131c596f61fa8070070228cea3e482fa41 100644 (file)
@@ -1,6 +1,16 @@
 #include "item.h"
+#include "player.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)
+item::item()
+{
+  myname = "New Item";
+  myprice = 0;
+  myuses = 0;
+  for (int x = 0; x < 8; x++)
+    mymodifiers[x] = 0;
+}
+
+item::item(const char *name, long int p, int uses, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8)
 {
   myname = name; // string = char*
   myprice = p;
@@ -15,7 +25,7 @@ item::item(char *name, int p, int uses, int m1, int m2, int m3, int m4, int m5,
   mymodifiers[7] = m8;
 }
 
-item::item(string name, int p, int uses, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8)
+item::item(string name, long int p, int uses, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8)
 {
   myname = name; // string = char*
   myprice = p;
@@ -80,6 +90,32 @@ void weapon::undo(Player *p)
   p->maxhp -= mymodifiers[2];
 }
 
+void armor::undo(Player *p)
+{
+  p->strength -= mymodifiers[0];
+  p->defense -= mymodifiers[1];
+  p->maxhp -= mymodifiers[2];
+}
+
+bool armor::use(Player *p)
+{
+  //  weapon(char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0)
+  if (myuses == 0)
+    return false;
+  else
+    {
+      p->strength += mymodifiers[0];
+      p->defense += mymodifiers[1];
+      p->maxhp += mymodifiers[2];
+    }
+
+  if (myuses > 0)
+    {
+      myuses--;
+    }
+  return true;
+}
+
 bool potion::use(Player *p)
 {
   // potion(char *name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0)
@@ -104,3 +140,8 @@ bool potion::use(Player *p)
     }
   return true;
 }
+
+void potion::undo(Player *p)
+{
+  return;
+}
index 69719c453c149db80706d19b770a91e575cb61f3..a1f721f6c8bab7875f8a6ad1b4fbc34dfc3544c2 100644 (file)
@@ -2,21 +2,28 @@
 #define ITEM_H
 
 
-#include <string.h>
-#include "player.h"
+#include <string>
+
+using namespace std;
+
+class Player; // Forward declaration
 
 class item
 {
  public:
-  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);
+  item();
+  item(const char *name, long 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, long 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; };
+
+  string getName () { return myname; };
   
   virtual bool use(Player *p) = 0;
-  virtual void undo() = 0;
+  virtual void undo(Player *p) = 0;
 
   bool operator<(const item &right) const;
   bool operator>(const item &right) const;
@@ -27,39 +34,58 @@ class item
   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
+  int myuses;            // How many times this item can be used by default
+};
+
+/*class itemContainer
+{
+ public:
+  itemContainer();
+  itemContainer(item *);
+  ~itemContainer();
+
+  itemContainer &operator ++();
+  itemContainer operator ++(itemContainer);
+
+ private:
+  int myuses;              How many times 
+  item *myitem; 
 };
+*/
 
 class weapon : public item
 {
   public:
-  weapon(char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+  weapon() : item() {myname = "New Weapon";};
+  weapon(const char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
   weapon(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 ~weapon();
+  ~weapon();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p);
+  bool use(Player *p);
+  void undo(Player *p);
 };
 
 class armor : public item
 {
   public:
-  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() : item(){};
+  armor(const 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();
+  ~armor();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p);
+  bool use(Player *p);
+  void undo(Player *p);
 };
 
 class potion : public item
 {
   public:
-  potion(char *name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
+  potion() : item(){};
+  potion(const char *name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
   potion(string name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
-  virtual ~potion();
+  ~potion();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p) { return; }; // You can't undo a potion
+  bool use(Player *p);
+  void undo(Player *p);
 };
 #endif
index 77e353c4ce6020bf12016f0cd7938695e72af638..d42c4b9bb8c910a91bdfab8fefc43039f2204eac 100644 (file)
@@ -251,6 +251,7 @@ void List<T>::print() const
        cout << currentPtr->getData()->getString() << endl;
        currentPtr = currentPtr->next;
        */
+      /*
        T *dat;
        dat = currentPtr->getData();
        log("name: %s", dat->name.c_str());
@@ -262,6 +263,7 @@ void List<T>::print() const
        log("maxhp: %d", dat->maxhp);
        log("hp: %d", dat->hp);
        currentPtr = currentPtr->next;
+      */
     }
 }
 #endif
index 3d3887b52f8e13704634f985e8db41c3e86dfe68..3188758f9f4828f7c7ed3431943a0fea634b53e2 100644 (file)
@@ -10,126 +10,131 @@ using namespace std;
 
 void Player::reset()
 {
-    exp = 1;
-    gold = 0;
-    bank = 500;
-    hp = 10;
-    maxhp = 10;
-    strength = 0;
-    defense = 0;
-    arm = 1;
-    wea = 1;
-    level = 1;
-    forest_fights = forestfights;
-    player_fights = 3;
-    fight = NULL;
-    master = NULL;
-    battle = NULL;
-    flags = 0;
-    lastcommand = 0;
-    lastlogin = 0;
-    setAlive(this);
-    inventory.reset();
+  exp = 1;
+  gold = 0;
+  bank = 500;
+  hp = 10;
+  maxhp = 10;
+  strength = 0;
+  defense = 0;
+  arm = 1;
+  wea = 1;
+  level = 1;
+  forest_fights = forestfights;
+  player_fights = 3;
+  fight = NULL;
+  master = NULL;
+  battle = NULL;
+  flags = 0;
+  lastcommand = 0;
+  lastlogin = 0;
+  setAlive(this);
+  inventory->clear();
 }
 
 Player::Player()
 {
-    setData(NULL);
-
-    #ifdef DEBUGMODE
-       log("New Player: %s", name.c_str());
-    #endif
+  inventory = new pouch();
+  setData(NULL);
+  
+#ifdef DEBUGMODE
+  log("New Player: %s", name.c_str());
+#endif
 }
 
 Player::Player(char *n)
 {
-    reset(); // Set defaults
-
-    name = n;
-
-    #ifdef DEBUGMODE
-       log("New Player: %s", name.c_str());
-    #endif
+  inventory = new pouch();
+  reset(); // Set defaults
+  
+  name = n;
+  
+#ifdef DEBUGMODE
+  log("New Player: %s", name.c_str());
+#endif
 }
 
 Player::Player(string n)
 {
-    reset();
-    name = n;
-    #ifdef DEBUGMODE
-       log("New Player: %s", name.c_str());
-    #endif
+  inventory = new pouch();
+  reset();
+  name = n;
+#ifdef DEBUGMODE
+  log("New Player: %s", name.c_str());
+#endif
 }
 
 Player::~Player()
 {   
-    #ifdef DEBUGMODE
-       string *output;
-       output = new string("Deleting Player");
-    #endif
-    #ifdef DEBUGMODE
-        *output += ": " + name;
-    #endif
-
-    #ifdef DEBUGMODE
-       *output += "    Password: " + password;
-       log ("%s", output->c_str());
-       delete output;
-    #endif
+  delete inventory;
+
+#ifdef DEBUGMODE
+  string *output;
+  output = new string("Deleting Player");
+#endif
+  
+#ifdef DEBUGMODE
+  *output += ": " + name;
+#endif
+  
+#ifdef DEBUGMODE
+  *output += "    Password: " + password;
+  log ("%s", output->c_str());
+  delete output;
+#endif
 }
 void Player::setPassword(const char *p)
 {
-      static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV\
+  static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV\
 WXYZ0123456789./";
-      static char salt[3];
-
-      salt[0] = saltChars[rand() % strlen(saltChars)];
-      salt[1] = saltChars[rand() % strlen(saltChars)];
-      salt[2] = '\0';
-
-      password = crypt(p, salt);
+  static char salt[3];
+  
+  salt[0] = saltChars[rand() % strlen(saltChars)];
+  salt[1] = saltChars[rand() % strlen(saltChars)];
+  salt[2] = '\0';
+  
+  password = crypt(p, salt);
 }
 
 void Player::setData(Player *right)
 {
-    if (right)
+  if (right)
     {
-       name = right->name;
-       password = right->password;
-        exp = right->exp;
-        gold = right->gold;
-        bank = right->bank;
-        hp = right->hp;
-        maxhp = right->maxhp;
-        strength = right->strength;
-        defense = right->defense;
-        arm = right->arm;
-        wea = right->wea;
-        level = right->level;
-        forest_fights = right->forest_fights;
-        player_fights = right->player_fights;
-       flags = right->flags;
-       inventory.setInventory(&right->inventory);
-       client = right->client;
-       lastcommand = right->lastcommand;
-       lastlogin = right->lastlogin;
+      name = right->name;
+      password = right->password;
+      exp = right->exp;
+      gold = right->gold;
+      bank = right->bank;
+      hp = right->hp;
+      maxhp = right->maxhp;
+      strength = right->strength;
+      defense = right->defense;
+      arm = right->arm;
+      wea = right->wea;
+      level = right->level;
+      forest_fights = right->forest_fights;
+      player_fights = right->player_fights;
+      flags = right->flags;
+      *inventory = *right->inventory;
+      client = right->client;
+      lastcommand = right->lastcommand;
+      lastlogin = right->lastlogin;
     }
-    else
+  else
     {
-       char *temp;
-        reset();
-       temp = new char[16];
-       client = NULL;
-       int num = rand() % 32767;
-       snprintf(temp, 16, "Player: %d", num);
-       name = temp;
-       delete []temp;
+      char *temp;
+      reset();
+      temp = new char[16];
+      client = NULL;
+      int num = rand() % 32767;
+      snprintf(temp, 16, "Player: %d", num);
+      name = temp;
+      delete []temp;
     }
-
-    #ifdef DEBUGMODE
-       log("Setting Player data for %s", name.c_str());
-    #endif
+  
+#ifdef DEBUGMODE
+  log("Setting Player data for %s", name.c_str());
+#endif
 }
 
 monster_::~monster_()
@@ -138,63 +143,56 @@ monster_::~monster_()
 
 monster_::monster_()
 {
-    name.erase();
-    weapon.erase();
-    death.erase();
-    strength = 0;
-    defense = 0;
-    exp = 0;
-    gold = 0;
-    maxhp = hp = 0;
+  name.erase();
+  weapon.erase();
+  death.erase();
+  strength = 0;
+  defense = 0;
+  exp = 0;
+  gold = 0;
+  maxhp = hp = 0;
 }
 
 monster_::monster_(monster_ *m)
 {
-    name = m->name;
-    weapon = m->weapon;
-    death = m->death;
-    strength = m->strength;
-    defense = m->defense;
-    maxhp = m->maxhp;
-    hp = m->hp;
-    gold = m->gold;
-    exp = m->exp;
+  name = m->name;
+  weapon = m->weapon;
+  death = m->death;
+  strength = m->strength;
+  defense = m->defense;
+  maxhp = m->maxhp;
+  hp = m->hp;
+  gold = m->gold;
+  exp = m->exp;
 }
 
 monster_::monster_(monster_ &m)
 {
-    name = m.name;
-    weapon = m.weapon;
-    death = m.death;
-    strength = m.strength;
-    defense = m.defense;
-    maxhp = m.maxhp;
-    hp = m.hp;
-    gold = m.gold;
-    exp = m.exp;
+  name = m.name;
+  weapon = m.weapon;
+  death = m.death;
+  strength = m.strength;
+  defense = m.defense;
+  maxhp = m.maxhp;
+  hp = m.hp;
+  gold = m.gold;
+  exp = m.exp;
 }
 
 long int Player::setFlags(long int newflags)
 {
-    flags = newflags;
-    return getFlags();
+  flags = newflags;
+  return getFlags();
 }
 
 long int Player::addFlag(long int flag)
 {
-    flags |= flag;
-    return getFlags();
+  flags |= flag;
+  return getFlags();
 }
 
 long int Player::remFlag(long int flag)
 {
-    flags &= ~flag;
-    return getFlags();
-}
-
-Pouch::Pouch(int h, int s, int d)
-{
-    setHealing(h);
-    setStrength(s);
-    setDefense(d);
+  flags &= ~flag;
+  return getFlags();
 }
index 096bb45c1112ec2c9c3fca4ee3583c6bdb93cdf5..b0919dd1410f5bd732853570b17f8b171f397177 100644 (file)
@@ -3,18 +3,17 @@
 
 #include <string>
 
-#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 pouch;   // forward declaration
 
 class Player {
 public:
@@ -53,7 +52,7 @@ public:
     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
-    Pouch inventory;           // This contains their potions, etc.
+    pouch *inventory;          // This contains everything you're holding
     long int lastcommand;      // timestamp for the last command typed
     long int lastlogin;                // timestamp for the last login
 
index 778a9f7c18c50739dc86a143358017c1a1f55c3e..8ab6b1eb5ab16358facbbfe227dd6d8de22e0301 100644 (file)
@@ -1,55 +1,35 @@
 #ifndef POUCH_H
 #define POUCH_H
 
-class Pouch {
-  public:
-
-    Pouch(int h = 0, int s = 0, int d = 0);    // Default constructor
-
-    // Access functions to get the number of each potion in inventory
-    int Healing() { return healing; };
-    int Strength() { return strength; };
-    int Defense() { return defense; };
-    int HP() { return hp; };
-
-    // Modifiers to set the number of potions
-    int setHealing (int h = 0) { healing = h; return Healing();};
-    int setStrength (int s = 0) { strength = s; return Strength(); };
-    int setDefense (int d = 0) { defense = d; return Defense();};
-    int setHP (int h = 0) { hp = h; return HP(); };
-
-    // Add one healing potion
-    int incHealing() { return setHealing(Healing() + 1); };
-
-    // Add one Strength potion
-    int incStrength() { return setStrength(Strength() + 1); };
-
-    // Add one Defense potion
-    int incDefense() { return setDefense(Defense() + 1); };
-
-    // Add one Max HP Potion
-    int incHP() { return setHP(HP() + 1); };
-
-    int decHealing() { return setHealing(Healing() - 1); };
-    int decStrength() { return setStrength(Strength() - 1); };
-    int decDefense() { return setDefense(Defense() - 1); };
-    int decHP() { return setHP(HP() - 1); };
-
-    void setInventory(Pouch *right) {  setHealing(right->Healing());
-                                       setStrength(right->Strength());
-                                       setDefense(right->Defense());
-                                       setHP(right->HP());
-                                   };
-    // Reset all potions to 0
-    void reset() {     setHealing(0);  setStrength(0);         setDefense(0);
-                       setHP(0);};
-
-  private:
-    // Potions
-    int healing;
-    int strength;
-    int defense;
-    int hp;
+#include <list>
+
+class item; // forward declaration
+
+using namespace std;
+
+class pouch 
+{
+ public:
+  pouch();
+  pouch(pouch *);
+  ~pouch();
+
+  void sort();
+  void clear();
+  bool isEmpty();
+
+  item *Find(char *);
+  item *Find(string &);
+
+  void addItem(item *);
+  void deleteItem(item *);
+  list <item*> *getItems() { return &items; };
+
+  // operators
+  const pouch &operator = ( const pouch &);
+
+ private:
+  list <item*> items;
 };
 
 #endif