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 = " {type}{name} {verb.1} {label_noun} {verb.2} {label_noun}
  • Medicine
  • 1
  • {name}
  • 1
  • Medicine
  • {name}
  • {name}
    "; const BREAST_SURGERIES: [Option;3] = [ Some(Operation{ surgery_type: "MultiBreast", verbs: ("add", "Adds", "Adding"), }), Some(Operation{ surgery_type: "BreastSurgery", verbs: ("attach", "Attaches", "Attaching"), }), None ]; const PENIS_SURGERIES: [Option;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;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;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 { // 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 }