1#![feature(generic_const_exprs)]
2#![allow(incomplete_features)] #![warn(missing_docs)]
4pub mod gamemodes;
12pub mod machine;
13pub mod recipe;
14pub mod research;
15pub mod resources;
16mod tick;
17
18use std::sync::Once;
19
20pub use crate::resources::{ResourceType, bundle, resource};
21use crate::{
22 gamemodes::{GameMode, StartingResources},
23 tick::Tick,
24};
25
26static ONCE: Once = Once::new();
27
28pub fn play<G: GameMode>(main: fn(Tick, G::StartingResources) -> (Tick, G::VictoryResources)) -> ! {
30 let mut call_once_ran = false;
31 ONCE.call_once(|| call_once_ran = true);
32 if !call_once_ran {
33 panic!(
34 "play() can only be called once per program execution to prevent cheating via multithreading."
35 );
36 }
37 let tick = Tick::start();
38 let start_resources = G::StartingResources::init(&tick);
39 let (tick, _points) = main(tick, start_resources);
40 println!("You won in {} ticks!", tick.cur());
41 std::process::exit(0);
42}
43
44pub trait Sealed {}
47
48pub mod mod_reexports {
55 pub use crate::{
56 gamemodes::GameMode,
57 play,
58 recipe::{HandRecipe, Recipe},
59 research::{ResearchPoint, Technology},
60 resources::{Bundle, InsufficientResourceError, Resource, ResourceType},
61 tick::Tick,
62 };
63}