Memorial stones only for level 10 creatures, at most 30 per map

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-06 15:34:03 +01:00
1 parent 66eaedf016
commit 28eac52953
2 files changed
+21 -9

No files matched your search

+19 -7
View File
@@ -8,9 +8,11 @@ use crate::i18n::{tr, trf};
use crate::map::*;
use serde::{Deserialize, Serialize};
// the fallen get a stone from this level on; at most MAX_MEMORIALS stones (the oldest go)
pub const MEMORIAL_LEVEL: u32 = 3;
pub const MAX_MEMORIALS: usize = 24;
// the fallen are remembered in the hall from HALL_LEVEL on; only the greatest (MEMORIAL_LEVEL)
// get a stone on the map, at most MAX_MEMORIALS of them (the oldest go)
pub const HALL_LEVEL: u32 = 3;
pub const MEMORIAL_LEVEL: u32 = 10;
pub const MAX_MEMORIALS: usize = 30;
// what killed a creature besides another unit (Ent::bane)
pub const BANE_SNARE: u8 = 250;
@@ -134,13 +136,17 @@ impl Game {
// a named creature of some standing fell: a stone with its name on its master's ground, as
// near to where it fell as there is plain floor
pub(crate) fn raise_memorial(&mut self, e: &Ent) -> bool {
if e.hero || e.name == 0 || e.level < MEMORIAL_LEVEL || !Owner::MASTER_SIDES.contains(&e.side) {
if e.hero || e.name == 0 || e.level < HALL_LEVEL || !Owner::MASTER_SIDES.contains(&e.side) {
return false;
}
// the hall of the fallen keeps the local master's (also without room for a stone)
if e.side == self.local_side {
self.hall.push(Fallen { kind: e.kind, name: e.name, level: e.level, kills: e.kills, bane: e.bane, time: self.time, when: 0 });
}
// a stone only for the greatest
if e.level < MEMORIAL_LEVEL {
return false; // the usual message tells of it
}
let owner = Owner::of_side(e.side);
let (x, y) = (e.x as i32, e.y as i32);
let taken: Vec<usize> = self.memorials.iter().map(|m| m.tile).collect();
@@ -261,12 +267,18 @@ mod tests {
t.owner = Owner::Player;
}
}
let id = g.spawn(EK::Ogre, false, cx as f32 + 1.5, cy as f32 + 5.5, 4);
let id = g.spawn(EK::Ogre, false, cx as f32 + 1.5, cy as f32 + 5.5, 10);
let j = g.ents.iter().position(|e| e.id == id).unwrap();
g.kill(j);
assert_eq!(g.memorials.len(), 1);
let m = &g.memorials[0];
assert_eq!((m.kind, m.level), (EK::Ogre, 4));
let m = g.memorials[0].clone();
assert_eq!((m.kind, m.level), (EK::Ogre, 10));
// level 4: in the hall, but no stone on the map
let o4 = g.spawn(EK::Ogre, false, cx as f32 + 3.5, cy as f32 + 5.5, 4);
let j = g.ents.iter().position(|e| e.id == o4).unwrap();
g.kill(j);
assert_eq!(g.memorials.len(), 1);
assert_eq!(g.hall.len(), 2);
assert!(g.memorial_at(m.tile).is_some());
// a level 1 kobold is not remembered
let k = g.spawn(EK::Kobold, false, cx as f32 + 2.5, cy as f32 + 5.5, 1);