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
class Player; // forward declaration
-
class aClient {
friend ostream &operator<<( ostream &output, const aClient &c);
#include "player.h"
+#include "pouch.h"
#include "extern.h"
#include <stdlib.h>
#include <stdio.h>
master = NULL;
battle = NULL;
flags = 0;
+ inventory.reset();
}
Player::Player(aClient *user)
return getFlags();
}
+Pouch::Pouch(int h, int s, int d)
+{
+ setHealing(h);
+ setStrength(s);
+ setDefense(d);
+}
#include <string.h>
#include <iostream.h>
#include "aClient.h"
+#include "pouch.h"
typedef struct monster_ Monster;
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
};
--- /dev/null
+#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