1
This commit is contained in:
@@ -3459,6 +3459,19 @@ pub fn current_puzzle_unix_micros() -> i64 {
|
||||
(current_unix_ms() as i64).saturating_mul(1_000)
|
||||
}
|
||||
|
||||
pub fn puzzle_point_incentive_claimable_points(total_half_points: u64, claimed_points: u64) -> u64 {
|
||||
total_half_points
|
||||
.saturating_div(2)
|
||||
.saturating_sub(claimed_points)
|
||||
}
|
||||
|
||||
pub fn puzzle_point_incentive_total_after_spend(
|
||||
total_half_points: u64,
|
||||
spent_points: u64,
|
||||
) -> u64 {
|
||||
total_half_points.saturating_add(spent_points)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -3779,6 +3792,16 @@ mod tests {
|
||||
assert_ne!(first_positions, second_positions);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn puzzle_point_incentive_uses_half_points_and_floor_claimable() {
|
||||
// 中文注释:累计单位是 half point,消耗 1 个陶泥币只让作者获得 0.5 个待结算陶泥币。
|
||||
assert_eq!(puzzle_point_incentive_total_after_spend(0, 1), 1);
|
||||
assert_eq!(puzzle_point_incentive_claimable_points(1, 0), 0);
|
||||
assert_eq!(puzzle_point_incentive_claimable_points(2, 0), 1);
|
||||
assert_eq!(puzzle_point_incentive_claimable_points(5, 1), 1);
|
||||
assert_eq!(puzzle_point_incentive_claimable_points(5, 2), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn initial_board_has_no_original_neighbor_pairs() {
|
||||
for grid_size in PUZZLE_SUPPORTED_GRID_SIZES {
|
||||
|
||||
Reference in New Issue
Block a user