Drawbridges (down, up, automatic), frost spell and obsidian over cooled lava

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 21:52:12 +01:00
1 parent 76c23a06f0
commit 34b4640d85
32 files changed
+869 -31

No files matched your search

+32 -5
View File
@@ -68,8 +68,15 @@ pub enum Kind {
GuardPost, // room: creatures hold the position
Arena, // room: sparring
Altar, // room: sacrifices
Drawbridge, // bridge that can be raised (res: see DB_RAISED, DB_AUTO, DB_LAVA)
Obsidian, // lava cooled by frost: walkable until it melts again
}
// drawbridge state in Tile::res
pub const DB_RAISED: u8 = 1; // raised: nobody can cross
pub const DB_AUTO: u8 = 2; // rises by itself when enemies come near
pub const DB_LAVA: u8 = 4; // spans lava (stone), else water (wood)
// options for the map generator (campaign missions)
#[derive(Clone, Debug)]
pub struct GenOpts {
@@ -96,7 +103,7 @@ pub struct River {
}
// order matters for the packed savegame codec: only append new kinds
const KINDS: [Kind; 34] = [
const KINDS: [Kind; 36] = [
Kind::Rock,
Kind::Earth,
Kind::Gold,
@@ -131,6 +138,8 @@ const KINDS: [Kind; 34] = [
Kind::GuardPost,
Kind::Arena,
Kind::Altar,
Kind::Drawbridge,
Kind::Obsidian,
];
// treasures (veins, treasury content, imp loads): 0 gold, 1 silver, 2 ruby, 3 diamond
@@ -151,6 +160,18 @@ pub enum Owner {
const OWNERS: [Owner; 6] = [Owner::None, Owner::Player, Owner::Hero, Owner::Rival1, Owner::Rival2, Owner::Rival3];
impl Owner {
// the side of a ground owner (255: nobody)
pub fn side(self) -> u8 {
match self {
Owner::Player => 0,
Owner::Hero => 1,
Owner::Rival1 => 2,
Owner::Rival2 => 3,
Owner::Rival3 => 4,
Owner::None => 255,
}
}
pub fn of_side(side: u8) -> Owner {
match side {
0 => Owner::Player,
@@ -240,20 +261,26 @@ impl Tile {
| Kind::GuardPost
| Kind::Arena
| Kind::Altar
)
| Kind::Obsidian
) || (self.kind == Kind::Drawbridge && self.res & DB_RAISED == 0)
}
// river tiles (open, but nobody can walk there)
pub fn liquid(&self) -> bool {
matches!(self.kind, Kind::Water | Kind::Lava)
}
pub fn bridge(&self) -> bool {
matches!(self.kind, Kind::Bridge | Kind::LavaBridge)
matches!(self.kind, Kind::Bridge | Kind::LavaBridge | Kind::Drawbridge)
}
// the river below a bridge or river tile
pub fn raised(&self) -> bool {
self.kind == Kind::Drawbridge && self.res & DB_RAISED != 0
}
// the river below a bridge or river tile (obsidian: the lava under the crust)
pub fn river(&self) -> Option<Kind> {
match self.kind {
Kind::Water | Kind::Bridge => Some(Kind::Water),
Kind::Lava | Kind::LavaBridge => Some(Kind::Lava),
Kind::Lava | Kind::LavaBridge | Kind::Obsidian => Some(Kind::Lava),
Kind::Drawbridge if self.res & DB_LAVA != 0 => Some(Kind::Lava),
Kind::Drawbridge => Some(Kind::Water),
_ => None,
}
}