1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::api::dungeons::FixedRoomId;
use crate::api::overlay::OverlayLoadLease;
use crate::ffi;

/// Extension trait for [`FixedRoomId`] specific to dungeon mode.
pub trait DungeonFixedRoomIdExt {
    /// Note: unverified, ported from Irdkwia's notes
    fn is_boss_fight(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Checks if orbs are usable in the given fixed room.
    ///
    /// Always true if not a full-floor fixed room.
    fn are_orbs_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Checks if tile jumps (warping, being blown away, and leaping) are allowed in the given fixed room.
    ///
    /// Always true if not a full-floor fixed room.
    fn are_tile_jumps_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Checks if Trawl Orbs work in the given fixed room.
    ///
    /// Always true if not a full-floor fixed room.
    fn are_trawl_orbs_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Check if late-game traps (Summon, Pitfall, and Pokémon traps) work in the given fixed room.
    ///
    /// Or disabled? This function, which Irdkwia's notes label as a disable check, check
    /// the struct field labeled in End's notes as an enable flag.
    fn are_late_game_traps_enabled(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Checks if moves (excluding the regular attack) are usable in the given fixed room.
    fn are_moves_enabled(&self, _ov29: &OverlayLoadLease<29>) -> bool;

    /// Checks if the given fixed room is fully illuminated.
    fn is_room_illuminated(&self, _ov29: &OverlayLoadLease<29>) -> bool;
}

impl DungeonFixedRoomIdExt for FixedRoomId {
    fn is_boss_fight(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::IsBossFight(*self) > 0 }
    }

    fn are_orbs_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::AreOrbsAllowed(*self) > 0 }
    }

    fn are_tile_jumps_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::AreTileJumpsAllowed(*self) > 0 }
    }

    fn are_trawl_orbs_allowed(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::AreTrawlOrbsAllowed(*self) > 0 }
    }

    fn are_late_game_traps_enabled(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::AreLateGameTrapsEnabled(*self) > 0 }
    }

    fn are_moves_enabled(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::AreMovesEnabled(*self) > 0 }
    }

    fn is_room_illuminated(&self, _ov29: &OverlayLoadLease<29>) -> bool {
        unsafe { ffi::IsRoomIlluminated(*self) > 0 }
    }
}