use super::types::{
CatalystId, IngredientInput, InheritanceSource, InheritedTrait, Prerequisite,
PrerequisiteResult, QualityLevel, Recipe, SynthesisConfig, SynthesisContext, SynthesisInput,
SynthesisOutcome, SynthesizerStats, UnexpectedTrigger, UnlockedPrerequisites,
};
pub trait SynthesisPolicy {
fn calculate_success_rate(
config: &SynthesisConfig,
recipe: &Recipe,
synthesizer: &SynthesizerStats,
ingredients: &[IngredientInput],
) -> f32;
fn determine_quality(
config: &SynthesisConfig,
recipe: &Recipe,
synthesizer: &SynthesizerStats,
ingredients: &[IngredientInput],
success_roll: f32,
) -> QualityLevel;
fn check_prerequisites(
prerequisites: &[Prerequisite],
unlocked: &UnlockedPrerequisites,
) -> PrerequisiteResult;
fn determine_outcome(
config: &SynthesisConfig,
input: &SynthesisInput,
success_rate: f32,
roll: f32,
) -> SynthesisOutcome;
fn check_unexpected(
recipe: &Recipe,
ingredients: &[IngredientInput],
context: &SynthesisContext,
) -> Option<UnexpectedTrigger>;
fn check_transmutation(
recipe: &Recipe,
ingredients: &[IngredientInput],
catalysts: &[CatalystId],
) -> Option<(super::types::RecipeId, Option<CatalystId>)>;
fn determine_inheritance(
sources: &[InheritanceSource],
slots: usize,
affinity: f32,
rng: f32,
) -> Vec<InheritedTrait>;
fn calculate_failure_consumption(
config: &SynthesisConfig,
recipe: &Recipe,
success_rate: f32,
) -> f32;
fn calculate_ingredient_quality(ingredients: &[IngredientInput]) -> QualityLevel {
if ingredients.is_empty() {
return QualityLevel::Common;
}
let total: u32 = ingredients.iter().map(|i| i.quality.value() as u32).sum();
let avg = total / ingredients.len() as u32;
QualityLevel::from_value(avg as u8)
}
}