77 lines
2.3 KiB
Rust
77 lines
2.3 KiB
Rust
|
use anyhow::Result;
|
||
|
use std::fs::File;
|
||
|
use std::thread;
|
||
|
use crate::notes::Notes;
|
||
|
use crate::game_state::GameState;
|
||
|
use crate::notes_state::NotesState;
|
||
|
|
||
|
mod notes;
|
||
|
mod game_state;
|
||
|
mod notes_state;
|
||
|
mod util;
|
||
|
|
||
|
fn main() -> Result<()> {
|
||
|
let notes: Notes = serde_yaml::from_reader(File::open("notes.yaml")?)?;
|
||
|
let mut game_state = GameState::new()?;
|
||
|
let mut notes_state = NotesState::new(¬es, &mut game_state)?;
|
||
|
|
||
|
println!("Ready");
|
||
|
|
||
|
// let mut first = true;
|
||
|
// let mut last_story = 0;
|
||
|
// let mut last_location = 0;
|
||
|
// let mut last_printed_location = 0;
|
||
|
// let mut step_idx = 23;
|
||
|
// let mut area_idx = 0;
|
||
|
// let mut current_step = ¬es.steps[0];
|
||
|
// let mut force_instructions = false;
|
||
|
|
||
|
loop {
|
||
|
notes_state.tick(&mut game_state)?;
|
||
|
thread::sleep(std::time::Duration::from_millis(16));
|
||
|
|
||
|
// last_story = state.story;
|
||
|
// last_location = state.location;
|
||
|
// state.refresh()?;
|
||
|
//
|
||
|
// if last_story != state.story {
|
||
|
// let next_step = match notes.steps.get(step_idx) {
|
||
|
// Some(step) => step,
|
||
|
// None => continue,
|
||
|
// };
|
||
|
//
|
||
|
// if next_step.stage == state.story {
|
||
|
// current_step = next_step;
|
||
|
// step_idx += 1;
|
||
|
// area_idx = 0;
|
||
|
// force_instructions = current_step.areas[0].area == 0 || current_step.areas[0].area == last_location;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// if force_instructions || last_location != state.location {
|
||
|
// let next_area = match current_step.areas.get(area_idx) {
|
||
|
// Some(area) => area,
|
||
|
// None => continue,
|
||
|
// };
|
||
|
//
|
||
|
// if next_area.area == state.location || next_area.area == 0 {
|
||
|
// if first {
|
||
|
// first = false;
|
||
|
// step_idx += 1;
|
||
|
// }
|
||
|
//
|
||
|
// area_idx += 1;
|
||
|
// force_instructions = false;
|
||
|
// if last_printed_location != next_area.area {
|
||
|
// println!("{}", state.location_name().unwrap_or("Unknown Location"));
|
||
|
// last_printed_location = state.location;
|
||
|
// }
|
||
|
//
|
||
|
// println!("{}", next_area.steps);
|
||
|
// }
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
Ok(())
|
||
|
}
|