()
| 3198 | |
| 3199 | #[test] |
| 3200 | fn test_factory_production() { |
| 3201 | let mut world = GameWorld::test_world(); |
| 3202 | let loc = MapLocation::new(Planet::Earth, 10, 10); |
| 3203 | let factory = world.create_unit(Team::Red, loc, UnitType::Factory).unwrap(); |
| 3204 | world.get_unit_mut(factory).unwrap().be_built(1000); |
| 3205 | let mage_cost = UnitType::Mage.factory_cost().unwrap(); |
| 3206 | |
| 3207 | // The factory can produce a robot only if it's not already busy. |
| 3208 | assert!(world.can_produce_robot(factory, UnitType::Mage)); |
| 3209 | assert!(world.produce_robot(factory, UnitType::Mage).is_ok()); |
| 3210 | assert!(!world.can_produce_robot(factory, UnitType::Mage)); |
| 3211 | assert_err!(world.produce_robot(factory, UnitType::Mage), GameError::FactoryBusy); |
| 3212 | assert_eq!(world.my_team().karbonite, KARBONITE_STARTING - mage_cost); |
| 3213 | |
| 3214 | // After a few rounds, the mage is added to the world. |
| 3215 | for _ in 0..world.my_unit(factory).unwrap().factory_max_rounds_left().unwrap() { |
| 3216 | world.end_round(); |
| 3217 | } |
| 3218 | assert_eq!(world.my_unit(factory).unwrap().structure_garrison().unwrap().len(), 1); |
| 3219 | assert_eq!(world.my_planet().units.len(), 2); |
| 3220 | assert_eq!(world.my_planet().units_by_loc.len(), 1); |
| 3221 | |
| 3222 | // Karbonite is a limiting factor for producing robots. |
| 3223 | assert!(world.can_produce_robot(factory, UnitType::Mage)); |
| 3224 | world.my_team_mut().karbonite = 0; |
| 3225 | assert!(!world.can_produce_robot(factory, UnitType::Mage)); |
| 3226 | } |
| 3227 | |
| 3228 | #[test] |
| 3229 | fn test_robot_attack_and_heal() { |
nothing calls this directly
no test coverage detected