// Spawn system tests: activation, deactivation, territory claiming mod common; use assert2::assert; use borders_core::prelude::*; use common::{TestWorld, WorldAssertExt, WorldTestExt}; #[test] fn test_spawn_phase_activation() { let world = TestWorld::new().with_spawn_phase().with_player(NationId::ZERO, 100.0).build(); world.assert().resource_exists::("SpawnPhase"); let spawn_phase = world.resource::(); assert!(spawn_phase.active, "SpawnPhase should be active when initialized with with_spawn_phase()"); } #[test] fn test_spawn_phase_deactivation() { let mut world = TestWorld::new().with_spawn_phase().with_player(NationId::ZERO, 100.0).build(); assert!(world.resource::().active); world.deactivate_spawn_phase(); assert!(!world.resource::().active, "SpawnPhase should be inactive after deactivation"); } #[test] fn test_spawn_territory_claiming() { let player0 = NationId::ZERO; let player1 = NationId::new(1).unwrap(); let mut world = TestWorld::new().with_spawn_phase().with_player(player0, 100.0).with_player(player1, 100.0).build(); let spawn0 = U16Vec2::new(25, 25); let spawn1 = U16Vec2::new(75, 75); world.conquer_tile(spawn0, player0); world.conquer_tile(spawn1, player1); world.assert().player_owns(spawn0, player0).player_owns(spawn1, player1); assert!(world.resource::().active); } #[test] fn test_spawn_with_pre_assigned_territories() { let player0 = NationId::ZERO; let player1 = NationId::new(1).unwrap(); let spawn_territory0 = vec![U16Vec2::new(25, 25), U16Vec2::new(25, 26), U16Vec2::new(26, 25)]; let spawn_territory1 = vec![U16Vec2::new(75, 75), U16Vec2::new(75, 76), U16Vec2::new(76, 75)]; let world = TestWorld::new().with_spawn_phase().with_player(player0, 100.0).with_player(player1, 100.0).with_territory(player0, &spawn_territory0).with_territory(player1, &spawn_territory1).build(); let mut assertions = world.assert(); for tile in &spawn_territory0 { assertions = assertions.player_owns(*tile, player0); } for tile in &spawn_territory1 { assertions = assertions.player_owns(*tile, player1); } assert!(world.resource::().active); }