MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / test_mage_blink

Function test_mage_blink

battlecode-engine/src/world.rs:2738–2776  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2736
2737 #[test]
2738 fn test_mage_blink() {
2739 // Create the game world.
2740 let mut world = GameWorld::test_world();
2741
2742 // Unlock mage's blink ability through research.
2743 let unlock_level = 4;
2744 let rounds = 200;
2745
2746 for _ in 0..unlock_level {
2747 let my_research = world.my_research_mut();
2748 assert!(my_research.add_to_queue(&Branch::Mage));
2749 for _ in 0..rounds {
2750 my_research.end_round();
2751 }
2752 }
2753
2754 // Create mage.
2755 let loc_a = MapLocation::new(Planet::Earth, 0, 0);
2756 let loc_b = MapLocation::new(Planet::Earth, 0, 1);
2757 let loc_c = MapLocation::new(Planet::Earth, 0, 20);
2758 let mage = world.create_unit(Team::Red, loc_a, UnitType::Mage).unwrap();
2759
2760 // Mage blink is ready.
2761 assert!(!world.is_blink_ready(mage));
2762 world.end_round();
2763 assert!(world.is_blink_ready(mage));
2764
2765 // Mage should not be able to blink to target location outside of range.
2766 assert!(!world.can_blink(mage, loc_c));
2767
2768 // Mage should be able to blink to target location within range.
2769 assert!(world.can_blink(mage, loc_b));
2770
2771 // Blink moves mage to new location.
2772 assert_eq!(world.get_unit(mage).unwrap().location(), OnMap(loc_a));
2773 assert!(world.blink(mage, loc_b).is_ok());
2774 assert_eq!(world.get_unit(mage).unwrap().location(), OnMap(loc_b));
2775 assert!(!world.is_blink_ready(mage));
2776 }
2777
2778 #[test]
2779 fn test_ranger_snipe() {

Callers

nothing calls this directly

Calls 3

my_research_mutMethod · 0.80
create_unitMethod · 0.80
end_roundMethod · 0.45

Tested by

no test coverage detected