Skip to main content

tengu_api/state/
game.rs

1use super::DojosAccount;
2use steel::*;
3
4#[repr(C)]
5#[derive(Clone, Copy, Debug, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
6pub struct Game {
7    /// Total Spirit Power of all assigned shoguns (for % display).
8    pub total_spirit_power: u64,
9    /// Total in-game shards burned (dine, upgrades, level-up). Not SPL transfers.
10    pub total_shards_burned: u64,
11    /// Last slot at which emission was run (keeper / gameplay). Used to compute next emission.
12    pub last_emission_slot: u64,
13    /// Sum of effective SP (raw + scene bonus) across all dojos. For pool-split in claim_shards.
14    pub total_effective_spirit_power: u64,
15    pub buffer3: u64,
16    pub buffer4: u64,
17}
18
19account!(DojosAccount, Game);
20
21impl Game {
22    /// Effective SP for pool-split: (raw_sp + flat_bonus) * (1 + pct_bps/10000).
23    /// Used so scene bonuses shift share without increasing total emissions.
24    pub fn effective_spirit_power_with_scene(raw_sp: u64, scene_id: u64) -> u64 {
25        let (flat, pct_bps) = crate::utils::scene_bonus(scene_id);
26        let base = raw_sp.saturating_add(flat);
27        if pct_bps == 0 {
28            base
29        } else {
30            base.saturating_mul(10000 + pct_bps) / 10000
31        }
32    }
33}