Beispiel #1
0
static int
enter_arena(unit * u, const item_type * itype, int amount, order * ord)
{
  skill_t sk;
  region *r = u->region;
  unit *u2;
  int fee = u->faction->score / 5;
  unused(ord);
  unused(amount);
  unused(itype);
  if (fee > 2000)
    fee = 2000;
  if (getplane(r) == arena)
    return -1;
  if (u->number != 1 && enter_fail(u))
    return -1;
  if (get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee) < fee
    && enter_fail(u))
    return -1;
  for (sk = 0; sk != MAXSKILLS; ++sk) {
    if (get_level(u, sk) > 1 && enter_fail(u))
      return -1;
  }
  for (u2 = r->units; u2; u2 = u2->next)
    if (u2->faction == u->faction)
      break;

  assert(!"not implemented");
/*
	for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) {
		int x = get_resource(u, res);
		if (x) {
			if (u2) {
				change_resource(u2, res, x);
				change_resource(u, res, -x);
			}
			else if (enter_fail(u)) return -1;
		}
	}
*/
  if (get_money(u) > fee) {
    if (u2)
      change_money(u2, get_money(u) - fee);
    else if (enter_fail(u))
      return -1;
  }
  ADDMSG(&u->faction->msgs, msg_message("arena_enter_fail", "region unit",
      u->region, u));
  use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE, 1);
  use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee);
  set_money(u, 109);
  fset(u, UFL_ANON_FACTION);
  move_unit(u, start_region[rng_int() % 6], NULL);
  return 0;
}
Beispiel #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) {

  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);
  }
}
Beispiel #3
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);
  }
}
Beispiel #4
0
static void guardian_faction(plane * pl, int id)
{
  region *r;
  faction *f = findfaction(id);

  if (!f) {
    f = calloc(1, sizeof(faction));
    f->banner = _strdup("Sie dienen dem großen Wyrm");
    f->passw = _strdup(itoa36(rng_int()));
    set_email(&f->email, "*****@*****.**");
    f->name = _strdup("Igjarjuks Kundschafter");
    f->race = new_race[RC_ILLUSION];
    f->age = turn;
    f->locale = find_locale("de");
    f->options =
      want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) |
      want(O_DEBUG);

    f->no = id;
    addlist(&factions, f);
    fhash(f);
  }
  if (f->race != new_race[RC_ILLUSION]) {
    assert(!"guardian id vergeben");
    exit(0);
  }
  f->lastorders = turn;
  f->alive = true;
  for (r = regions; r; r = r->next)
    if (getplane(r) == pl && rterrain(r) != T_FIREWALL) {
      unit *u;
      freset(r, RF_ENCOUNTER);
      for (u = r->units; u; u = u->next) {
        if (u->faction == f)
          break;
      }
      if (u)
        continue;
      u = createunit(r, f, 1, new_race[RC_GOBLIN]);
      set_string(&u->name, "Igjarjuks Auge");
      set_item(u, I_RING_OF_INVISIBILITY, 1);
      set_order(&u->thisorder, NULL);
      fset(u, UFL_ANON_FACTION);
      set_money(u, 1000);
    }
}
Beispiel #5
0
void BuyGold::MergeFrom(const BuyGold& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_id()) {
      set_id(from.id());
    }
    if (from.has_name()) {
      set_name(from.name());
    }
    if (from.has_describ()) {
      set_describ(from.describ());
    }
    if (from.has_gold_number()) {
      set_gold_number(from.gold_number());
    }
    if (from.has_money()) {
      set_money(from.money());
    }
    if (from.has_localname()) {
      set_localname(from.localname());
    }
  }
}
Beispiel #6
0
/**
 * \brief Removes some money from the player.
 *
 * If the money reaches zero, no more money is removed.
 *
 * \param money_to_remove Amount of money to remove.
 * Must be positive of zero.
 */
