From 64bb8b476b525706d08d00be7c6f6cc397606c06 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 23:55:21 +0400 Subject: feat(ai): carry ore from clan mines to storage Resolve the stock transport order against the newly produced unit. Move between owned endpoints and limit transfers by rate, source stock and destination space. The window logged the first departure and the stock simulation completed an unloading cycle. Native roster selection was called directly. Port approaches and rates remain approximations. --- crates/fparkan-runtime/src/clan_problem_conditions.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'crates/fparkan-runtime/src/clan_problem_conditions.rs') diff --git a/crates/fparkan-runtime/src/clan_problem_conditions.rs b/crates/fparkan-runtime/src/clan_problem_conditions.rs index bace9ec6..00d39173 100644 --- a/crates/fparkan-runtime/src/clan_problem_conditions.rs +++ b/crates/fparkan-runtime/src/clan_problem_conditions.rs @@ -8,6 +8,7 @@ pub(super) enum Condition { BuildingCaptured(ObjectHandle), GroupDestroyed, GroupIdle, + TransportInactive(ObjectHandle), } impl Condition { @@ -17,6 +18,7 @@ impl Condition { clan: OwnerId, patrol: Option<&UnitPatrol>, group: Option<&CombatGroup>, + transport_active: impl Fn(ObjectHandle) -> bool, ) -> bool { let live = |unit| registration_sequence(world, unit).is_ok_and(|sequence| sequence.is_some()); @@ -30,6 +32,7 @@ impl Condition { Self::GroupDestroyed => { group.is_none_or(|group| group.members.iter().all(|&unit| !live(unit))) } + Self::TransportInactive(unit) => !live(unit) || !transport_active(unit), Self::GroupIdle => group.is_none_or(|group| { group.members.iter().all(|&unit| { !live(unit) || patrol.is_none_or(|patrol| !patrol.is_patrolling(unit)) @@ -53,13 +56,13 @@ mod tests { register_object(&mut world, target).unwrap(); let clan = OwnerId(1); set_owner(&mut world, target, Some(OwnerId(0))).unwrap(); - assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None)); - assert!(!Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None)); + assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); + assert!(!Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None, |_| false)); set_owner(&mut world, target, Some(clan)).unwrap(); - assert!(Condition::BuildingCaptured(target).met(&world, clan, None, None)); + assert!(Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); fparkan_world::request_delete(&mut world, target).unwrap(); fparkan_world::step(&mut world, &fparkan_world::InputSnapshot).unwrap(); - assert!(Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None)); - assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None)); + assert!(Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None, |_| false)); + assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); } } -- cgit v1.2.3