Fortresses above ground stand in a clearing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a35a903de
commit
5a8ebb984e
1 file changed
+44
@@ -89,6 +89,29 @@ impl Game {
|
||||
}
|
||||
}
|
||||
}
|
||||
// a clearing around the knights' fortresses (and anything else they hold) above ground
|
||||
let held: Vec<usize> = (0..self.map.t.len()).filter(|&i| self.map.sky(i) && self.map.t[i].owner == Owner::Hero).collect();
|
||||
let mut cleared = vec![false; self.map.t.len()];
|
||||
for &i in &held {
|
||||
let (x, y) = xy(i);
|
||||
for yy in y - 3..=y + 3 {
|
||||
for xx in x - 3..=x + 3 {
|
||||
if !inb(xx, yy) || xx < 2 || yy < 2 || xx >= w - 2 || yy >= h - 2 {
|
||||
continue;
|
||||
}
|
||||
let j = idx(xx, yy);
|
||||
if cleared[j] || !self.map.sky(j) {
|
||||
continue;
|
||||
}
|
||||
cleared[j] = true;
|
||||
let t = &mut self.map.t[j];
|
||||
if t.owner == Owner::None && matches!(t.kind, Kind::Tree | Kind::Rock) {
|
||||
t.kind = Kind::Floor;
|
||||
t.hp = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// the cave mouths run through into the dungeon: dig until open ground is reached
|
||||
for &m in &mouth_rows {
|
||||
let ex = edge(m);
|
||||
@@ -108,6 +131,8 @@ impl Game {
|
||||
}
|
||||
}
|
||||
self.recount();
|
||||
// torches on stands light the clearing at night (and look fine by day)
|
||||
self.place_all_torches();
|
||||
}
|
||||
|
||||
// the share of the map above ground (0: a dungeon map)
|
||||
@@ -139,4 +164,23 @@ mod tests {
|
||||
let goal = |i: usize| g.map.sky(i) && g.map.t[i].walkable();
|
||||
assert!(g.map.search(idx(core.0 + 1, core.1 + 3), g.map.hero_cost_as(false), goal, true).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fortresses_above_ground_stand_in_a_clearing() {
|
||||
let mut g = Game::new(22, 128, 96);
|
||||
let spec = crate::fortress::FortSpec { x: 90, y: 40, w: 15, h: 13, doors: vec![3], towers: vec![TowerKind::Arrow], tower_level: 1, guards: vec![(EK::Knight, 1)], patrols: Vec::new(), vaults: 1, vault_value: 500, shard: false, heart: false };
|
||||
g.build_fortress(&spec);
|
||||
g.add_surface(22, 0.5, 3);
|
||||
let wall = g.map.t.iter().enumerate().filter(|(i, t)| g.map.sky(*i) && t.owner == Owner::Hero && t.kind == Kind::Earth).count();
|
||||
assert!(wall > 20, "the fortress walls stand");
|
||||
// no tree right next to the walls
|
||||
for y in 37..56 {
|
||||
for x in 87..108 {
|
||||
let near = (x >= 89 && x <= 105 && y >= 39 && y <= 53) as bool;
|
||||
if near && g.map.t[idx(x, y)].owner == Owner::None {
|
||||
assert_ne!(g.map.t[idx(x, y)].kind, Kind::Tree, "tree at {},{}", x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user