#[repr(C)]pub struct Battle {
pub dojo: Pubkey,
pub attack_points: u64,
pub defense_points: u64,
pub battle_points: u64,
pub last_battle_slot: u64,
pub last_targeted_slot: u64,
pub duel_window_start_slot: u64,
pub duel_count_24h: u64,
pub champion_slot: u64,
pub last_champion_change_slot: u64,
pub buffer: [u64; 3],
}Fields§
§dojo: Pubkey§attack_points: u64Cached champion attack rating (= champion spirit power for odds).
defense_points: u64Cached champion defense rating (= defender’s champion spirit power in their role).
battle_points: u64PvP score; win/loss transfers capped per battle.
last_battle_slot: u64Last slot this dojo initiated an attack (attacker cooldown).
last_targeted_slot: u64Last slot this dojo was targeted in a duel (defender immunity window).
duel_window_start_slot: u64Start of current 24h window for duel count.
duel_count_24h: u64Duels initiated in current 24h window (max crate::consts::BATTLE_MAX_DUELS_PER_24H).
champion_slot: u64Barracks slot index (0–11) of the PvP champion shogun.
last_champion_change_slot: u64Last slot when champion was changed (0 = never changed; first change skips cooldown).
buffer: [u64; 3]Implementations§
Source§impl Battle
impl Battle
Sourcepub fn champion_sp(barracks: &Barracks, champion_slot: u64) -> Option<u64>
pub fn champion_sp(barracks: &Barracks, champion_slot: u64) -> Option<u64>
Spirit power of the champion at champion_slot for win odds (AP or DP as role).
Sourcepub fn champion_chakra_remaining(
barracks: &Barracks,
champion_slot: u64,
) -> Option<u64>
pub fn champion_chakra_remaining( barracks: &Barracks, champion_slot: u64, ) -> Option<u64>
Chakra remaining for the champion at champion_slot (ore / dine). 0 = depleted (PvP: higher loss cap on defender; attacker cannot initiate).
Sourcepub fn win_probability_bps(attacker_ap: u64, defender_dp: u64) -> u64
pub fn win_probability_bps(attacker_ap: u64, defender_dp: u64) -> u64
Win probability in basis points (0..=10000): AP / (AP + DP).
Sourcepub fn point_transfer_fren(
attacker_bp: u64,
defender_bp: u64,
win_bps: u64,
attacker_won: bool,
defender_cap_bps: u64,
) -> u64
pub fn point_transfer_fren( attacker_bp: u64, defender_bp: u64, win_bps: u64, attacker_won: bool, defender_cap_bps: u64, ) -> u64
Points moved from loser → winner (Fren Pet rules).
win_bps is attacker win probability (0..=10_000). Used only when attacker BP ≥ low threshold
(and for “attack stronger” vs “weaker”, win_bps < 5000 vs ≥ 5000).
defender_cap_bps: crate::consts::BATTLE_TRANSFER_BPS or crate::consts::BATTLE_TRANSFER_DEFENDER_DEPLETED_BPS for defender-side % of BP.
Trait Implementations§
Source§impl AccountValidation for Battle
impl AccountValidation for Battle
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl Discriminator for Battle
impl Discriminator for Battle
fn discriminator() -> u8
impl Copy for Battle
impl Pod for Battle
impl StructuralPartialEq for Battle
Auto Trait Implementations§
impl Freeze for Battle
impl RefUnwindSafe for Battle
impl Send for Battle
impl Sync for Battle
impl Unpin for Battle
impl UnsafeUnpin for Battle
impl UnwindSafe for Battle
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more