Statistics with a chart at the end of a game, 64 achievements kept locally and on the server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
193b199875
commit
9931ca9b54
37 files changed
+1833
-4
No files matched your search
+30
@@ -304,6 +304,11 @@ pub struct Ent {
|
||||
pub disp_y: f32,
|
||||
}
|
||||
|
||||
// units of the neutral dwarves count for nobody
|
||||
fn e_is_dwarf_side(side: u8) -> bool {
|
||||
side == crate::dwarves::DWARF_SIDE
|
||||
}
|
||||
|
||||
fn yes() -> bool {
|
||||
true
|
||||
}
|
||||
@@ -596,6 +601,8 @@ pub struct Game {
|
||||
#[serde(default)]
|
||||
pub bridgework: crate::bridges::BridgeWork, // burning and worn bridges
|
||||
#[serde(default)]
|
||||
pub stats: crate::stats::GameStats, // statistics of the master at this computer (see stats.rs)
|
||||
#[serde(default)]
|
||||
pub wall_plans: Vec<(usize, u8)>, // walls to raise: tile, master side (see walls.rs)
|
||||
#[serde(default)]
|
||||
pub wood: f32, // the second resource (see wood.rs)
|
||||
@@ -920,6 +927,7 @@ impl Game {
|
||||
vrng: crate::particles::vrng(),
|
||||
dwarf_caves: Vec::new(),
|
||||
bridgework: Default::default(),
|
||||
stats: Default::default(),
|
||||
wall_plans: Vec::new(),
|
||||
wood: crate::wood::WOOD_START,
|
||||
woodwork: Default::default(),
|
||||
@@ -1137,6 +1145,7 @@ impl Game {
|
||||
self.gold += acc;
|
||||
if acc > 0.0 {
|
||||
self.incoming.push((res, acc, at));
|
||||
self.count(crate::stats::GOLD, acc);
|
||||
}
|
||||
acc
|
||||
}
|
||||
@@ -1384,6 +1393,7 @@ impl Game {
|
||||
}
|
||||
let local = self.local_side;
|
||||
self.switch_to(local);
|
||||
self.sample_stats(STEP);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- masters
|
||||
@@ -2494,6 +2504,7 @@ impl Game {
|
||||
t.hp = 0.0;
|
||||
t.gold = 0;
|
||||
let (x, y) = xy(i);
|
||||
self.count(crate::stats::DUG, 1.0);
|
||||
self.fx(3, x as f32 + 0.5, y as f32 + 0.5, 0.0, 0.0, 0.6, 0xff304a66);
|
||||
self.sfx(Sfx::DigDone, x as f32 + 0.5, y as f32 + 0.5);
|
||||
}
|
||||
@@ -2759,6 +2770,8 @@ impl Game {
|
||||
e.patrol.clear();
|
||||
let b = st(kind).bounty as f32;
|
||||
let got = self.add_gold(b);
|
||||
self.count_local(crate::stats::HEROES);
|
||||
self.count_local(crate::stats::CAPTURED);
|
||||
self.fx(5, x, y, 0.0, 0.0, 1.0, 0xff30d0ff);
|
||||
self.sfx(Sfx::Capture, x, y);
|
||||
self.msg("msg.hero_captured", vec![format!("@{}", st(kind).name), (got as i32).to_string()]);
|
||||
@@ -2780,6 +2793,15 @@ impl Game {
|
||||
self.bury(x, y);
|
||||
}
|
||||
let s = st(kind);
|
||||
if hero {
|
||||
self.count_local(crate::stats::HEROES);
|
||||
} else if side == self.local_side && !e_is_dwarf_side(side) {
|
||||
let me = self.me_side;
|
||||
let local = self.local_side;
|
||||
self.switch_to(local);
|
||||
self.count(crate::stats::LOST, 1.0);
|
||||
self.switch_to(me);
|
||||
}
|
||||
if hero {
|
||||
let b = s.bounty as f32;
|
||||
let got = self.add_gold(b);
|
||||
@@ -2866,6 +2888,9 @@ impl Game {
|
||||
if !e.alive || e.held || e.tile() != i || flies(e.kind) {
|
||||
continue;
|
||||
}
|
||||
if e.hero {
|
||||
self.count_local(crate::stats::DROWNED);
|
||||
}
|
||||
if lava {
|
||||
self.burn(j);
|
||||
continue;
|
||||
@@ -4778,6 +4803,7 @@ impl Game {
|
||||
if built == 0 && !broke {
|
||||
self.hint(7, "hint.build_where");
|
||||
}
|
||||
self.count(crate::stats::ROOMS, built as f32);
|
||||
self.recount();
|
||||
}
|
||||
|
||||
@@ -4923,6 +4949,7 @@ impl Game {
|
||||
let tower = Tower { id, kind, tile: i, level: 1, hp: s.hp, cd: 1.0, aim: 0.0, flash: 0.0, hero: false, rune_final };
|
||||
let (px, py) = tower.pos();
|
||||
self.towers.push(tower);
|
||||
self.count(crate::stats::TOWERS, 1.0);
|
||||
// units standing on the tile step aside
|
||||
for e in self.ents.iter_mut() {
|
||||
if e.alive && e.tile() == i {
|
||||
@@ -5460,6 +5487,7 @@ impl Game {
|
||||
self.fx(2, x, y, 0.0, 0.0, 0.3, 0xffffffff);
|
||||
self.sfx(Sfx::Slap, x, y);
|
||||
self.script_event(crate::mscript::ScriptEvent::Slap);
|
||||
self.count(crate::stats::SLAPS, 1.0);
|
||||
return 1;
|
||||
}
|
||||
if self.ents[j].captive != 0 {
|
||||
@@ -5498,6 +5526,7 @@ impl Game {
|
||||
return;
|
||||
}
|
||||
self.mana -= COST;
|
||||
self.count(crate::stats::SPELLS, 1.0);
|
||||
self.sfx(Sfx::Lightning, wx, wy);
|
||||
self.fx(1, wx, wy, 0.0, 0.0, 0.5, 0xffffeeaa);
|
||||
self.ignite_at(wx, wy);
|
||||
@@ -5524,6 +5553,7 @@ impl Game {
|
||||
return;
|
||||
}
|
||||
self.mana -= COST;
|
||||
self.count(crate::stats::SPELLS, 1.0);
|
||||
self.sfx(Sfx::Heal, wx, wy);
|
||||
let mut fxs = Vec::new();
|
||||
for e in self.ents.iter_mut() {
|
||||
|
||||
Reference in new issue
Block a user