fix(game): restore exact media thresholds
Replace the inferred exponential media progression with the four initialized 32-bit thresholds used by the original score-addition path: 140,000, 650,000, 1,300,000, and 4,000,000. Award exactly one media level and extra ball at each, with no nonexistent fifth tier. Test Plan: - `cargo test --all-targets` -- 50 passed - `cargo clippy --all-targets -- -D warnings` -- passed - `cargo build --profile production` -- passed - threshold boundary and four-extra-ball test -- passed - `git diff --cached --check` -- passed
This commit is contained in:
+29
-2
@@ -586,10 +586,10 @@ impl Game {
|
||||
}
|
||||
|
||||
fn check_media(&mut self, events: &mut Vec<Event>) {
|
||||
const THRESHOLDS: [u32; 5] = [360_000, 720_000, 1_440_000, 2_880_000, 5_760_000];
|
||||
const THRESHOLDS: [u32; 4] = [140_000, 650_000, 1_300_000, 4_000_000];
|
||||
let score = self.player().score;
|
||||
let level =
|
||||
u8::try_from(THRESHOLDS.partition_point(|threshold| score >= *threshold)).unwrap_or(5);
|
||||
u8::try_from(THRESHOLDS.partition_point(|threshold| score >= *threshold)).unwrap_or(4);
|
||||
if level > self.player().media_level {
|
||||
let player = &mut self.players[self.current_player];
|
||||
player.media_level = level;
|
||||
@@ -1253,6 +1253,33 @@ mod tests {
|
||||
assert!(!game.effect_target_active());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn media_extra_balls_use_the_recovered_threshold_table() {
|
||||
let mut game = Game::new(1);
|
||||
let mut events = Vec::new();
|
||||
|
||||
for (expected_level, threshold) in [140_000, 650_000, 1_300_000, 4_000_000]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
game.players[0].score = threshold - 1;
|
||||
game.check_media(&mut events);
|
||||
assert_eq!(usize::from(game.player().media_level), expected_level);
|
||||
|
||||
game.players[0].score = threshold;
|
||||
game.check_media(&mut events);
|
||||
assert_eq!(usize::from(game.player().media_level), expected_level + 1);
|
||||
}
|
||||
assert_eq!(game.player().extra_balls, 4);
|
||||
assert_eq!(
|
||||
events
|
||||
.iter()
|
||||
.filter(|event| **event == Event::ExtraBall)
|
||||
.count(),
|
||||
4
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn center_drain_advances_to_a_fresh_ball() {
|
||||
let mut game = Game::new(1);
|
||||
|
||||
Reference in New Issue
Block a user