/*----
  implementation file for class: PlayerChar

  a PlayerChar represents a player in a game (for 
      example, in a role-playing game)

  by: Sharon Tuttle
  last modified: 2022-09-22 - original version 
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include "PlayerChar.h"    
using namespace std;

// for EVERY method of PlayerChar,
//     put PlayerChar:: in front of each method's name
//     in its method header!

// constructor methods
// *   class style: each should initialize ALL
//     of the data fields!

PlayerChar::PlayerChar()
{
    name = "";
    strength = 5;
    exp = 0.0;
    role = "";
    hp = 20;
}

PlayerChar::PlayerChar(string init_name, int init_strength,
                   double init_exp, string init_role,
                   int init_hp)
{
    // note: you can add additional code
    //    seeing if given data field values are
    //    reasonable, or computing some data field
    //    values based on others' values, etc.!

    name = init_name;
    strength = init_strength;
    exp = init_exp;
    role = init_role;
    hp = init_hp;
}

// accessor methods

string PlayerChar::get_name() const
{
    return name;
}

int PlayerChar::get_strength() const
{
    return strength;
}

double PlayerChar::get_exp() const
{
    return exp;
}

string PlayerChar::get_role() const
{
    return role;
}

int PlayerChar::get_hp() const
{
    return hp;
}

// mutator methods
// (these CAN have additional double-checking
//    of user's provided arguments, etc.)

void PlayerChar::set_name(string new_name)
{
    name = new_name;
}

void PlayerChar::set_role(string new_role)
{
    role = new_role;
}

// "other" methods

/*---
    signature: display_player: void -> void
    purpose: expects nothing, prints to the
        screen the characteristics of the
        calling player char, and returns nothing
    tests:
        for:
        PlayerChar a_player;

        a_player.display_player();

        prints to the screen:

PlayerChar:
   name:
   strength: 5
   exp:      0
   role:
   hp:       20

    for:
    PlayerChar angie("Angie", 10, 2.7, "tank", 15);

    angie.display_player();

    ...prints to the screen:

PlayerChar:
   name:     Angie
   strength: 10
   exp:      2.7
   role:     tank
   hp:       15

---*/

void PlayerChar::display_player() const
{
    cout << endl
         << "PlayerChar:\n"
         << "   name:     " << name << endl
         << "   strength: " << strength << endl
         << "   exp:      " << exp << endl
         << "   role:     " << role << endl
         << "   hp:       " << hp << endl;
}


/*---
    signature: player_to_string: void -> string
    purpose: expects nothing, and returns
        a string depiction of the calling player
        char
    tests:
        for:
        PlayerChar a_player;

        a_player.player_to_string() ==
            "PlayerChar(, 5, 0.000000, , 20)"

        for:
        PlayerChar angie("Angie", 10, 2.7, "tank" 15);

        angie.player_to_string() ==
            "PlayerChar(Angie, 10, 2.700000, tank, 15)" 
    
---*/

string PlayerChar::player_to_string() const
{
    return "PlayerChar(" + name + ", "
           + to_string(strength) + ", "
           + to_string(exp) + ", "
           + role + ", "
           + to_string(hp) + ")";
}