()
| 2818 | |
| 2819 | #[test] |
| 2820 | fn test_healer_overcharge() { |
| 2821 | // Create the game world. |
| 2822 | let mut world = GameWorld::test_world(); |
| 2823 | |
| 2824 | // Unlock healer's overcharge ability through research. |
| 2825 | let unlock_level = 3; |
| 2826 | let rounds = 200; |
| 2827 | |
| 2828 | for _ in 0..unlock_level { |
| 2829 | let my_research = world.my_research_mut(); |
| 2830 | assert!(my_research.add_to_queue(&Branch::Healer)); |
| 2831 | for _ in 0..rounds { |
| 2832 | my_research.end_round(); |
| 2833 | } |
| 2834 | } |
| 2835 | |
| 2836 | // Unlock robot's ability through research. |
| 2837 | let unlock_level = 3; |
| 2838 | let rounds = 200; |
| 2839 | |
| 2840 | for _ in 0..unlock_level { |
| 2841 | let my_research = world.my_research_mut(); |
| 2842 | assert!(my_research.add_to_queue(&Branch::Knight)); |
| 2843 | for _ in 0..rounds { |
| 2844 | my_research.end_round(); |
| 2845 | } |
| 2846 | } |
| 2847 | |
| 2848 | // Create healer and target robots. |
| 2849 | let loc_a = MapLocation::new(Planet::Earth, 0, 0); |
| 2850 | let loc_b = MapLocation::new(Planet::Earth, 0, 1); |
| 2851 | let loc_c = MapLocation::new(Planet::Earth, 0, 20); |
| 2852 | let healer = world.create_unit(Team::Red, loc_a, UnitType::Healer).unwrap(); |
| 2853 | let robot_a = world.create_unit(Team::Red, loc_b, UnitType::Knight).unwrap(); |
| 2854 | let robot_b = world.create_unit(Team::Red, loc_c, UnitType::Knight).unwrap(); |
| 2855 | |
| 2856 | // Healer overcharge is ready. |
| 2857 | assert!(!world.is_overcharge_ready(healer)); |
| 2858 | world.end_round(); |
| 2859 | assert!(world.is_overcharge_ready(healer)); |
| 2860 | |
| 2861 | // Healer should not be able to overcharge target robot outside of range. |
| 2862 | assert!(!world.can_overcharge(healer, robot_b)); |
| 2863 | |
| 2864 | // Healer should be able to overcharge target robot within range. |
| 2865 | assert!(world.can_overcharge(healer, robot_a)); |
| 2866 | |
| 2867 | // Robot uses ability. |
| 2868 | let loc_d = MapLocation::new(Planet::Earth, 0, 2); |
| 2869 | world.move_to(robot_b, loc_d); |
| 2870 | assert!(world.javelin(robot_a, robot_b).is_ok()); |
| 2871 | assert!(!world.get_unit(robot_a).unwrap().ok_if_ability_ready().is_ok()); |
| 2872 | |
| 2873 | // Healer uses overcharge to reset robot's ablity cooldown |
| 2874 | assert!(world.overcharge(healer, robot_a).is_ok()); |
| 2875 | assert!(world.get_unit(robot_a).unwrap().ok_if_ability_ready().is_ok()); |
| 2876 | } |
| 2877 |
nothing calls this directly
no test coverage detected