/*----
  signature: main: void -> int
  purpose: testing program for the class Team
           (now including some *light* tests of
           "big 3" added during Week 8 Lecture 2,
           destructor, copy constructor, and
           overloaded assignment operator)

  compile using:
      g++ Team-test.cpp Team.cpp PlayerChar.cpp -o Team-test

  run using:
      ./Team-test

  by: Sharon Tuttle
  last modified: 2022-10-13 
----*/

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

int main()
{
    cout << boolalpha;

    cout << endl;
    cout << "*** Testing class Team ***"
         << endl << endl;

    // testing (regular) constructors and accessors

    cout << "regular constructors' and accessors' tests:" << endl;

    Team ex_team1;
    Team ex_team2("Example2", 2);

    cout << ( (ex_team1.get_name() == "")
              && (ex_team1.get_size() == 4)
              && (ex_team1.get_player(1).get_strength() == 5)
              && (ex_team1.get_player(2).get_strength() == 5)
              && (ex_team1.get_player(3).get_strength() == 5)
              && (ex_team1.get_player(4).get_strength() == 5) )
         << endl;

    cout << ( (ex_team2.get_name() == "Example2")
              && (ex_team2.get_size() == 2)
              && (ex_team2.get_player(1).get_hp() == 20)
              && (ex_team2.get_player(2).get_hp() == 20) )
         << endl;

    // test mutators

    cout << endl;
    cout << "mutators' tests: " << endl;

    ex_team2.set_name("Example2New");

    cout << (ex_team2.get_name() == "Example2New") << endl;

    PlayerChar angie("Angie", 10, 2.7, "tank", 15);             
    PlayerChar sven("Sven", 5, 3.1, "support", 14);
    
    ex_team2.set_player(angie, 1);
    ex_team2.set_player(sven, 2);
   
    cout << ( (ex_team2.get_player(1).get_name() == angie.get_name())
              && (ex_team2.get_player(1).get_strength() ==
                  angie.get_strength())
              && (ex_team2.get_player(1).get_exp() ==
                  angie.get_exp())
              && (ex_team2.get_player(1).get_role() ==
                  angie.get_role())
              && (ex_team2.get_player(1).get_hp() ==
                  angie.get_hp())) << endl;

    cout << ( (ex_team2.get_player(2).get_name() == sven.get_name())
              && (ex_team2.get_player(2).get_strength() ==
                  sven.get_strength())
              && (ex_team2.get_player(2).get_exp() ==
                  sven.get_exp())
              && (ex_team2.get_player(2).get_role() ==
                  sven.get_role())
              && (ex_team2.get_player(2).get_hp() ==
                  sven.get_hp())) << endl;
    
    // then, test your "other" methods

    cout << "\ntesting \"other\" methods:" << endl;

    cout << "\ntesting display:" << endl;

    cout << "\ntest succeeds if you see team name that's empty, size of 4,"
         << "\n    and four players each with an empty name,"
         << "\n    strength 5, exp 0, empty role, and hp 20: " << endl;

    Team a_team;

    a_team.display();

    cout << "test succeeds if you see name of Example2New, "
         << "\n    size of 2, and two players,"
         << "\n    *   Angie with strength 10, exp 2.7, role tank, "
         << "\n        and hp 15, and"
         << "\n    *   Sven with strength 5, exp 3.1, role support, "
         << "\n        and hp 14:" << endl;

    ex_team2.display();

    cout << "testing is_bigger_than:" << endl;
    
    Team team1("Team 1", 2);
    Team team2("Team 2", 3);

    cout << (team1.is_bigger_than(team2) == false) << endl;
    cout << (team2.is_bigger_than(team1) == true) << endl;
    cout << (team1.is_bigger_than(team1) == false) << endl;

    cout << endl;
    cout << "testing copy constructor:" << endl;
    cout << "\nIn Team version with cout statement in copy constructor,\n"
         << "    should see statement calling that constructor: \n"
         << endl;

    team2.set_name("Pomegranates");
    team2.set_player(angie, 1);
    team2.set_player(sven, 2);

    Team team3 = team2;

    PlayerChar deloris("Deloris", 9, 4.4, "adventurer", 13);
    team3.set_player(deloris, 1);

    cout << (team2.get_name() == team3.get_name()) << endl;
    cout << (team2.get_size() == team3.get_size()) << endl;    
    
    // 2nd players of team2 and team3 should have SAME name
    
    cout << (team3.get_player(2).get_name() ==
             team2.get_player(2).get_name()) << endl;

    cout << "\nnext part of test succeeds if you see name of Pomegranates, "
         << "\n    size of 3, and 3 players,"
         << "\n    *   Deloris with strength 9, exp 4.4, role adventurer, "
         << "\n        and hp 13, and"
         << "\n    *   Sven with strength 5, exp 3.1, role support, "
         << "\n        and hp 14, and"
         << "\n    *   one player with no name, strength 5, exp 0,"
         << "\n        no role, and hp 20" << endl;

    cout << "team3: ";
    team3.display();

    cout << "next part of test succeeds if you see name of Pomegranates, "
         << "\n    size of 3, and 3 players,"
         << "\n    *   Angie with strength 10, exp 2.7, role tank, "
         << "\n        and hp 15, and"
         << "\n    *   Sven with strength 5, exp 3.1, role support, "
         << "\n        and hp 14, and"
         << "\n    *   one player with no name, strength 5, exp 0,"
         << "\n        no role, and hp 20" << endl;

    cout << "team2: ";
    team2.display();
    
    cout << "testing overloaded assignment operator:" << endl;    
    cout << "\nIn Team version with cout statement in \n"
         << "    overloaded assignment operator, \n"
         << "    should see statement calling that operator: \n"
         << endl;

    team3.set_name("Kumquats");
    
    team1 = team3;

    cout << (team1.get_size() == team3.get_size()) << endl;
    cout << (team1.get_name() == team3.get_name()) << endl;

    team3.set_player(angie, 3);

    cout << "\nnext part of test succeeds if you see name of Kumquats, "
         << "\n    size of 3, and 3 players,"
         << "\n    *   Deloris with strength 9, exp 4.4, role adventurer, "
         << "\n        and hp 13, and"
         << "\n    *   Sven with strength 5, exp 3.1, role support, "
         << "\n        and hp 14, and"
         << "\n    *   Angie with strength 10, exp 2.7, role tank, "
         << "\n        and hp 15" << endl;

    cout << "team3:";
    team3.display();

    cout << "next part of test succeeds if you see name of Kumquats, "
         << "\n    size of 3, and 3 players,"
         << "\n    *   Deloris with strength 9, exp 4.4, role adventurer, "
         << "\n        and hp 13, and"
         << "\n    *   Sven with strength 5, exp 3.1, role support, "
         << "\n        and hp 14, and"
         << "\n    *   one player with no name, strength 5, exp 0,"
         << "\n        no role, and hp 20" << endl;

    cout << "team1:";
    team1.display();
    
    cout << "In Team version with cout statements in \n"
         << "    destructor, should now see statements from \n"
         << "    calling that destructor for: \n"
         << "team3 (with name KumQuats), team2 (with name Pomegranates),\n"
         << "    team1 (with name Kumquats), a_team (with no name),\n"
         << "    ex_team2 (with name Example2New), and\n"
         << "    ex_team1 (with no name)"
         << endl;

    cout << endl;
    return EXIT_SUCCESS;
}