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