Imps reinforce walls next to claimed ground (heroes avoid them, ~10x slower to break)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-03 07:39:39 +01:00
1 parent c508e232b0
commit a1fe02ffa6
8 files changed
+197 -13

No files matched your search

+15 -6
View File
@@ -46,9 +46,12 @@ pub enum Kind {
Core,
Portal,
Gate,
Torture,
Tower, // floor tile occupied by a defence tower (not walkable)
}
const KINDS: [Kind; 12] = [
// order matters for the packed savegame codec: only append new kinds
const KINDS: [Kind; 14] = [
Kind::Rock,
Kind::Earth,
Kind::Gold,
@@ -61,6 +64,8 @@ const KINDS: [Kind; 12] = [
Kind::Core,
Kind::Portal,
Kind::Gate,
Kind::Torture,
Kind::Tower,
];
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
@@ -93,11 +98,13 @@ pub struct Tile {
pub bed: u32, // entity id + 1 sleeping here
#[serde(rename = "v")]
pub var: u8, // texture variant
#[serde(rename = "rf", default)]
pub reinforced: bool, // wall reinforced by imps
}
impl Tile {
pub fn new(kind: Kind) -> Tile {
Tile { kind, owner: Owner::None, hp: 0.0, gold: 0, marked: false, reserved: 0, food: 0.0, bed: 0, var: 0 }
Tile { kind, owner: Owner::None, hp: 0.0, gold: 0, marked: false, reserved: 0, food: 0.0, bed: 0, var: 0, reinforced: false }
}
pub fn solid(&self) -> bool {
matches!(self.kind, Kind::Rock | Kind::Earth | Kind::Gold)
@@ -108,7 +115,7 @@ impl Tile {
pub fn walkable(&self) -> bool {
matches!(
self.kind,
Kind::Floor | Kind::Treasury | Kind::Lair | Kind::Farm | Kind::Training | Kind::Library | Kind::Portal | Kind::Gate
Kind::Floor | Kind::Treasury | Kind::Lair | Kind::Farm | Kind::Training | Kind::Library | Kind::Portal | Kind::Gate | Kind::Torture
)
}
}
@@ -429,9 +436,10 @@ impl Map {
move |i| {
let tl = &self.t[i];
match tl.kind {
Kind::Earth if tl.reinforced => Some(70),
Kind::Earth => Some(7),
Kind::Gold => Some(12),
Kind::Rock | Kind::Core => None,
Kind::Rock | Kind::Core | Kind::Tower => None,
_ => Some(1),
}
}
@@ -505,7 +513,7 @@ fn tile_record(t: &Tile) -> [u8; REC] {
let mut r = [0u8; REC];
r[0] = KINDS.iter().position(|&k| k == t.kind).unwrap_or(0) as u8;
r[1] = OWNERS.iter().position(|&o| o == t.owner).unwrap_or(0) as u8;
r[2] = t.marked as u8;
r[2] = t.marked as u8 | (t.reinforced as u8) << 1;
r[3..7].copy_from_slice(&t.hp.to_le_bytes());
r[7..11].copy_from_slice(&t.gold.to_le_bytes());
r[11..15].copy_from_slice(&t.food.to_le_bytes());
@@ -567,7 +575,8 @@ fn tiles_de<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<Tile>, D::Error> {
let t = Tile {
kind: *KINDS.get(r[0] as usize).unwrap_or(&Kind::Rock),
owner: *OWNERS.get(r[1] as usize).unwrap_or(&Owner::None),
marked: r[2] != 0,
marked: r[2] & 1 != 0,
reinforced: r[2] & 2 != 0,
hp: f32::from_le_bytes(f(3)),
gold: i32::from_le_bytes(f(7)),
food: f32::from_le_bytes(f(11)),