void Equipment::remove_money(int money_to_remove) {

  Debug::check_assertion(money_to_remove >= 0, "Invalid money amount to remove");

  set_money(get_money() - money_to_remove);
}
Beispiel #7
0
/**
 * \brief Adds some money to the player.
 *
 * If the maximum amount of money is reached, no more money is added.
 *
 * \param money_to_add Amount of money to add.
 * Must be positive of zero.
 */
void Equipment::add_money(int money_to_add) {

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

  set_money(get_money() + money_to_add);
}
Beispiel #8
0
/**
 * \brief Removes some money from the player.
 *
 * If the money reaches zero, no more money is removed.
 *
 * \param money_to_remove amount of money to remove
 */
void Equipment::remove_money(int money_to_remove) {

  set_money(get_money() - money_to_remove);
}
Beispiel #9
0
/**
 * \brief Adds some money to the player.
 *
 * If the maximum amount of money is reached, no more money is added.
 * 
 * \param money_to_add amount of money to add
 */
void Equipment::add_money(int money_to_add) {

  set_money(get_money() + money_to_add);
}
Beispiel #10
0
void chaos(region * r)
{
  if (rng_int() % 100 < 8) {
    switch (rng_int() % 3) {
      case 0:                  /* Untote */
        if (!fval(r->terrain, SEA_REGION)) {
          unit *u = random_unit(r);
          if (u && playerrace(u_race(u))) {
            ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
            u_setfaction(u, get_monsters());
            u_setrace(u, get_race(RC_GHOUL));
          }
        }
        break;
      case 1:                  /* Drachen */
        if (random_unit(r)) {
          int mfac = 0;
          unit *u;
          switch (rng_int() % 3) {
            case 0:
              mfac = 100;
              u =
                createunit(r, get_monsters(), rng_int() % 8 + 1,
                get_race(RC_FIREDRAGON));
              break;
            case 1:
              mfac = 500;
              u =
                createunit(r, get_monsters(), rng_int() % 4 + 1,
                get_race(RC_DRAGON));
              break;
            default:
              mfac = 1000;
              u =
                createunit(r, get_monsters(), rng_int() % 2 + 1,
                get_race(RC_WYRM));
              break;
          }
          if (mfac)
            set_money(u, u->number * (rng_int() % mfac));
          fset(u, UFL_ISNEW | UFL_MOVED);
        }
      case 2:                  /* Terrainveränderung */
        if (!fval(r->terrain, FORBIDDEN_REGION)) {
          if (!fval(r->terrain, SEA_REGION)) {
            direction_t dir;
            for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
              region *rn = rconnect(r, dir);
              if (rn && fval(rn->terrain, SEA_REGION))
                break;
            }
            if (dir != MAXDIRECTIONS) {
              ship *sh = r->ships;
              unit **up;

              while (sh) {
                ship *nsh = sh->next;
                float dmg =
                  get_param_flt(global.parameters, "rules.ship.damage.atlantis",
                  0.50);
                damage_ship(sh, dmg);
                if (sh->damage >= sh->size * DAMAGE_SCALE) {
                  remove_ship(&sh->region->ships, sh);
                }
                sh = nsh;
              }

              for (up = &r->units; *up;) {
                unit *u = *up;
                if (u_race(u) != get_race(RC_SPELL) && u->ship == 0 && !canfly(u)) {
                  ADDMSG(&u->faction->msgs, msg_message("tidalwave_kill",
                      "region unit", r, u));
                  remove_unit(up, u);
                }
                if (*up == u)
                  up = &u->next;
              }
              ADDMSG(&r->msgs, msg_message("tidalwave", "region", r));

              while (r->buildings) {
                remove_building(&r->buildings, r->buildings);
              }
              terraform_region(r, newterrain(T_OCEAN));
            }
          } else {
            direction_t dir;
            for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
              region *rn = rconnect(r, dir);
              if (rn && fval(rn->terrain, SEA_REGION))
                break;
            }
            if (dir != MAXDIRECTIONS) {
              terraform_region(r, chaosterrain());
            }
          }
        }
    }
  }
}