Esempio n. 1
0
QString GeoLocation::translatedName() const {
    QString context;
    if( province().isEmpty() ) {
        context = QString("City in %1").arg(country());
    } else {
        context = QString("City in %1 %2").arg(province(), country());
    }
    return Name.isEmpty() ? QString() : i18nc(context.toUtf8().data(), Name.toUtf8().data());
}
Esempio n. 2
0
int
is_port_city(int where)
{
  int p;
  int n, s, e, w;

  if (subkind(where) != sub_city)
    return FALSE;

  assert(loc_depth(where) == LOC_subloc);

  p = province(where);

  if (subkind(p) == sub_mountain)
    return FALSE;

  n = location_direction(p, DIR_N);
  s = location_direction(p, DIR_S);
  e = location_direction(p, DIR_E);
  w = location_direction(p, DIR_W);

  if ((n && subkind(n) == sub_ocean) ||
      (s && subkind(s) == sub_ocean) ||
      (e && subkind(e) == sub_ocean) || (w && subkind(w) == sub_ocean))
    return TRUE;

  return FALSE;
}
Esempio n. 3
0
QString GeoLocation::fullName() const {
    if ( province().isEmpty() ) {
        return QString("%1, %2").arg(translatedName(), translatedCountry());
    } else {
        return QString("%1, %2, %3").arg(translatedName(), translatedProvince(), translatedCountry());
    }
}
Esempio n. 4
0
QString GeoLocation::fullName() const {
	QString s;
	if ( province().isEmpty() ) {
		s = translatedName() + ", " + translatedCountry();
	} else {
		s = translatedName() + ", " + translatedProvince() + ", " + translatedCountry();
	}
	
	return s;
}
Esempio n. 5
0
void
scry_show_where(int who, int target)
{

  if (crosses_ocean(who, target)) {
    out(who, "%s is in %s.", just_name(region(target)));
    return;
  }

  out(who, "%s is in %s.", box_name(province(target)));
}
Esempio n. 6
0
int
los_province_distance(int a, int b)
{
  int ra, rb, r1, r2;
  int ca, cb, c1, c2;
  int d1, d2;

  a = province(a);
  b = province(b);

  ra = region_row(a) - 1;
  rb = region_row(b) - 1;
  ca = region_col(a) - 1;
  cb = region_col(b) - 1;

  r1 = min(ra, rb);
  r2 = max(ra, rb);
  c1 = min(ca, cb);
  c2 = max(ca, cb);

  /* no wrap N-S */

  d1 = r2 - r1;
  if (d1 > (r1 + max_map_row) - r2)
    d1 = (r1 + max_map_row) - r2;

  d2 = c2 - c1;
  if (d2 > (c1 + max_map_col) - c2)
    d2 = (c1 + max_map_col) - c2;

#if 1
  return d1 + d2;               /* since there is no diagonal movement */
#else
  d1 *= d1;
  d2 *= d2;

  return my_sqrt(d1 + d2);
#endif
}
Esempio n. 7
0
static int
province_owner(int where)
{
	int prov = province(where);
	int city;
	int castle;

	city = city_here(prov);

	castle = subloc_here(prov, sub_castle);
	if (castle == 0 && city)
		castle = subloc_here(city, sub_castle);

	if (castle)
		return first_character(castle);

	return 0;
}
ProvinceCollection::ProvinceCollection(const std::set<int>& provinceIDs,
                                       const std::string& provincesHistoryPath,
                                       const std::string& provincesNamesPath,
                                       const std::string& localisationPath)
{
  auto provinceNames = SimpleYaml::ParseYamlFile(localisationPath + "prov_names_l_english.yml");
  auto provinceAdjectives = SimpleYaml::ParseYamlFile(localisationPath + "prov_names_adj_l_english.yml");

  std::map<int, std::map<std::string, std::string>> cultureProvinceNames;
  auto provinceNamesFileNames = FileUtilities::GetAllFilesInFolder(provincesNamesPath);
  for (const auto& provinceNamesFileName : provinceNamesFileNames)
  {
    auto culture = provinceNamesFileName.substr(0, provinceNamesFileName.find('.'));
    auto provinceNamesNode = ParadoxNode::ParseFromFile(provincesNamesPath + provinceNamesFileName);
    for (const auto& provinceNameNode : provinceNamesNode->GetChildren())
    {
      auto provinceID = std::stoi(provinceNameNode->GetKey());
      const auto& cultureProvinceName = provinceNameNode->GetValue();
      cultureProvinceNames[provinceID].emplace(culture, cultureProvinceName);
    }
  }

  auto provinceFileNames = FileUtilities::GetAllFilesInFolder(provincesHistoryPath);
  for (const auto& provinceFileName : provinceFileNames)
  {
    int provinceID = std::stoi(provinceFileName);
    if (provinceIDs.find(provinceID) != provinceIDs.end())
    {
      auto splitPos = provinceFileName.find('-');
      auto extPos = provinceFileName.rfind('.');
      if (splitPos != std::string::npos && extPos != std::string::npos)
      {
        auto provinceName = provinceNames["PROV" + std::to_string(provinceID)];
        auto provinceAdjective = provinceAdjectives["PROV_ADJ" + std::to_string(provinceID)];
        auto provinceFullPath = provincesHistoryPath + provinceFileName;
        Province province(provinceID, provinceName, provinceAdjective, cultureProvinceNames[provinceID], *ParadoxNode::ParseFromFile(provinceFullPath));
        provinces.emplace(provinceID, std::move(province));
        provinceHistoryFileNames[provinceID] = provinceFileName;
      }
    }
  }
}
Esempio n. 9
0
/*
 *  Fri Oct  9 18:19:22 1998 -- Scott Turner
 *
 *  Destroying monster.
 *
 */
