use sylpheed_formats::{game_data as gd, PakArchive};
fn main(){
    let disc=std::env::var("SYLPHEED_DISC").unwrap();
    let pak=PakArchive::open(format!("{disc}/dat/GP_MAIN_GAME_E.pak")).unwrap();
    let units=gd::load_units(&pak); let vessels=gd::load_vessels(&pak);
    let hp=|id:&str|->String{
        units.iter().find(|u|u.id.as_deref()==Some(id)).and_then(|u|u.hp).map(|h|format!("{h:.0}hp"))
            .or_else(||vessels.iter().find(|v|v.id.as_deref()==Some(id)).and_then(|v|v.hp).map(|h|format!("{h:.0}HP")))
            .unwrap_or("·".into())
    };
    let rosters=gd::load_unit_rosters(&pak);
    for r in rosters.iter().filter(|r|r.stage.is_some()).take(4){
        println!("\n{} — {} combatants:", r.stage.as_deref().unwrap(), r.units.len());
        for u in r.units.iter().filter(|u|u.contains("ADAN")).take(6){
            let short=u.trim_start_matches("UN_").split('_').skip(1).collect::<Vec<_>>().join("_");
            println!("   {short:32} {}", hp(u));
        }
    }
}
