Example #1
0
DECLARE_EXPORT void ResourceSkill::validate(Action action)
{
  // Catch null operation and resource pointers
  Skill *skill = getSkill();
  Resource *res = getResource();
  if (!skill || !res)
  {
    // Invalid load model
    if (!skill && !res)
      throw DataException("Missing resource and kill on a resourceskill");
    else if (!skill)
      throw DataException("Missing skill on a resourceskill on resource '"
          + res->getName() + "'");
    else if (!res)
      throw DataException("Missing resource on a resourceskill on skill '"
          + skill->getName() + "'");
  }

  // Check if a resourceskill with 1) identical resource, 2) identical skill and
  // 3) overlapping effectivity dates already exists
  Skill::resourcelist::const_iterator i = skill->getResources().begin();
  for (; i != skill->getResources().end(); ++i)
    if (i->getResource() == res
        && i->getEffective().overlap(getEffective())
        && &*i != this)
      break;

  // Apply the appropriate action
  switch (action)
  {
    case ADD:
      if (i != skill->getResources().end())
      {
        throw DataException("Resourceskill of '" + res->getName() + "' and '"
            + skill->getName() + "' already exists");
      }
      break;
    case CHANGE:
      throw DataException("Can't update a resourceskill");
    case ADD_CHANGE:
      // ADD is handled in the code after the switch statement
      if (i == skill->getResources().end()) break;
      throw DataException("Can't update a resourceskill");
    case REMOVE:
      // This resourceskill was only used temporarily during the reading process
      delete this;
      if (i == skill->getResources().end())
        // Nothing to delete
        throw DataException("Can't remove nonexistent resourceskill of '"
            + res->getName() + "' and '" + skill->getName() + "'");
      delete &*i;
      return;
  }
}
Example #2
0
void Test_Skill::setName()
{
    Skill testSkill;

    string name = "SkillName";
    testSkill.setName(name);

    QVERIFY(testSkill.getName() == name);
}
Example #3
0
void Character::attack(Character* character, int idSkill )
{
    Skill* skill = ObjectList::lSkill.at( idSkill );
    std::cout << "\nLe sort " << skill->getName() << " est lance par " << this->m_name <<
        " sur " << character->m_name << '\n' << skill->getPunchline() << '\n';

    switch( skill->getSkillEffect() )
    {
        case PHYS_ATT :
        {
            int thisAtt = (skill->getPower() + this->m_stat.physicalAtt);
            thisAtt = thisAtt - character->m_stat.physicalDef/4;
            if( thisAtt < 1 )
            {
                thisAtt = 1;
            }
            character->m_stat.life -= thisAtt;
            std::cout << character->m_name << " se voit inflige -" << thisAtt << "PV.\n";
            break;
        }
        case MAG_ATT :
        {
            int thisAtt = (skill->getPower() + this->m_stat.magicalAtt);
            thisAtt = thisAtt - character->m_stat.magicalDef/4;
            if( thisAtt < 1 )
            {
                thisAtt = 1;
            }
            this->m_stat.mana--;
            character->m_stat.life -= thisAtt;
            std::cout << character->m_name << " se voit inflige -" << thisAtt << "PV.\n";
            break;
        }
        case HEAL :
            this->m_stat.mana--;
            character->m_stat.life += skill->getPower();
            std::cout << character->m_name << " recoit +" << skill->getPower() << "PV.\n";
            break;

        default :
            std::cout << "TADADADAAAAMMM !!";
            std::exit(17);
    }
    std::cout << "Vie de " << character->m_name << " : " << character->m_stat.life << "PV.\n";
}
Example #4
0
Skill::Skill(const Skill& other)
{
	set(other.get());
	setName(other.getName());
	setDescription(other.getDescription());
}
Example #5
0
bool operator==(const Skill &s1, const Skill &s2) {
    return (s1.getName() == s2.getName());
}