refactor(core): move compute_time_bonus into scoring module
The win-time bonus is Ferrous house-rule scoring policy, not a bridge to the upstream klondike crate, so it does not belong in klondike_adapter. Relocate it to a dedicated solitaire_core::scoring module and update the sole caller (win_summary_plugin) and the adapter/settings doc references. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
//! [`KlondikeAdapter`] is a pure helper namespace for:
|
||||
//! - building [`KlondikeConfig`] from Ferrous settings
|
||||
//! - translating between local and upstream types
|
||||
//! - applying Ferrous-specific scoring policy on top of upstream defaults
|
||||
//!
|
||||
//! Ferrous-specific scoring policy (the win-time bonus) lives in
|
||||
//! [`crate::scoring`], not here.
|
||||
//!
|
||||
//! All `From` / `TryFrom` conversions between `solitaire_core` product types and
|
||||
//! upstream `card_game` / `klondike` types live here so that the product modules
|
||||
@@ -14,11 +16,11 @@ use klondike::{
|
||||
SkipCards, Tableau,
|
||||
};
|
||||
|
||||
/// Bridges `solitaire_core` game config and scoring to the upstream `klondike` crate.
|
||||
/// Bridges `solitaire_core` game config to the upstream `klondike` crate.
|
||||
///
|
||||
/// This type is intentionally zero-sized: it does not carry mutable runtime
|
||||
/// state, and exists only as a namespace for configuration, conversion, and
|
||||
/// scoring helpers.
|
||||
/// state, and exists only as a namespace for configuration and conversion
|
||||
/// helpers.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub struct KlondikeAdapter;
|
||||
|
||||
@@ -81,12 +83,3 @@ pub fn skip_cards_from_count(skip: usize) -> Option<SkipCards> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Time bonus added to the score on a win: `700_000 / elapsed_seconds`.
|
||||
/// Returns 0 when `elapsed_seconds` is 0 to avoid division by zero.
|
||||
pub fn compute_time_bonus(elapsed_seconds: u64) -> i32 {
|
||||
if elapsed_seconds == 0 {
|
||||
return 0;
|
||||
}
|
||||
(700_000u64 / elapsed_seconds).min(i32::MAX as u64) as i32
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user