prices come from the csv globals now, a json cost is just an override. DATABASE_URL defaults to postgres:///scroll when unset.
19 lines
623 B
Rust
19 lines
623 B
Rust
pub const SECONDS_PER_DAY: i32 = 86_400;
|
|
pub const WEEKDAYS: i32 = 7;
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub struct ShopCycle {
|
|
pub seed: i32,
|
|
pub weekday_index: i32,
|
|
pub seconds_to_cycle: i32,
|
|
}
|
|
impl ShopCycle {
|
|
pub fn at(timestamp: i32) -> Self {
|
|
let day = timestamp.div_euclid(SECONDS_PER_DAY);
|
|
let seconds_into_day = timestamp.rem_euclid(SECONDS_PER_DAY);
|
|
Self {
|
|
seed: day.wrapping_mul(2_654_435_761u32 as i32) | 1,
|
|
weekday_index: day.rem_euclid(WEEKDAYS) + 1,
|
|
seconds_to_cycle: SECONDS_PER_DAY - seconds_into_day,
|
|
}
|
|
}
|
|
}
|