Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Player.h"
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- Player::Player()
- {
- _name = "DEFAULT";
- _health = 100;
- _strengh = 1;
- _agility = 1;
- _mf = "male";
- _race = 0;
- _xCoord = 3;
- _yCoord = 5;
- _win = 0;
- _tryX = 3;
- _tryY = 5;
- }
- Player::Player(string name, int health, int strengh, int agility, string mf, int race, int xCoord, int yCoord, int win, int tryX, int tryY)
- {
- _name = name;
- _health = health;
- _strengh = strengh;
- _agility = agility;
- _mf = mf;
- _race = race;
- _xCoord = xCoord;
- _yCoord = yCoord;
- _win = win;
- _tryX = tryX;
- _tryY = tryY;
- }
- void Player::set_name(string PlayerName)
- {
- _name = PlayerName;
- }
- void Player::set_sex(string playerSex)
- {
- if (playerSex == "m")
- {
- _mf = "male";
- }
- else if (playerSex == "f")
- {
- _mf = "female";
- }
- else
- {
- _mf = "male";
- }
- }
- void Player::set_race(int playerRace)
- {
- _race = playerRace;
- }
- void Player::set_tryX(int tryX)
- {
- _tryX = tryX;
- }
- void Player::set_tryY(int tryY)
- {
- _tryY = tryY;
- }
- void Player::set_xCoord(int coord)
- {
- _xCoord = coord;
- }
- void Player::set_yCoord(int coord)
- {
- _yCoord = coord;
- }
- void Player::returnRace()
- {
- if (_race == 1)
- {
- cout << "Human";
- }
- else if (_race == 2)
- {
- cout << "Mage";
- }
- }
- string Player::returnName()
- {
- return _name;
- }
- int Player::returnHealth()
- {
- return _health;
- }
- string Player::returnSex()
- {
- return _mf;
- }
- void Player::returnStat(int stat)
- {
- if (stat == 1)
- {
- cout << _strengh;
- }
- else if (stat == 2)
- {
- cout << _agility;
- }
- }
- int Player::returnCoord(int coord)
- {
- if (coord == 1)
- {
- return (_xCoord);
- }
- else if (coord == 2)
- {
- return (_yCoord);
- }
- }
- int Player::returnTry(int coord)
- {
- if (coord == 1)
- {
- return _tryX;
- }
- else if (coord == 2)
- {
- return _tryY;
- }
- }
- int Player::returnWin()
- {
- return _win;
- }
- void Player::addStat(int stat, int amount)
- {
- if (stat == 1)
- {
- _strengh = _strengh + amount;
- }
- if (stat == 2)
- {
- _agility = _agility + amount;
- }
- }
- void Player::subtractStat(int stat, int amount)
- {
- if (stat == 1)
- {
- _strengh = _strengh - amount;
- }
- if (stat == 2)
- {
- _agility = _agility - amount;
- }
- }
- void Player::createStats()
- {
- if (_race == 1)
- {
- srand((unsigned)time(0));
- _strengh = rand() % 5 + 1;
- _agility = rand() % 15 + 1;
- }
- if (_race == 2)
- {
- srand((unsigned)time(0));
- _strengh = rand() % 15 + 1;
- _agility = rand() % 8 + 1;
- }
- }
- void Player::IsDead()
- {
- if (_health <= 0)
- {
- cout << "Player " << _name << " has died!" << endl;
- }
- }
- Player::~Player()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment