Пример #1
0
/**
 * \brief Sets the maximum level of life of the player.
 *
 * The program exits with an error message if the specified maximum
 * life is not valid.
 *
 * \param max_life the player's maximum life
 */
void Equipment::set_max_life(int max_life) {

  Debug::check_assertion(max_life >= 0, "Invalid life amount");

  savegame.set_integer(Savegame::KEY_MAX_LIFE, max_life);

  // If the max life is reduced, make sure the current life does not exceed
  // the new maximum.
  if (get_life() > get_max_life()) {
    set_life(max_life);
  }
}
Пример #2
0
bool enemy::check() const {
    bool b=attributes->check();
    if(life>get_max_life()) {
        b=false;
        debug_log::report("enemy life>max life",warning,true,true,false);
    }
    if(animation.size()!=6) b=false;
    if(speed<=0) {
        b=false;
        debug_log::report("speed<=0",err,true,true,false);
    }
    if(position.first<0.0 || position.second<0.0 || destiny.first<0.0 || destiny.second<0.0) b=false;
    return b;
}
Пример #3
0
/**
 * \brief Sets the maximum level of life of the player.
 *
 * The program exits with an error message if the specified maximum
 * life is not valid.
 * 
 * \param max_life the player's maximum life
 */
void Equipment::set_max_life(int max_life) {

  if (max_life <= 0) {
    std::ostringstream oss;
    oss << "Illegal maximum life: " << max_life;
    Debug::die(oss.str());
  }

  savegame.set_integer(Savegame::KEY_MAX_LIFE, max_life);

  // If the max life is reduced, make sure the current life does not exceed
  // the new maximum.
  if (get_life() > get_max_life()) {
    set_life(max_life);
  }
}
Пример #4
0
/**
 * \brief Restores all the life.
 */
void Equipment::restore_all_life() {

  set_life(get_max_life());
}
Пример #5
0
/**
 * \brief Sets the current life of the player.
 *
 * If the life is lower than zero, it is replaced by zero.
 * If the life is greater than get_max_life(), it is replaced by that value.
 *
 * \param life The player's new level of life.
 */
void Equipment::set_life(int life) {

  life = std::max(0, std::min(get_max_life(), life));
  savegame.set_integer(Savegame::KEY_CURRENT_LIFE, life);
}