use serde_json::Result; use std::fs; #[allow(non_snake_case)] pub mod CAHd_game; use crate::CAHd_game::*; /// Parse json for card data fn load_json(path: &str) -> Result> { let data: String = fs::read_to_string(path).expect("Error reading file"); let jayson: Vec = serde_json::from_str(&data)?; Ok(jayson) } fn main() -> Result<()> { // choose decks let cards_input_path: &str = "data/cah-cards-full.json"; let cards_json: Vec = load_json(cards_input_path)?; // player 0 (host) let adam: CAHPlayer = CAHPlayer { host: true, ..Default::default() }; // create game with/for player 0 println!("{:?}", adam.host); // setup // let mut cah_game = CAHGame { // ..Default::default() // }; // cah_game.build_decks(cards_json); // cah_game.deck_counts(); // cah_game.create_player(CAHPlayer { // ..Default::default() // }); // // sloppy ui stuff // let div = "--------------------------"; // deal black // if let Some(black_card) = cah_game.deal_black()? { // println!( // "{}\nPick {}\n {}\n{}", // div, // black_card.pick.to_string(), // black_card.text, // div, // ); // } // deal white // for i in 1..11 { // let card = cah_game.draw_one_white()?; // println!("{} {}", i, card.text); // } // println!("{}", div); // // cah_game.deck_counts(); // fin Ok(()) }