mod big_push;
mod commit_value;
mod context;
mod first_push;
mod friday_afternoon_push;
mod many_lines_changed;
mod multiple_repos;
mod one_line_change;
mod rapid_fire;
mod streak;
mod weekend_push;
pub use crate::clock::Clock;
pub use context::PushContext;
use big_push::BigPush;
use commit_value::CommitValue;
use first_push::FirstPush;
use friday_afternoon_push::FridayAfternoon;
use many_lines_changed::ManyLinesChanged;
use multiple_repos::MultipleRepos;
use one_line_change::OneLineChange;
use rapid_fire::RapidFire;
use streak::Streak;
use weekend_push::WeekendPush;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Reward {
Multiplier(u32),
FlatPoints(u64),
}
#[derive(Debug, Clone, Copy)]
pub struct Tier {
pub cost: u64,
pub reward: Reward,
}
pub trait BonusTrack: Sync {
fn id(&self) -> &'static str;
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn tiers(&self) -> &'static [Tier];
fn applies(&self, ctx: &PushContext) -> u32;
fn reward_at_level(&self, level: u32) -> Option<Reward> {
if level == 0 {
return None;
}
self.tiers().get(level as usize - 1).map(|t| t.reward)
}
}
static BIG_PUSH: BigPush = BigPush;
pub static COMMIT_VALUE: CommitValue = CommitValue;
static FIRST_PUSH: FirstPush = FirstPush;
static FRIDAY_AFTERNOON: FridayAfternoon = FridayAfternoon;
static MANY_LINES_CHANGED: ManyLinesChanged = ManyLinesChanged;
static MULTIPLE_REPOS: MultipleRepos = MultipleRepos;
static ONE_LINE_CHANGE: OneLineChange = OneLineChange;
static RAPID_FIRE: RapidFire = RapidFire;
static STREAK: Streak = Streak;
static WEEKEND_PUSH: WeekendPush = WeekendPush;
pub static ALL_TRACKS: &[&'static dyn BonusTrack] = &[
&COMMIT_VALUE,
&FIRST_PUSH,
&RAPID_FIRE,
&BIG_PUSH,
&MULTIPLE_REPOS,
&ONE_LINE_CHANGE,
&MANY_LINES_CHANGED,
&STREAK,
&WEEKEND_PUSH,
&FRIDAY_AFTERNOON,
];