mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
civ/mod.rs - replace duplicate code
This commit is contained in:
parent
51356d5fad
commit
9f0664c73b
@ -508,332 +508,151 @@ impl Civs {
|
|||||||
let mut biome_count = 0;
|
let mut biome_count = 0;
|
||||||
for biome in biomes {
|
for biome in biomes {
|
||||||
let name = match biome.0 {
|
let name = match biome.0 {
|
||||||
common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => Some(format!(
|
||||||
Some(match ctx.rng.gen_range(0..8) {
|
"{} {}",
|
||||||
0 => format!(
|
NameGen::location(&mut ctx.rng).generate_temp_forest(),
|
||||||
"{} Forest",
|
[
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
"Forest",
|
||||||
),
|
"Woodlands",
|
||||||
1 => format!(
|
"Woods",
|
||||||
"{} Woodlands",
|
"Glades",
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
"Grove",
|
||||||
),
|
"Thickets",
|
||||||
2 => format!(
|
"Weald"
|
||||||
"{} Woods",
|
]
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
.choose(&mut ctx.rng)
|
||||||
),
|
.unwrap()
|
||||||
3 => format!(
|
)),
|
||||||
"{} Glades",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
4 => format!(
|
|
||||||
"{} Grove",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
5 => format!(
|
|
||||||
"{} Glades",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
6 => format!(
|
|
||||||
"{} Thickets",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
7 => format!(
|
|
||||||
"{} Weald",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
_ => format!(
|
|
||||||
"{} Forest",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_temp_forest()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => {
|
||||||
Some(match ctx.rng.gen_range(0..9) {
|
Some(format!(
|
||||||
0 => format!(
|
"{} {}",
|
||||||
"{} Grasslands",
|
NameGen::location(&mut ctx.rng).generate_grassland(),
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
[
|
||||||
),
|
"Grasslands",
|
||||||
1 => format!(
|
"Flats",
|
||||||
"{} Flats",
|
"Greens",
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
"Plains",
|
||||||
),
|
"Meadows",
|
||||||
2 => format!(
|
"Fields",
|
||||||
"{} Greens",
|
"Heath",
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
"Steppe",
|
||||||
),
|
"Downs"
|
||||||
3 => format!(
|
]
|
||||||
"{} Plains",
|
.choose(&mut ctx.rng)
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
.unwrap()
|
||||||
),
|
))
|
||||||
4 => format!(
|
|
||||||
"{} Meadows",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
5 => format!(
|
|
||||||
"{} Fields",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
6 => format!(
|
|
||||||
"{} Heath",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
7 => format!(
|
|
||||||
"{} Prairie",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
8 => format!(
|
|
||||||
"{} Steppe",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
9 => format!(
|
|
||||||
"{} Downs",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
_ => format!(
|
|
||||||
"{} Grassland",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_grassland()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..3) {
|
|
||||||
0 => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
1 => format!("{} Blue", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
2 => format!("{} Deep", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
3 => format!(
|
|
||||||
"{} Depths",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
_ => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => Some(format!(
|
||||||
|
"{} {}",
|
||||||
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
|
["Ocean", "Blue", "Deep"].choose(&mut ctx.rng).unwrap()
|
||||||
|
)),
|
||||||
common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => {
|
||||||
Some(match ctx.rng.gen_range(0..11) {
|
Some(format!(
|
||||||
0 => format!(
|
"{} {}",
|
||||||
"{} Mountains",
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
[
|
||||||
),
|
"Mountains",
|
||||||
1 => format!("{} Range", NameGen::location(&mut ctx.rng).generate_biome()),
|
"Range",
|
||||||
2 => format!("{} Reach", NameGen::location(&mut ctx.rng).generate_biome()),
|
"Reach",
|
||||||
3 => format!(
|
"Massif",
|
||||||
"{} Massif",
|
"Rocks",
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"Cliffs",
|
||||||
),
|
"Peaks",
|
||||||
4 => format!("{} Rocks", NameGen::location(&mut ctx.rng).generate_biome()),
|
"Heights",
|
||||||
5 => format!(
|
"Bluffs",
|
||||||
"{} Cliffs",
|
"Ridge",
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"Canyon",
|
||||||
),
|
"Plateau"
|
||||||
6 => format!("{} Peaks", NameGen::location(&mut ctx.rng).generate_biome()),
|
]
|
||||||
7 => format!(
|
.choose(&mut ctx.rng)
|
||||||
"{} Heights",
|
.unwrap()
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
))
|
||||||
),
|
|
||||||
8 => format!(
|
|
||||||
"{} Bluffs",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
9 => format!("{} Ridge", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
10 => format!(
|
|
||||||
"{} Canyon",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
11 => format!(
|
|
||||||
"{} Plateau",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
_ => format!(
|
|
||||||
"{} Mountains",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => {
|
||||||
Some(match ctx.rng.gen_range(0..6) {
|
Some(format!(
|
||||||
0 => format!(
|
"{} {}",
|
||||||
"{} Snowlands",
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
[
|
||||||
),
|
"Snowlands",
|
||||||
1 => format!(
|
"Glacier",
|
||||||
"{} Glacier",
|
"Tundra",
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"Snowfields",
|
||||||
),
|
"Hills",
|
||||||
2 => format!(
|
"Highlands"
|
||||||
"{} Tundra",
|
]
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
.choose(&mut ctx.rng)
|
||||||
),
|
.unwrap()
|
||||||
3 => format!(
|
))
|
||||||
"{} Drifts",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
4 => format!(
|
|
||||||
"{} Snowfields",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
5 => format!("{} Hills", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
6 => format!(
|
|
||||||
"{} Highlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
_ => format!(
|
|
||||||
"{} Snowlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => Some(format!(
|
||||||
Some(match ctx.rng.gen_range(0..5) {
|
"{} {}",
|
||||||
0 => format!(
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
"{} Desert",
|
["Desert", "Sands", "Sandsea", "Drifts", "Dunes", "Sandfield"]
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
.choose(&mut ctx.rng)
|
||||||
),
|
.unwrap()
|
||||||
1 => format!("{} Sands", NameGen::location(&mut ctx.rng).generate_biome()),
|
)),
|
||||||
2 => format!(
|
common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => {
|
||||||
"{} Sandsea",
|
Some(format!(
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"{} {}",
|
||||||
),
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
3 => format!(
|
[
|
||||||
"{} Drifts",
|
"Swamp",
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"Swamps",
|
||||||
),
|
"Swamplands",
|
||||||
4 => format!("{} Dunes", NameGen::location(&mut ctx.rng).generate_biome()),
|
"Marsh",
|
||||||
5 => format!(
|
"Marshlands",
|
||||||
"{} Sandfield",
|
"Morass",
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
"Mire",
|
||||||
),
|
"Bog",
|
||||||
_ => format!(
|
"Snowlands"
|
||||||
"{} Desert",
|
]
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
.choose(&mut ctx.rng)
|
||||||
),
|
.unwrap()
|
||||||
})
|
))
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Swamp if biome.1.len() as u32 > 750 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..7) {
|
|
||||||
0 => format!("{} Swamp", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
1 => format!(
|
|
||||||
"{} Swamps",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
2 => format!(
|
|
||||||
"{} Swamplands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
3 => format!("{} Marsh", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
4 => format!(
|
|
||||||
"{} Marshlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
5 => format!(
|
|
||||||
"{} Morass",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
6 => format!("{} Mire", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
7 => format!("{} Bog", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
_ => format!(
|
|
||||||
"{} Snowlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..7) {
|
|
||||||
0 => format!(
|
|
||||||
"{} Jungle",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
1 => format!(
|
|
||||||
"{} Rainforest",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
2 => format!(
|
|
||||||
"{} Greatwood",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
3 => format!("{} Wilds", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
4 => format!(
|
|
||||||
"{} Wildwood",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
5 => format!(
|
|
||||||
"{} Tangle",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
6 => format!(
|
|
||||||
"{} Tanglewood",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
7 => format!("{} Bush", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
_ => format!(
|
|
||||||
"{} Jungle",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => Some(format!(
|
||||||
|
"{} {}",
|
||||||
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
|
[
|
||||||
|
"Jungle",
|
||||||
|
"Rainforest",
|
||||||
|
"Greatwood",
|
||||||
|
"Wilds",
|
||||||
|
"Wildwood",
|
||||||
|
"Tangle",
|
||||||
|
"Tanglewood",
|
||||||
|
"Bush"
|
||||||
|
]
|
||||||
|
.choose(&mut ctx.rng)
|
||||||
|
.unwrap()
|
||||||
|
)),
|
||||||
common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => {
|
common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => {
|
||||||
Some(match ctx.rng.gen_range(0..4) {
|
Some(format!(
|
||||||
0 => format!(
|
"{} {}",
|
||||||
"{} Savannah",
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
["Savannah", "Shrubland", "Sierra", "Prairie", "Lowlands"]
|
||||||
),
|
.choose(&mut ctx.rng)
|
||||||
1 => format!(
|
.unwrap()
|
||||||
"{} Shrubland",
|
))
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
2 => format!(
|
|
||||||
"{} Sierra",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
3 => format!(
|
|
||||||
"{} Prairie",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
4 => format!(
|
|
||||||
"{} Lowlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
_ => format!(
|
|
||||||
"{} Savannah",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..4) {
|
|
||||||
0 => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
1 => format!(
|
|
||||||
"{} Timberlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
2 => format!(
|
|
||||||
"{} Uplands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
3 => format!(
|
|
||||||
"{} Woodlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
4 => format!(
|
|
||||||
"{} Highlands",
|
|
||||||
NameGen::location(&mut ctx.rng).generate_biome()
|
|
||||||
),
|
|
||||||
_ => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..2) {
|
|
||||||
0 => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
1 => format!("Loch {}", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
_ => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => {
|
|
||||||
Some(match ctx.rng.gen_range(0..1) {
|
|
||||||
0 => format!("{} Pool", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
1 => format!("{} Well", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
_ => format!("{} Pond", NameGen::location(&mut ctx.rng).generate()),
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => Some(format!(
|
||||||
|
"{} {}",
|
||||||
|
NameGen::location(&mut ctx.rng).generate_biome(),
|
||||||
|
["Taiga", "Timberlands", "Uplands", "Highlands"]
|
||||||
|
.choose(&mut ctx.rng)
|
||||||
|
.unwrap()
|
||||||
|
)),
|
||||||
|
common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => Some(format!(
|
||||||
|
"{} {}",
|
||||||
|
["Lake", "Loch"].choose(&mut ctx.rng).unwrap(),
|
||||||
|
NameGen::location(&mut ctx.rng).generate()
|
||||||
|
)),
|
||||||
|
common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => Some(format!(
|
||||||
|
"{} {}",
|
||||||
|
NameGen::location(&mut ctx.rng).generate(),
|
||||||
|
["Pool", "Well", "Pond"].choose(&mut ctx.rng).unwrap()
|
||||||
|
)),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
|
Loading…
Reference in New Issue
Block a user