78 lines
1.7 KiB
Rust
78 lines
1.7 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use crate::parts::{Part, PartType};
|
|
|
|
const THINGDEF_STRING: &str = "
|
|
<ThingDef ParentName=\"rjw_BodyPartNaturalBase{type}\">
|
|
<defName>{name}</defName>
|
|
<label>{label}</label>
|
|
<description>{description}</description>
|
|
<statBases>
|
|
<MarketValue>{value}</MarketValue>
|
|
<Mass>{mass}</Mass>
|
|
</statBases>
|
|
</ThingDef>";
|
|
|
|
|
|
pub fn construct_thingdef(part: &Part) -> String {
|
|
let mut s = String::from(THINGDEF_STRING);
|
|
|
|
let ty = match part.part_type {
|
|
PartType::Anus => "Anus",
|
|
PartType::Breasts => "Breast",
|
|
PartType::Penis => "GenMale",
|
|
PartType::Vagina => "GenFemale",
|
|
};
|
|
|
|
let mass = match part.part_type {
|
|
PartType::Anus => 0.12,
|
|
PartType::Breasts => 0.5,
|
|
PartType::Penis => 0.16,
|
|
PartType::Vagina => 0.10,
|
|
};
|
|
|
|
let mut mass_mult = 1.;
|
|
|
|
for prop in &part.props {
|
|
match *prop {
|
|
// positive
|
|
"Long" => mass_mult += 0.5,
|
|
"Girthy" => mass_mult += 0.5,
|
|
"Deep" => mass_mult += 0.3,
|
|
"Knotted" => mass_mult += 0.1,
|
|
"Solid" => mass_mult += 1.,
|
|
"Multiple" => mass_mult += 0.2,
|
|
// negative
|
|
"Thin" => mass_mult -= 0.3,
|
|
"Small" => mass_mult -= 0.5,
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
let m = format!("{:.3}", mass * mass_mult);
|
|
|
|
let val = match part.name.as_str() {
|
|
// positive
|
|
"DinoPenis" => "300",
|
|
"DinoVagina" => "300",
|
|
"TentaclePenis" => "350",
|
|
// negative
|
|
"OviporeVagina" => "50",
|
|
"AedeagusPenis" => "50",
|
|
_ => "250",
|
|
};
|
|
|
|
let replace = HashMap::from([
|
|
("{type}", ty),
|
|
("{name}", &part.name),
|
|
("{label}", &part.label),
|
|
("{description}", &part.description),
|
|
("{value}", val),
|
|
("{mass}", &m),
|
|
]);
|
|
for r in replace {
|
|
s = s.replace(r.0, r.1);
|
|
}
|
|
s
|
|
}
|