From: kainazzzo Date: Tue, 25 Nov 2003 17:35:46 +0000 (+0000) Subject: Added a file pouch.h which contains an inventory class Pouch to be used for carrying... X-Git-Url: https://jfr.im/git/irc/gameservirc.git/commitdiff_plain/3662210ff8fbf469ecfc45ce9e1734ddb781e6fd?hp=2bf5063e2e7ffafd210396652ed7b98ad438b343 Added a file pouch.h which contains an inventory class Pouch to be used for carrying things like potions and such. git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@70 bc333340-6410-0410-a689-9d09f3c113fa --- diff --git a/gameserv/Makefile.in b/gameserv/Makefile.in index e3e98c2..41f60a4 100644 --- a/gameserv/Makefile.in +++ b/gameserv/Makefile.in @@ -37,30 +37,31 @@ configscript: configscript.o configscript.o: configscript.cpp $(CC) $(CFLAGS) -c configscript.cpp -tcpclient.o: tcpclient.cpp aClient.h player.h extern.h list.h listnode.h \ - options.h sockhelp.h +tcpclient.o: tcpclient.cpp aClient.h player.h pouch.h extern.h list.h \ + listnode.h options.h sockhelp.h $(CC) $(CFLAGS) -c tcpclient.cpp tcpserver.o: tcpserver.cpp sockhelp.cpp $(CC) $(CFLAGS) -c tcpserver.cpp sockhelp.o: sockhelp.cpp aClient.h extern.h list.h listnode.h \ - player.h sockhelp.h + player.h pouch.h sockhelp.h $(CC) $(CFLAGS) -c sockhelp.cpp aClient.o: aClient.cpp aClient.h extern.h list.h listnode.h \ - player.h sockhelp.h + player.h pouch.h sockhelp.h $(CC) $(CFLAGS) -c aClient.cpp gameserv.o: gameserv.cpp aClient.h extern.h flags.h list.h\ - listnode.h player.h sockhelp.h + listnode.h player.h pouch.h sockhelp.h $(CC) $(CFLAGS) -c gameserv.cpp c_forest.o: c_forest.cpp aClient.h extern.h list.h\ - listnode.h player.h sockhelp.h + listnode.h player.h pouch.h sockhelp.h $(CC) $(CFLAGS) -c c_forest.cpp -player.o: player.cpp aClient.h extern.h list.h listnode.h player.h sockhelp.h +player.o: player.cpp aClient.h extern.h list.h listnode.h player.h \ + pouch.h sockhelp.h $(CC) $(CFLAGS) -c player.cpp config.o: config.cpp extern.h diff --git a/gameserv/aClient.h b/gameserv/aClient.h index 05c3bbd..591f09b 100644 --- a/gameserv/aClient.h +++ b/gameserv/aClient.h @@ -7,7 +7,6 @@ class Player; // forward declaration - class aClient { friend ostream &operator<<( ostream &output, const aClient &c); diff --git a/gameserv/player.cpp b/gameserv/player.cpp index ccaf1ab..55aa920 100644 --- a/gameserv/player.cpp +++ b/gameserv/player.cpp @@ -1,4 +1,5 @@ #include "player.h" +#include "pouch.h" #include "extern.h" #include #include @@ -25,6 +26,7 @@ void Player::reset() master = NULL; battle = NULL; flags = 0; + inventory.reset(); } Player::Player(aClient *user) @@ -158,3 +160,9 @@ long int Player::remFlag(long int flag) return getFlags(); } +Pouch::Pouch(int h, int s, int d) +{ + setHealing(h); + setStrength(s); + setDefense(d); +} diff --git a/gameserv/player.h b/gameserv/player.h index 9e8b2da..c4d9bf7 100644 --- a/gameserv/player.h +++ b/gameserv/player.h @@ -4,6 +4,7 @@ #include #include #include "aClient.h" +#include "pouch.h" typedef struct monster_ Monster; @@ -40,11 +41,13 @@ public: int forest_fights; // Amount of forest fights left today int player_fights; // Amount of player<->player fights for today char *password; // Player's encrypted password + Pouch inventory; // This contains their potions, etc. aClient *user; // Pointer to the aClient this player is from Monster *fight; // Pointer to the monster the player is currently fighting Monster *master; // Pointer to the master the player is currently fighting aClient *battle; // Pointer to the player this player is currently fighting + private: long int flags; // Player's current flags }; diff --git a/gameserv/pouch.h b/gameserv/pouch.h new file mode 100644 index 0000000..ece1c71 --- /dev/null +++ b/gameserv/pouch.h @@ -0,0 +1,38 @@ +#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; }; + + // 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();}; + + // 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); }; + + // Reset all potions to 0 + void reset() { setHealing(0); setStrength(0); setDefense(0); }; + + private: + // Potions + int healing; + int strength; + int defense; +}; + +#endif