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 chosen_packs: Vec = load_json(cards_input_path)?; let test_player0 = CAHPlayer { player_name: "Adam".to_string(), role: PlayerRole::Host, white: vec![], black: vec![], }; let test_player1 = CAHPlayer { player_name: "Ferris".to_string(), role: PlayerRole::Player, white: vec![], black: vec![], }; // make some games let mut games: Vec = vec![]; // create game with/for player 0 games.push(CAHGame::new( "Test0".to_string(), test_player0, chosen_packs, )?); // ready player 1 let _ = games[0].create_player(test_player1); Ok(()) }