int
v_art_destroy(struct command *c)
{
  int item = c->use_skill;
  int where = province(subloc(c->who));
  int num;
  struct item_ent *t;
  int kind;

  assert(rp_item_artifact(item));
  kind = rp_item_artifact(item)->param1;

  if (rp_item_artifact(item)->uses < 1) {
    wout(c->who, "Nothing happens.");
    wout(c->who, "%s vanishes!", box_name(item));
    destroy_unique_item(c->who, item);
    return TRUE;
  };

  log_write(LOG_SPECIAL, "Destroy monster artifact %s used by %s",
            box_code_less(item), box_code_less(player(c->who)));

  wout(c->who, "A golden glow suffuses the province.");
  wout(where, "A golden glow suffuses the province.");

  loop_all_here(where, num) {
    wout(num, "A golden glow suffuses the province.");

    loop_inv(num, t) {
      if (t->item == kind) {
        wout(num, "%s vanished!", box_name_qty(t->item, t->qty));
        consume_item(num, t->item, t->qty);
      }
    }
    next_inv;

    if (subkind(num) == sub_ni && noble_item(num) == kind) {
      kill_char(num, MATES, S_body);
    }
  }
Esempio n. 10
0
char *
loc_inside_string(int where)
{
  char *reg_name;

  if (loc_depth(where) == LOC_build) {
    if (subkind(loc(where)) == sub_ocean)
      return sout(", in %s", box_name(province(where)));

    if (loc_depth(loc(where)) == LOC_province)
      return sout(", in province %s", box_name(province(where)));

    return sout(", in %s", box_name(province(where)));
  }
  else if (loc_depth(where) == LOC_subloc) {
    if (subkind(province(where)) == sub_ocean)
      return sout(", in %s", box_name(province(where)));
    else if (!valid_box(province(where)))
      return sout(", adrift in the Cosmos");
    else
      return sout(", in province %s", box_name(province(where)));
  }
  else if (subkind(where) == sub_ocean) {
    reg_name = name(region(where));

    if (reg_name && *reg_name)
      return sout(", in %s", reg_name);
    return "";
  }
  else {
    reg_name = name(region(where));

    if (reg_name && *reg_name)
      return sout(", in %s", reg_name);

    return "";
  }
}
Esempio n. 11
0
int
exit_distance(int loc1, int loc2)
{
  int dist;
  int w_d;                      /* where depth */
  int d_d;                      /* dest depth */

  if (subkind(loc1) == sub_hades_pit || subkind(loc2) == sub_hades_pit)
    return 28;

  if (loc_depth(loc1) > loc_depth(loc2)) {
    int tmp;

    tmp = loc1;
    loc1 = loc2;
    loc2 = tmp;
  }

  w_d = loc_depth(loc1);
  d_d = loc_depth(loc2);

  if (d_d == LOC_build)
    return 0;
  if (d_d == LOC_subloc)
    return 1;

#if 0
/*
 *  water-land links
 */

  if (subkind(loc1) == sub_ocean && subkind(loc2) != sub_ocean) {
    if (loc_sea_lane(loc1))
      return 2;
    return 3;
  }

  if (subkind(loc1) != sub_ocean && subkind(loc2) == sub_ocean) {
    if (loc_sea_lane(loc2))
      return 2;
    return 3;
  }

#else
/*
 *  water-land links are distance=2
 */

  if (subkind(loc1) == sub_ocean && subkind(loc2) != sub_ocean)
    return 2;

  if (subkind(loc1) != sub_ocean && subkind(loc2) == sub_ocean)
    return 2;
#endif

/*
 *  Linked sublocs between regions
 */

  if (province(loc1) != province(loc2)) {
    loc1 = province(loc1);
    loc2 = province(loc2);
  }

  switch (subkind(loc2)) {
  case sub_ocean:
    if (loc_sea_lane(loc1) && loc_sea_lane(loc2))
      dist = 2;
    else
      dist = 3;
    break;

  case sub_mountain:
    dist = 10;
    break;
  case sub_forest:
    dist = 8;
    break;
  case sub_swamp:
    dist = 14;
    break;
  case sub_desert:
    dist = 8;
    break;
  case sub_plain:
    dist = 7;
    break;
  case sub_under:
    dist = 7;
    break;
  case sub_cloud:
    dist = 7;
    break;
  case sub_tunnel:
    dist = 5;
    break;
  case sub_chamber:
    dist = 5;
    break;

  default:
    fprintf(stderr,
            "exit_distance: subkind=%s, loc1=%d, loc2=%d, "
            "w_d=%d, d_d=%d\n",
            subkind_s[subkind(loc2)], loc1, loc2, w_d, d_d);
    assert(FALSE);
  }

  return dist;
}
Esempio n. 12
0
int
v_bird_spy(struct command *c)
{
	int targ = c->a;
	int where = subloc(c->who);
	struct exit_view *v;

	if (!has_holy_symbol(c->who)) {
	  wout(c->who, "A holy symbol is required to bird spy.");
	  return FALSE;
	};

	if (!has_piety(c->who, skill_piety(c->use_skill))) {
	  wout(c->who, "You don't have the piety required to use that prayer.");
	  return FALSE;
	};

	if (is_ship(where))
		where = loc(where);

	if (numargs(c) < 1)
	{
		wout(c->who, "Specify what location the bird should spy on.");
		return FALSE;
	}

	if (!is_loc_or_ship(c->a))
	{
		v = parse_exit_dir(c, where, sout("use %d", sk_bird_spy));

		if (v == NULL)
			return FALSE;

		targ = v->destination;
	}

	if (province(targ) != province(c->who))
	{
		struct exit_view **l;
		int i;
		int okay = FALSE;

		l = exits_from_loc(c->who, where);

		for (i = 0; i < ilist_len(l); i++)
			if (l[i]->destination == targ)
				okay = TRUE;

		if (!okay)
		{
			wout(c->who, "The location to be spied upon must be "
				"a sublocation in the same province or a "
				"neighboring location.");
			return FALSE;
		}
	}

	c->d = targ;

	return TRUE;
}
Esempio n. 13
0
void
location_production()
{
  int where;
  int i, enclosed;
  int terr, encl_terr;
  int has_city;
  float pop_grow = 0.0;
  int pop_limit = 200, pop, dpop = 0;

  loop_loc(where) {
    terr = subkind(where);
    has_city = 0;

    for (i = 0; terr_prod[i].terr; i++)
      if (terr_prod[i].terr == terr) {
        replenish(where, terr_prod[i].item, terr_prod[i].qty,
                  terr_prod[i].max);
      }

    /*
     *  Mon Sep 16 11:42:22 1996 -- Scott Turner
     *
     *  Now check for production from enclosed locations...
     *
     */
    loop_here(where, enclosed) {
      encl_terr = subkind(enclosed);
      if (encl_terr == sub_city)
        has_city = 1;
      for (i = 0; terr_prod2[i].terr; i++)
        if (terr_prod2[i].terr == encl_terr) {
          replenish(where, terr_prod2[i].item, terr_prod2[i].qty,
                    terr_prod2[i].max);
        };
    }
    next_here;

    /*
     *  First limit poppy fields to normal production level.
     *  Then double opium if poppy field was specially tended.
     */
    if (terr == sub_poppy_field) {
      int n;

      n = has_item(where, item_opium);
      if (n > POPPY_OPIUM)
        consume_item(where, item_opium, n - POPPY_OPIUM);

      if (rp_misc(where) && rp_misc(where)->opium_double) {
        rp_misc(where)->opium_double = FALSE;
        gen_item(where, item_opium, has_item(where, item_opium));
      }
    }

    if (terr == sub_island ||
        (loc_depth(where) == LOC_province && has_ocean_access(where)))
      replenish(where, item_flotsam, 30, 30);

    /*
     *  Sun Dec  1 10:34:41 1996 -- Scott Turner
     *
     *  Peasant production.  Depends upon the location (and
     *  whether it contains a city).
     *
     *  Has_city is set up above...
     *
     *  Tue Sep 22 13:20:18 1998 -- Scott Turner
     *
     *  Faery ought not have peasants.  It should have (I guess)
     *  elf peasants, although what you can do with those is
     *  open to conjecture :-)
     *
     */
    if (pop = has_item(where, item_peasant)) {
      if (has_city) {
        pop_grow = 0.03;
        pop_limit = 10000;
      }
      else {
        switch (terr) {
        case sub_plain:
        case sub_forest:
          pop_grow = 0.01;
          pop_limit = 1000;
          break;
        case sub_mountain:
        case sub_swamp:
          pop_grow = 0.005;
          pop_limit = 1000;
          break;
        default:
          pop_grow = 0.000;
          pop_limit = 500;
          break;
        };
      };

      /*
       *  Might be an effect here.
       *
       */
      if (get_effect(where, ef_grow, 0, 0)) {
        wout(where, "The peasants seem particularly happy this month.");
        pop_grow += 0.02;
      };

      dpop = pop * pop_grow;
      if (pop_grow > 0.0 && dpop < 1)
        dpop = 1;
      /*
       *  Lose population at a reasonable rate.
       *
       */
      if (pop > pop_limit)
        dpop = -(pop - pop_limit) / 10;

      if (p_subloc(province(where))->loot && dpop > 0) {
        wout(where,
             "Pillaging traumatizes the population and no growth occurs.");
      }
      else if (dpop > 0) {
        if (pop > 100)
          wout(where, "The population grows by %s peasant%s.",
               nice_num(dpop), add_s(dpop));
        gen_item(where, item_peasant, dpop);
      }
      else {
        if (pop > 100)
          wout(where, "Overcrowding causes %s peasant death%s.",
               nice_num(-dpop), add_s(-dpop));
        consume_item(where, item_peasant, -dpop);
      };
    };

    /*
     *  Sat Apr 18 16:57:53 1998 -- Scott Turner
     *
     *  Special case for gold production from peasants.
     *  They generate 1 gold per 20 peasants (1/10 in cities)
     *  which accumulates to be removed by various means.
     *
     *  Only in civilized (> 100) provinces
     */
    if ((pop = has_item(where, item_peasant)) > 100) {
      if (has_city) {
        dpop = pop * 0.10;
      }
      else {
        dpop = pop * 0.05;
      };
      gen_item(where, item_gold, dpop);
    };
  }