Hero waves march on the strongest master

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 20:58:46 +01:00
1 parent 988f4a3333
commit e3a9d32d61
22 files changed
+147 -22

No files matched your search

+31
View File
@@ -507,4 +507,35 @@ mod tests {
}
assert!(fought, "heroes fight the rival master");
}
#[test]
fn hero_waves_march_on_the_strongest_master() {
let mut g = (1..200u32).map(|s| Game::new_free(s, 160, 160, 1)).find(|g| g.rivals.len() == 1 && g.gate_on).unwrap();
let side = g.rivals[0].side;
let (rx, ry) = g.rivals[0].centre();
let army = |g: &mut Game, side: u8, x: f32, y: f32, n: usize| {
for k in 0..n {
let id = g.spawn(EK::Ogre, false, x + k as f32 * 0.2, y, 6);
if let Some(e) = g.ents.iter_mut().find(|e| e.id == id) {
e.side = side;
}
}
};
// the rival master is far stronger: the wave marches on him and is measured against him
g.gold = 0.0;
army(&mut g, side, rx, ry + 2.0, 8);
assert_eq!(g.wave_goal(), side);
let before = g.ents.len();
g.spawn_wave();
let heroes: Vec<&Ent> = g.ents[before..].iter().filter(|e| e.hero).collect();
assert!(!heroes.is_empty());
assert!(heroes.iter().all(|e| e.target == Some(side)), "the wave marches on the rival");
// now the player is the strongest: the next wave comes for him
let (cx, cy) = g.map.core;
army(&mut g, 0, cx as f32 + 1.5, cy as f32 + 4.0, 20);
assert_eq!(g.wave_goal(), 0);
let before = g.ents.len();
g.spawn_wave();
assert!(g.ents[before..].iter().filter(|e| e.hero).all(|e| e.target.is_none()), "the wave comes for the player");
}
}