]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/player.h
Added messages.cpp and find.cpp, which contain functions from gameserv.cpp
[irc/gameservirc.git] / gameserv / player.h
index 36945cf5c58e7ba88f7236b5b33dcec8415d9e42..2e76b7614c61f8c5d14515995f3374ed5cd4579e 100644 (file)
 #ifndef PLAYER_H
 #define PLAYER_H
 
-#include <string.h>
-#include <iostream.h>
-#include "aClient.h"
+#include <string>
+#include "script.h"
 
-typedef struct monster_  Monster;
+using namespace std;
 
 class aClient; // forward declaration
+class Monster; // forward declaration
+
+class item;    // forward declaration
+class weapon;  // forward declaration
+class armor;   // forward declaration
+class potion;  // forward declaration
+class pouch;   // forward declaration
+class script;  // forward declaration
 
 class Player {
 public:
-    Player(aClient *user = NULL);
-    Player(char *);
-    ~Player();
-    void setData(Player *);
-    void reset();
-
-    const Player &operator=(const Player &);
-    char *name;                        // Player's Name
-    int level;                 // Player's level (1-12)
-    long int exp;               // Player's experience
-    long int gold;              // Gold on hand
-    long int bank;              // Gold in the bank
-    int hp;                     // Current Hit Points (health)
-    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
-    bool alive;                 // True/False: is the player alive?
-    bool started;               // True/False: has this player started? -Possibly deprecated
-    bool yourturn;             // True/False: is it your turn in battle?
-    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
-
-    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
+  Player();
+  Player(char *);
+  Player(string);
+  ~Player();
+  void setData(Player *);
+
+  void reset();
+  friend class script;
+  
+  long int getFlags() { return flags; };          // Returns the Client's current flags
+  // Functions also return the flags after modifying them
+  long int setFlags(long int);    // Sets the clients flags to a new value
+  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
+  
+  
+  item *getWeapon() { return w; };
+  item *getArmor() { return a; };
+  
+  void setWeapon (item &);  // Set a player's weapon to some item
+  void setArmor (item &);   // Set a player's weapon to some item
+  
+  void clearWeapon () { w = NULL; };      // Remove a weapon
+  void clearArmor () { a = NULL; };
+
+  void setName (string &); // Set the player's name
+  void setName (const char *); // Set the player's name
+  void setLevel(int ); // Set the player's level
+  void setExp(long int); // Set the player's experience
+  void setGold(long int); // Set the player's gold
+  void setBank(long int); // Set the player's bank balance
+  void setHP(int); // Set the player's hit points (health)
+  void setMaxHP(int); // Set the player's maximum hit points
+  void setStrength(int); // Set the player's raw strength
+  void setDefense(int); // Set the player's raw defense
+  void setForestFights(int); // Set the player's forest fight limit
+  void setPlayerFights(int); // Set the player's player vs. player fight limit
+  void setPassword(const char *p); // Set the player's password while encrypting it
+  void setRawPassword(const char *p); //Set the player's password without encrypting it
+  
+  void setClient(aClient *); // Set the pointer back to this player's IRC Client
+  void setMonster(Monster *); // Set the pointer to the monster this player is fighting
+  void setMyMaster(Monster *); // Set the pointer to the master this player is fighting
+  void setBattle(aClient *); // Set the pointer to the player this person is fighting
+
+  void addLevel(int); // Add to the player's level
+  void addExp(int); // Add to the player's experience
+  void addGold(int); // Add to the player's gold
+  void addBank(int); // Add to the player's bank account
+  void addHP(int); // Add to the player's hit points
+  void addMaxHP(int); // Add to the player's maximum hit points
+  void addStrength(int); // Add to the player's strength
+  void addDefense(int); // Add to the player's defense
+  void addForestFights(int); // Add to the player's forest fights
+  void addPlayerFights(int); // Add to the player's player vs. player fights
+
+  void subtractLevel(int); // Subtract from a player's level
+  void subtractExp(long int); // Subtract from a player's experience
+  void subtractGold(long int); // Subtract from a player's gold
+  void subtractBank(long int); // Subtract from a player's bank account
+  void subtractHP(int); // Subtract from a player's hit points
+  void subtractMaxHP(int); // Subtract from a player's maximum hit points
+  void subtractStrength(int); // Subtract from a player's strength
+  void subtractDefense(int); // Subtract from a player's defense
+  void subtractForestFights(int); // Subtract from a player's forest fights
+  void subtractPlayerFights(int); // Subtract from a player's player vs. player fights
+  pouch *inventory;            // This contains everything you're holding
+
+  string getName() { return name; };
+  int getLevel() { return level; };
+  long int getExp() { return exp; };
+  long int getGold() { return gold; };
+  long int getBank() { return bank; };
+  int getHP() { return hp; };
+  int getMaxHP() { return maxhp; };
+  int getStrength() { return strength; };
+  int getDefense() { return defense; };
+  int getForestFights() { return forest_fights; };
+  int getPlayerFights() { return player_fights; };
+  string getPassword() { return password; };
+
+  aClient *getClient() { return client; };
+  Monster *getMonster() { return fight; };
+  Monster *getMaster() { return master; };
+  aClient *getBattle() { return battle; };
+
+  void delMaster(); // Delete the monster stored in *master
+  void delMonster(); // Delete the monster stored in *fight
+  void delBattle(); // Clear the pointer to the player this person is fighting
+  void healall () { setHP(getMaxHP()); }; // Completely heal this person's hp
+
+  long int lastcommand;        // timestamp for the last command typed
+  long int lastlogin;          // timestamp for the last login
+
+  bool operator < (Player &right);
+  
+private:
+  string name;         // Player's Name
+  int level;                   // Player's level (1-12)
+  long int exp;               // Player's experience
+  long int gold;              // Gold on hand
+  long int bank;              // Gold in the bank
+  int hp;                     // Current Hit Points (health)
+  int maxhp;                  // Maximum Hit Points
+  int strength;               // Player's Strength
+  int defense;                // Player's defensive strength
+  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
+
+  aClient *client;             // 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
+
+  long int flags;              // Player's current flags
+  item *w;                    // Player's weapon
+  item *a;                    // Player's armor
 };
 
-struct monster_ {
-    char *name;    // The monster's name
-    char *weapon;  // A name for their weapon. Doesn't have to be in weapons[]
-    int strength;  // Their strength
-    int gold;      // The gold you get when you kill them
-    int exp;       // The experience you get when you kill them
-    int hp;        // Their remaining hitpoints
-    int maxhp;     // Their max hitpoints
-    char *death;   // What is said when they die
+class Monster {
+public:
+  Monster();
+  Monster(Monster *);
+  Monster(const Monster &);
+  Monster(Monster &);
+  ~Monster();
+  string name;         // The monster's name
+  string weapon;       // A name for their weapon. Doesn't have to be in weapons[]
+  int strength;        // Their strength
+  int gold;            // The gold you get when you kill them
+  int exp;             // The experience you get when you kill them
+  int hp;              // Their remaining hitpoints
+  int maxhp;           // Their max hitpoints
+  int defense; // Only used seldomly
+  string death;        // What is said when they die
 };
 
 #endif