Skip to content

Commit

Permalink
fmt and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Aug 27, 2024
1 parent 451f1bf commit 2c28636
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased
### Additions:

- Make `RoomName::from_packed` and `RoomName::packed_repr` public
- Add constants to `season_1` module representing the Season 1 score cycle mechanic

0.21.3 (2024-08-14)
===================
Expand Down
19 changes: 14 additions & 5 deletions src/constants/seasonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ pub mod season_1 {
/// 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 dropped spawned by [`SCORE_BONUS_MULTIPLIER`].
/// The point of the score cycle where bonus time begins, multiplying
/// dropped spawned by [`SCORE_BONUS_MULTIPLIER`].
pub const SCORE_BONUS_START: u32 = 45_000;

/// The point of the score cycle where bonus time ends
Expand All @@ -54,30 +55,35 @@ pub mod season_1 {
/// The multiplier for score spawned during bonus time
pub const SCORE_BONUS_MULTIPLIER: u8 = 2;

/// The point of the score cycle where crisis time begins, during which no new [`ScoreContainer`]s will be spawned.
/// 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;

/// The point of the score cycle where crisis time ends, allowing [`ScoreContainer`]s to be spawned once again.
/// 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;

/// The multiplier for score spawned during crisis time
pub const SCORE_CRISIS_MULTIPLIER: u8 = 0;

/// The minimum amount of ticks a [`ScoreContainer`] can exist before despawning
/// The minimum amount of ticks a [`ScoreContainer`] can exist before
/// 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
/// The maximum amount of ticks a [`ScoreContainer`] can exist before
/// despawning
///
/// [`ScoreContainer`]: crate::objects::ScoreContainer
pub const SCORE_MAX_DECAY: u16 = 5_000;

/// The different parts of the score cycle
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ScoreCycleState {
Normal,
Expand All @@ -86,6 +92,8 @@ pub mod season_1 {
}

impl ScoreCycleState {
/// Gets the multiplier of score associated with the represented part of
/// the score cycle
pub fn multiplier(&self) -> u8 {
match self {
ScoreCycleState::Normal => 1,
Expand All @@ -102,6 +110,7 @@ pub mod season_1 {
// match on those exact values first
SCORE_CRISIS_START => ScoreCycleState::Normal,
SCORE_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,
_ => ScoreCycleState::Normal,
Expand Down

0 comments on commit 2c28636

Please sign in to comment.