1use crate::continent::ContinentKey;
5use crate::error::Result;
6use crate::ranking::score::Score;
7use crate::ruler::Ruler;
8use crate::world::World;
9
10impl World {
11 pub fn count_cities<R>(&self, owner: R) -> u32
12 where
13 R: Into<Ruler>,
14 {
15 self
16 .continent
17 .cities_of(owner)
18 .count()
19 .try_into()
20 .unwrap_or(u32::MAX)
21 }
22
23 pub fn get_city_score(&self, key: impl ContinentKey) -> Result<Score> {
24 let stats = self.stats.infrastructure.as_ref();
25 self.continent.city(key)?.score(stats)
26 }
27
28 pub fn rename_city(&mut self, key: impl ContinentKey, name: &str) -> Result<()> {
29 let coord = key.into_coord(self.continent.size())?;
30 let city = self.continent.city_mut(coord)?;
31 name.clone_into(city.name_mut());
32
33 self.emit_public_city_updated(coord);
34 self.emit_city_updated(coord);
35
36 Ok(())
37 }
38}