use std::thread;
use std::time::Duration;
use bfbb::game_interface::dolphin::DolphinInterface;
use bfbb::game_interface::game_var::{GameVar, GameVarMut, InterfaceBackend};
use bfbb::game_interface::{GameInterface, InterfaceError, InterfaceProvider, InterfaceResult};
use bfbb::game_state::GameState;
fn main() -> InterfaceResult<()> {
let mut dolphin = DolphinInterface::default();
let spatula_count = dolphin.do_with_interface(|interface| interface.spatula_count.get())?;
println!("You have {spatula_count} spatulas.");
loop {
let res = dolphin.do_with_interface(mod_logic);
match res {
Ok(()) => println!("GameState was successfully updated"),
Err(InterfaceError::Unhooked) => println!("GameInterface became unhooked"),
Err(e) => println!("{e:?}"),
}
thread::sleep(Duration::from_secs(2));
}
}
fn mod_logic<F: InterfaceBackend>(interface: &mut GameInterface<F>) -> InterfaceResult<()> {
interface.game_state.set(GameState::Exit)
}