()
| 2691 | |
| 2692 | #[test] |
| 2693 | fn test_knight_javelin() { |
| 2694 | // Create the game world. |
| 2695 | let mut world = GameWorld::test_world(); |
| 2696 | |
| 2697 | // Unlock knight's javelin ability through research. |
| 2698 | let unlock_level = 3; |
| 2699 | let rounds = 200; |
| 2700 | |
| 2701 | for _ in 0..unlock_level { |
| 2702 | let my_research = world.my_research_mut(); |
| 2703 | assert!(my_research.add_to_queue(&Branch::Knight)); |
| 2704 | for _ in 0..rounds { |
| 2705 | my_research.end_round(); |
| 2706 | } |
| 2707 | } |
| 2708 | |
| 2709 | // Create knight and target robots |
| 2710 | let loc_a = MapLocation::new(Planet::Earth, 0, 0); |
| 2711 | let loc_b = MapLocation::new(Planet::Earth, 0, 1); |
| 2712 | let loc_c = MapLocation::new(Planet::Earth, 0, 20); |
| 2713 | let knight = world.create_unit(Team::Red, loc_a, UnitType::Knight).unwrap(); |
| 2714 | let robot_a = world.create_unit(Team::Red, loc_b, UnitType::Knight).unwrap(); |
| 2715 | let robot_b = world.create_unit(Team::Red, loc_c, UnitType::Knight).unwrap(); |
| 2716 | |
| 2717 | // Knight Javelin is ready |
| 2718 | assert!(!world.is_javelin_ready(knight)); |
| 2719 | world.end_round(); |
| 2720 | assert!(world.is_javelin_ready(knight)); |
| 2721 | |
| 2722 | // Knight should not be able to javelin target outside of range |
| 2723 | assert!(!world.can_javelin(knight, robot_b)); |
| 2724 | |
| 2725 | // Knight should be able to javelin target within range |
| 2726 | assert!(world.can_javelin(knight, robot_a)); |
| 2727 | |
| 2728 | // Javelin target. |
| 2729 | let robot_max_health = 250; |
| 2730 | let robot_damaged_health = 205; |
| 2731 | assert_eq!(world.get_unit(robot_a).unwrap().health(), robot_max_health); |
| 2732 | assert!(world.javelin(knight, robot_a).is_ok()); |
| 2733 | assert_eq!(world.get_unit(robot_a).unwrap().health(), robot_damaged_health); |
| 2734 | assert!(!world.is_javelin_ready(knight)); |
| 2735 | } |
| 2736 | |
| 2737 | #[test] |
| 2738 | fn test_mage_blink() { |
nothing calls this directly
no test coverage detected