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"; // TODO: this should be a master card database and pointers // to the cards should be passed to the game instead of actual cards let chosen_packs: Vec = load_json(cards_input_path)?; println!("{}", &chosen_packs.len()); 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 // use hashmap? let mut games: Vec = vec![]; // create game with/for player 0 // TODO: make this a new game request struct games.push(CAHGame::new( "Test0".to_string(), test_player0, chosen_packs, )?); // a new game request struct but this player is a player games[0].create_player(test_player1)?; // start round games[0].game_start()?; Ok(()) }