rjw-race-support-AsmodeusRex/generator/src/surgery.rs

139 lines
3.1 KiB
Rust

use std::collections::HashMap;
use crate::parts::{Part, PartType};
#[derive(Clone, Copy, Debug)]
struct Operation {
surgery_type: &'static str,
verbs: (&'static str, &'static str, &'static str),
}
#[derive(Clone, Debug)]
pub struct Surgery {
part: Part,
operation: Operation,
}
const SURGERY_STRING: &str = "
<RecipeDef ParentName=\"{type}\">
<defName>{type}{name}</defName>
<label>{verb.0} {label}</label>
<description>{verb.1} {label_noun}</description>
<jobString>{verb.2} {label_noun}</jobString>
<ingredients>
<li>
<filter>
<categories>
<li>Medicine</li>
</categories>
</filter>
<count>1</count>
</li>
<li>
<filter>
<thingDefs>
<li>{name}</li>
</thingDefs>
</filter>
<count>1</count>
</li>
</ingredients>
<fixedIngredientFilter>
<categories>
<li>Medicine</li>
</categories>
<thingDefs>
<li>{name}</li>
</thingDefs>
</fixedIngredientFilter>
<addsHediff>{name}</addsHediff>
</RecipeDef>";
const BREAST_SURGERIES: [Option<Operation>;3] = [
Some(Operation{
surgery_type: "MultiBreast",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "BreastSurgery",
verbs: ("attach", "Attaches", "Attaching"),
}),
None
];
const PENIS_SURGERIES: [Option<Operation>;3] = [
Some(Operation{
surgery_type: "FutaMakingF",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "MultiPenis",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "SexReassignmentP",
verbs: ("attach", "Attaches", "Attaching"),
})
];
const VAGINA_SURGERIES: [Option<Operation>;3] = [
Some(Operation{
surgery_type: "FutaMakingM",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "MultiVagina",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "SexReassignmentV",
verbs: ("attach", "Attaches", "Attaching"),
})
];
const ANUS_SURGERIES: [Option<Operation>;3] = [
Some(Operation{
surgery_type: "MultiAnus",
verbs: ("add", "Adds", "Adding"),
}),
Some(Operation{
surgery_type: "AnalSurgery",
verbs: ("attach", "Attaches", "Attaching"),
}),
None
];
pub fn enumerate_surgeries<'a>(part: &Part) -> Vec<Surgery> {
// Every part should have 2-3 relevant surgeries
let surgeries = match part.part_type {
PartType::Anus => ANUS_SURGERIES,
PartType::Breasts => BREAST_SURGERIES,
PartType::Penis => PENIS_SURGERIES,
PartType::Vagina => VAGINA_SURGERIES,
};
surgeries.iter().filter(|x| x.is_some()).map(|operation|
Surgery {
part: part.clone(),
operation: operation.unwrap()
}
).collect()
}
pub fn construct_surgery(surgery: &Surgery) -> String {
let mut s = String::from(SURGERY_STRING);
let replace = HashMap::from([
("{type}", surgery.operation.surgery_type),
("{verb.0}", surgery.operation.verbs.0),
("{verb.1}", surgery.operation.verbs.1),
("{verb.2}", surgery.operation.verbs.2),
("{name}", &surgery.part.name),
("{label}", &surgery.part.label),
("{label_noun}", &surgery.part.label_noun),
]);
for r in replace {
s = s.replace(r.0, r.1);
}
s
}