#include "../include/event.h"

Event::Event(std::string i_name, bool i_isGlobal, std::string i_relatedTrait)
{
    name = i_name;
    isGlobal = i_isGlobal;
    relatedTrait = i_relatedTrait;
    lethality = 0.8;
    handicap = 0.5;
    law = "normal";
    paramA = 0;
    paramB = 1;
    vmax = 10^5;
    offset = 0;
}

Event::Event(std::string i_name, bool i_isGlobal, std::string i_relatedTrait, float i_lethality, float i_handicap, std::string i_law, float i_paramA, float i_paramB, float i_vmax, float i_offset)
{
    name = i_name;
    isGlobal = i_isGlobal;
    relatedTrait = i_relatedTrait;
    lethality = i_lethality;
    handicap = i_handicap;
    law = i_law;
    paramA = i_paramA;
    paramB = i_paramB;
    vmax = i_vmax;
    offset = i_offset;
}

std::string Event::get_name()
{
    return name;
}

bool Event::get_isGlobal()
{
    return isGlobal;
}

std::string Event::get_law()
{
  return law;
}

float Event::pick_cutValue()
{
  float cutValue;
  if (law == "normal")
  {
    cutValue = sqrt(paramB)*gasdev() + paramA;
  }
  else
  {
    cutValue = paramB*pow((1-Random()), (-1/(paramA-1)));
  }
  cutValue = min(vmax, cutValue + offset);
  return cutValue;
}

std::vector<float> Event::get_params()
{
  std::vector<float> params;
  params.push_back(paramA);
  params.push_back(paramB);
  params.push_back(vmax);
  params.push_back(offset);
  return params;
}

std::string Event::get_relatedTrait()
{
    return relatedTrait; // style "T1"
}

float Event::get_lethality()
{
    return lethality;
}

float Event::get_handicap()
{
    return handicap;
}

EventOccur::EventOccur(Event e, float i_cutValue)
{
    name = e.get_name();
    relatedTrait = e.get_relatedTrait();
    cutValue = i_cutValue;
    lethality = e.get_lethality();
    handicap = e.get_handicap();
}

float EventOccur::get_cutValue()
{
    return cutValue;
}

float EventOccur::get_lethality()
{
    return lethality;
}

float EventOccur::get_handicap()
{
    return handicap;
}


std::string EventOccur::get_name()
{
    return name;
}

std::string EventOccur::get_relatedTrait()
{
    return relatedTrait; // style "T1"
}
