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

+41 -4
View File
@@ -174,13 +174,14 @@ pub enum Tool {
Tower(TowerKind),
Bridge,
Steel,
Drawbridge,
Trap(crate::traps::TrapKind),
Spell(crate::spells::Spell),
Order(u8), // 0 attack, 1 guard
}
// New tools are appended so that existing key bindings ("tool<i>") keep their meaning
pub const TOOLS: [Tool; 47] = [
pub const TOOLS: [Tool; 49] = [
Tool::Dig,
Tool::Hand,
Tool::Room(0),
@@ -228,6 +229,8 @@ pub const TOOLS: [Tool; 47] = [
Tool::Room(13),
Tool::Order(0),
Tool::Order(1),
Tool::Drawbridge,
Tool::Spell(crate::spells::Spell::Freeze),
];
@@ -259,7 +262,7 @@ pub fn tool_info(t: Tool) -> ToolInfo {
Tool::Trap(k) => (k.id(), I_TRAPS + crate::traps::TRAP_KINDS.iter().position(|&t| t == k).unwrap_or(0) as u32, None),
Tool::Order(0) => ("order_attack", I_ORDERS, None),
Tool::Order(_) => ("order_guard", I_ORDERS + 1, None),
Tool::Spell(sp) => (sp.id(), I_SPELLS + crate::spells::SPELLS.iter().position(|&t| t == sp).unwrap_or(0) as u32, None),
Tool::Spell(sp) => (sp.id(), crate::spells::spell_icon(sp), None),
Tool::Tower(TowerKind::Arrow) => ("arrow", I_ARROW, None),
Tool::Tower(TowerKind::Cannon) => ("cannon", I_CANNON, None),
Tool::Tower(TowerKind::Magic) => ("magic", I_MAGIC, None),
@@ -270,6 +273,7 @@ pub fn tool_info(t: Tool) -> ToolInfo {
Tool::Heal => ("heal", I_HEAL, None),
Tool::Summon => ("summon", I_SUMMON, None),
Tool::Bridge => ("bridge", I_BRIDGE, None),
Tool::Drawbridge => ("drawbridge", I_DRAWBRIDGE, None),
Tool::Steel => ("steel", I_STEEL, None),
};
let name = match room {
@@ -285,6 +289,7 @@ pub fn tool_cost_static(t: Tool) -> String {
Tool::Spell(sp) => trf("cost.mana", &[(sp.cost() as i32).to_string()]),
Tool::Trap(k) => trf("cost.work", &[(k.work() as i32).to_string()]),
Tool::Bridge => trf("cost.bridge", &[BRIDGE_COST[0].to_string(), BRIDGE_COST[1].to_string()]),
Tool::Drawbridge => trf("cost.gold_tile", &[DRAWBRIDGE_COST.to_string()]),
Tool::Steel => trf("cost.steel", &[STEEL_COST[0].to_string(), STEEL_COST[1].to_string()]),
Tool::Tower(TowerKind::Rune) => {
let s = tower_stats(TowerKind::Rune);
@@ -310,6 +315,7 @@ pub fn tool_cost(t: Tool, g: &Game) -> String {
Tool::Heal => trf("cost.mana", &["60".into()]),
Tool::Summon => trf("cost.mana", &[(g.summon_cost() as i32).to_string()]),
Tool::Bridge => trf("cost.bridge", &[BRIDGE_COST[0].to_string(), BRIDGE_COST[1].to_string()]),
Tool::Drawbridge => trf("cost.gold_tile", &[DRAWBRIDGE_COST.to_string()]),
Tool::Steel => trf("cost.steel", &[STEEL_COST[0].to_string(), STEEL_COST[1].to_string()]),
Tool::Tower(TowerKind::Rune) => {
let s = tower_stats(TowerKind::Rune);
@@ -331,10 +337,10 @@ pub fn tool_cost(t: Tool, g: &Game) -> String {
pub const CATS: [(&str, &[usize]); 7] = [
("cat.dig", &[0]),
("cat.hand", &[1]),
("cat.rooms", &[2, 3, 4, 5, 6, 12, 40, 13, 18, 21, 41, 42, 43, 44, 17]),
("cat.rooms", &[2, 3, 4, 5, 6, 12, 40, 13, 18, 21, 41, 42, 43, 44, 17, 47]),
("cat.towers", &[14, 15, 16, 20]),
("cat.traps", &[22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),
("cat.spells", &[9, 10, 11, 32, 33, 34, 35, 36, 37, 38, 39]),
("cat.spells", &[9, 10, 11, 32, 33, 34, 35, 36, 37, 38, 39, 48]),
("cat.orders", &[8, 45, 46, 7, 19]),
];
@@ -1412,6 +1418,17 @@ impl Ui {
}
// Info text for the unit or tile under the mouse (first line = title)
// fire and wear of a bridge tile
fn bridge_state(g: &Game, i: usize, out: &mut Vec<(String, Color)>) {
if g.burning(i) {
out.push((tr("tile.bridge_burning"), RED));
}
let w = g.wear_of(i);
if w > 0.0 {
out.push((trf("tile.bridge_worn", &[((w * 100.0) as i32).to_string()]), GOLD));
}
}
pub fn hover_info(g: &Game, ent: Option<usize>, tile: Option<(i32, i32)>) -> Vec<(String, Color)> {
let mut out = Vec::new();
if let Some(j) = ent {
@@ -1475,6 +1492,7 @@ pub fn hover_info(g: &Game, ent: Option<usize>, tile: Option<(i32, i32)>) -> Vec
return out;
}
let Some(t) = g.map.get(x, y) else { return out };
let i = idx(x, y);
let owner = match t.owner {
Owner::Player => "owner.player",
Owner::Hero => "owner.hero",
@@ -1532,6 +1550,25 @@ pub fn hover_info(g: &Game, ent: Option<usize>, tile: Option<(i32, i32)>) -> Vec
Kind::Bridge | Kind::LavaBridge => {
out.push((tr(if t.kind == Kind::Bridge { "tile.bridge" } else { "tile.lavabridge" }), FRAME_HI));
out.push((tr(owner), DIM));
bridge_state(g, i, &mut out);
}
Kind::Drawbridge => {
out.push((tr("tile.drawbridge"), FRAME_HI));
out.push((tr(owner), DIM));
let state = if t.res & DB_AUTO != 0 {
if t.raised() { "tile.drawbridge_auto_up" } else { "tile.drawbridge_auto" }
} else if t.raised() {
"tile.drawbridge_up"
} else {
"tile.drawbridge_down"
};
out.push((tr(state), BLUE));
bridge_state(g, i, &mut out);
}
Kind::Obsidian => {
out.push((tr("tile.obsidian"), FRAME_HI));
let left = g.bridgework.cooled.iter().find(|c| c.0 == i).map_or(0.0, |c| c.1);
out.push((trf("tile.obsidian_info", &[(left.ceil() as i32).to_string()]), if left < crate::bridges::MELT_WARN { RED } else { DIM }));
}
Kind::Shard => {
out.push((tr("tile.shard"), RED));