#include "player.h"
+#include "pouch.h"
+#include "extern.h"
+#include "flags.h"
#include <stdlib.h>
#include <stdio.h>
void Player::reset()
{
- memset(name, 0, 255);
- memset(password, 0, 255);
-
- cout << "Got Here" << endl;
+ memset(name, 0, 256);
+ memset(password, 0, 256);
exp = 1;
gold = 0;
armor = 1;
weapon = 1;
level = 1;
- alive = 1;
- started = 1; // Possibly deprecated
- forest_fights = 100;
+ forest_fights = forestfights;
player_fights = 3;
fight = NULL;
master = NULL;
battle = NULL;
+ flags = 0;
+ setAlive(this);
+ inventory.reset();
}
Player::Player(aClient *user)
password = new char[256];
if (user)
+ {
setData(user->stats);
+ strcpy(name, user->getNick());
+ }
else
setData(NULL);
- cout << "New Player: " << name << endl << flush;
+ #ifdef DEBUGMODE
+ log("New Player: %s", name);
+ #endif
}
Player::Player(char *n)
strcpy(name, n);
- cout << "New Player: " << name << endl << flush;
+ #ifdef DEBUGMODE
+ log("New Player: %s", name);
+ #endif
}
Player::~Player()
-{
- cout << "Deleting player";
-
- if (name)
+{
+ #ifdef DEBUGMODE
+ char *output;
+ output = new char[strlen(name) + strlen(password) + 48];
+ strcpy(output, "Deleting Player");
+ #endif
+
+ if (name != NULL)
{
- cout << ": " << name;
+ #ifdef DEBUGMODE
+ sprintf(output, "%s: %s", output, name);
+ #endif
+
delete [] name;
}
- if (password)
+
+ if (password != NULL)
{
- cout << " Password: " << password;
+ #ifdef DEBUGMODE
+ sprintf(output, "%s Password: %s", output, password);
+ #endif
+
delete [] password;
}
- cout << endl << "Player Deleted";
+
+ #ifdef DEBUGMODE
+ log ("%s", output);
+ delete [] output;
+ #endif
}
void Player::setData(Player *right)
armor = right->armor;
weapon = right->weapon;
level = right->level;
- alive = right->alive;
- started = right->started; // Possibly obsoleted
forest_fights = right->forest_fights;
player_fights = right->player_fights;
+ flags = right->flags;
+ inventory.setInventory(&right->inventory);
}
else
{
reset();
int num = rand() % 32767;
- sprintf(name, "Player%d\0", num);
+ sprintf(name, "Player%d", num);
}
- cout << "Setting Player data for " << name << endl;
+ #ifdef DEBUGMODE
+ log("Setting Player data for %s", name);
+ #endif
}
monster_::~monster_()
monster_::monster_()
{
- name = new char[32];
- weapon = new char[32];
- death = new char[256];
+ name = new char[64];
+ weapon = new char[64];
+ death = new char[512];
- memset(name, 0, 32);
- memset(weapon, 0, 32);
- memset(death, 0, 256);
+ memset(name, 0, 64);
+ memset(weapon, 0, 64);
+ memset(death, 0, 512);
}
monster_::monster_(monster_ *m)
strength = m->strength;
maxhp = m->maxhp;
+ hp = m->hp;
gold = m->gold;
exp = m->exp;
}
+
+long int Player::setFlags(long int newflags)
+{
+ flags = newflags;
+ return getFlags();
+}
+
+long int Player::addFlag(long int flag)
+{
+ 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);
+}