use cursebreaker_parser::ShopDatabase; use std::env; fn main() -> Result<(), Box> { // Load all shops from XML let cb_assets_path = env::var("CB_ASSETS_PATH").unwrap_or_else(|_| "/home/connor/repos/CBAssets".to_string()); let shop_db = ShopDatabase::load_from_xml( &format!("{}/Data/XMLs/Shops/Shops.xml", cb_assets_path), )?; println!("=== Shop Database Statistics ==="); println!("Total shops: {}", shop_db.len()); println!("General stores: {}", shop_db.get_general_stores().len()); println!("Specialized shops: {}", shop_db.get_specialized_shops().len()); println!("Non-empty shops: {}", shop_db.get_non_empty_shops().len()); println!("Total items across all shops: {}", shop_db.total_item_count()); println!("Unique items sold: {}", shop_db.get_all_item_ids().len()); println!(); // Show all general stores println!("=== General Stores ==="); let general_stores = shop_db.get_general_stores(); for shop in &general_stores { println!(" [ID {}] {} ({} items)", shop.shop_id, shop.name, shop.item_count()); if let Some(ref comment) = shop.comment { println!(" Comment: {}", comment); } } println!(); // Show some specialized shops println!("=== Specialized Shops (first 10) ==="); let specialized = shop_db.get_specialized_shops(); for shop in specialized.iter().take(10) { println!(" [ID {}] {} ({} items)", shop.shop_id, shop.name, shop.item_count()); if let Some(ref comment) = shop.comment { println!(" Comment: {}", comment); } } println!("... and {} more", specialized.len().saturating_sub(10)); println!(); // Show details of a specific shop if let Some(shop) = shop_db.get_by_id(3) { println!("=== Shop Details (ID 3) ==="); println!("Name: {}", shop.name); println!("Is General Store: {}", shop.is_general_store); println!("Total items: {}", shop.item_count()); println!("\nItems:"); for (i, item) in shop.items.iter().take(10).enumerate() { print!(" {}) Item ID: {}", i + 1, item.item_id); if let Some(ref name) = item.name { print!(" ({})", name); } if let Some(price) = item.price { print!(" - {} gold", price); } if let Some(stock) = item.max_stock { print!(" - max stock: {}", stock); } if let Some(restock) = item.restock_time { print!(" - restock: {}s", restock); } println!(); } if shop.item_count() > 10 { println!(" ... and {} more items", shop.item_count() - 10); } } println!(); // Show shops that sell a specific item println!("=== Shops Selling Item '167' (Fishing Rod) ==="); let fishing_rod_shops = shop_db.get_shops_selling_item("167"); for shop in &fishing_rod_shops { println!(" [ID {}] {}", shop.shop_id, shop.name); if let Some(item) = shop.get_item_by_id("167") { if let Some(ref name) = item.name { print!(" - {}", name); } if let Some(price) = item.price { print!(" (custom price: {} gold)", price); } println!(); } } println!(); // Show shop with most items if let Some(largest_shop) = shop_db.all_shops().iter().max_by_key(|s| s.item_count()) { println!("=== Largest Shop ==="); println!("Name: {}", largest_shop.name); println!("Item count: {}", largest_shop.item_count()); println!(); } // Show items with unlimited stock in a shop if let Some(shop) = shop_db.get_by_id(3) { println!("=== Unlimited Stock Items in {} ===", shop.name); let unlimited = shop.get_unlimited_stock_items(); for item in unlimited.iter().take(5) { print!(" Item ID: {}", item.item_id); if let Some(ref name) = item.name { print!(" ({})", name); } println!(); } if unlimited.len() > 5 { println!(" ... and {} more", unlimited.len() - 5); } } println!(); // Show items with limited stock if let Some(shop) = shop_db.get_by_id(8) { println!("=== Limited Stock Items in Shop ID 8 ==="); let limited = shop.get_limited_stock_items(); for item in &limited { print!(" Item ID: {}", item.item_id); if let Some(ref name) = item.name { print!(" ({})", name); } if let Some(stock) = item.max_stock { print!(" - max stock: {}", stock); } if let Some(minutes) = item.get_restock_minutes() { print!(" - restocks every {:.1} min", minutes); } println!(); } } Ok(()) }