]> jfr.im git - irc/gameservirc.git/commitdiff
Added a file pouch.h which contains an inventory class Pouch to be used for carrying...
authorkainazzzo <redacted>
Tue, 25 Nov 2003 17:35:46 +0000 (17:35 +0000)
committerkainazzzo <redacted>
Tue, 25 Nov 2003 17:35:46 +0000 (17:35 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@70 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/Makefile.in
gameserv/aClient.h
gameserv/player.cpp
gameserv/player.h
gameserv/pouch.h [new file with mode: 0644]

index e3e98c25510f9c88e614fbdf58331c035b5d195d..41f60a4e408e386cef2f6dd91a2c1641fc40b3a3 100644 (file)
@@ -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
index 05c3bbd4011d6aa06b950e6140adc1f910b3e36d..591f09bdd490f18c72014179842a6d44fbfced09 100644 (file)
@@ -7,7 +7,6 @@
 
 class Player; // forward declaration
 
-
 class aClient {
 
        friend ostream &operator<<( ostream &output, const aClient &c);
index ccaf1abea3d094de9d915ab2c622938159082341..55aa9204bf06e05446b29faa249959381899409e 100644 (file)
@@ -1,4 +1,5 @@
 #include "player.h"
+#include "pouch.h"
 #include "extern.h"
 #include <stdlib.h>
 #include <stdio.h>
@@ -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);
+}
index 9e8b2da7aed939b9dd39c058e56a6206f257d10f..c4d9bf7140308a8122ea7369a84f0ae45b5d406f 100644 (file)
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <iostream.h>
 #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 (file)
index 0000000..ece1c71
--- /dev/null
@@ -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