From bde9a500336aabf94967441074284ec8ca569692 Mon Sep 17 00:00:00 2001 From: Shane Madden Date: Tue, 27 Aug 2024 14:28:13 -0600 Subject: [PATCH] tweak constant names, minor comment cleanup --- src/constants/seasonal.rs | 45 ++++++++++++++++++--------------- src/local/room_xy/extra_math.rs | 2 ++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/constants/seasonal.rs b/src/constants/seasonal.rs index 284958a2..2e5c1962 100644 --- a/src/constants/seasonal.rs +++ b/src/constants/seasonal.rs @@ -42,63 +42,66 @@ pub mod season_1 { // extra constants for s1 related to the score spawn bonus/crisis cycle // https://github.com/screeps/mod-season1/blob/7ca3c7ddb47bf9dfbdfb4e72b666a3159fde8780/src/scoreContainer.roomObject.js - /// The duration of a full score cycle + /// The duration of a full score cycle. pub const SCORE_CYCLE_DURATION: u32 = 50_000; /// The point of the score cycle where bonus time begins, multiplying - /// spawned score by [`SCORE_BONUS_MULTIPLIER`]. - pub const SCORE_BONUS_START: u32 = 45_000; + /// spawned score by [`SCORE_CYCLE_BONUS_MULTIPLIER`]. + pub const SCORE_CYCLE_BONUS_START: u32 = 45_000; - /// The point of the score cycle where bonus time ends - pub const SCORE_BONUS_END: u32 = 50_000; + /// The point of the score cycle where bonus time ends. + pub const SCORE_CYCLE_BONUS_END: u32 = 50_000; - /// The multiplier for score spawned during bonus time - pub const SCORE_BONUS_MULTIPLIER: u8 = 2; + /// The multiplier for score spawned during bonus time. + pub const SCORE_CYCLE_BONUS_MULTIPLIER: u8 = 2; /// The point of the score cycle where crisis time begins, during which no /// new [`ScoreContainer`]s will be spawned. /// /// [`ScoreContainer`]: crate::objects::ScoreContainer - pub const SCORE_CRISIS_START: u32 = 10_000; + pub const SCORE_CYCLE_CRISIS_START: u32 = 10_000; /// The point of the score cycle where crisis time ends, allowing /// [`ScoreContainer`]s to be spawned once again. /// /// [`ScoreContainer`]: crate::objects::ScoreContainer - pub const SCORE_CRISIS_END: u32 = 15_000; + pub const SCORE_CYCLE_CRISIS_END: u32 = 15_000; - /// The multiplier for score spawned during crisis time - pub const SCORE_CRISIS_MULTIPLIER: u8 = 0; + /// The multiplier for score spawned during crisis time. + pub const SCORE_CYCLE_CRISIS_MULTIPLIER: u8 = 0; /// The minimum amount of ticks a [`ScoreContainer`] can exist before - /// despawning + /// despawning. /// /// [`ScoreContainer`]: crate::objects::ScoreContainer // https://github.com/screeps/mod-season1/blob/7ca3c7ddb47bf9dfbdfb4e72b666a3159fde8780/src/scoreContainer.roomObject.js#L93 pub const SCORE_MIN_DECAY: u16 = 500; /// The maximum amount of ticks a [`ScoreContainer`] can exist before - /// despawning + /// despawning. /// /// [`ScoreContainer`]: crate::objects::ScoreContainer pub const SCORE_MAX_DECAY: u16 = 5_000; - /// The different parts of the score cycle + /// The different periods in the score cycle. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum ScoreCycleState { + /// Normal score spawns during the normal parts of the cycle Normal, + /// No score spawns during the crisis period Crisis, + /// Double score in each container during the bonus period Bonus, } impl ScoreCycleState { /// Gets the multiplier of score associated with the represented part of - /// the score cycle + /// the score cycle. pub fn multiplier(&self) -> u8 { match self { ScoreCycleState::Normal => 1, - ScoreCycleState::Crisis => SCORE_CRISIS_MULTIPLIER, - ScoreCycleState::Bonus => SCORE_BONUS_MULTIPLIER, + ScoreCycleState::Crisis => SCORE_CYCLE_CRISIS_MULTIPLIER, + ScoreCycleState::Bonus => SCORE_CYCLE_BONUS_MULTIPLIER, } } } @@ -108,11 +111,11 @@ pub mod season_1 { // the bonus/crisis periods are exclusive of their boundaries // https://github.com/screeps/mod-season1/blob/7ca3c7ddb47bf9dfbdfb4e72b666a3159fde8780/src/scoreContainer.roomObject.js#L77-L81 // match on those exact values first - SCORE_CRISIS_START => ScoreCycleState::Normal, - SCORE_BONUS_START => ScoreCycleState::Normal, + SCORE_CYCLE_CRISIS_START => ScoreCycleState::Normal, + SCORE_CYCLE_BONUS_START => ScoreCycleState::Normal, // then on the remaining ranges - SCORE_CRISIS_START..SCORE_CRISIS_END => ScoreCycleState::Crisis, - SCORE_BONUS_START..SCORE_BONUS_END => ScoreCycleState::Bonus, + SCORE_CYCLE_CRISIS_START..SCORE_CYCLE_CRISIS_END => ScoreCycleState::Crisis, + SCORE_CYCLE_BONUS_START..SCORE_CYCLE_BONUS_END => ScoreCycleState::Bonus, _ => ScoreCycleState::Normal, } } diff --git a/src/local/room_xy/extra_math.rs b/src/local/room_xy/extra_math.rs index 49b75b39..4f8f933e 100644 --- a/src/local/room_xy/extra_math.rs +++ b/src/local/room_xy/extra_math.rs @@ -34,6 +34,8 @@ impl RoomXY { /// pos.offset(-5, 5); /// assert_eq!(pos, RoomXY::checked_new(16, 26).unwrap()); /// ``` + /// + /// [`Position::offset`]: crate::local::Position::offset #[inline] #[track_caller] pub fn offset(&mut self, x: i8, y: i8) {