Ejemplo n.º 1
0
/**
 * \brief Sets the maximum amount of money of the player.
 * \param max_money the player's maximum amount number of money
 */
void Equipment::set_max_money(int max_money) {

  Debug::check_assertion(max_money >= 0, "Invalid money amount to add");

  savegame.set_integer(Savegame::KEY_MAX_MONEY, max_money);

  // If the max money is reduced, make sure the current money does not exceed
  // the new maximum.
  if (get_money() > get_max_money()) {
    set_money(max_money);
  }
}
Ejemplo n.º 2
0
/**
 * \brief Sets the maximum amount of money of the player.
 * \param max_money the player's maximum amount number of money
 */
void Equipment::set_max_money(int max_money) {

  if (max_money <= 0) {
    std::ostringstream oss;
    oss << "Illegal maximum amount of money: " << max_money;
    Debug::die(oss.str());
  }

  savegame.set_integer(Savegame::KEY_MAX_MONEY, max_money);

  // If the max money is reduced, make sure the current money does not exceed
  // the new maximum.
  if (get_money() > get_max_money()) {
    set_money(max_money);
  }
}
Ejemplo n.º 3
0
/**
 * \brief Sets the player's current amount of money.
 *
 * If the amount is lower than zero, it is replaced by zero.
 * If the amount is greater than get_max_money(), it is replaced by that value.
 *
 * \param money The player's new amount of money.
 */
void Equipment::set_money(int money) {

  money = std::max(0, std::min(get_max_money(), money));
  savegame.set_integer(Savegame::KEY_CURRENT_MONEY, money);
}