cards/src/main.rs

36 lines
860 B
Rust
Raw Normal View History

2024-04-05 22:38:41 -04:00
use serde_json::Result;
2024-04-10 04:18:31 -04:00
use std::{alloc::Layout, fs};
2024-04-05 22:38:41 -04:00
#[allow(non_snake_case)]
pub mod CAHd_game;
use crate::CAHd_game::*;
2024-04-05 22:38:41 -04:00
2024-04-06 22:38:00 -04:00
/// Parse json for card data
2024-04-05 22:38:41 -04:00
fn load_json(path: &str) -> Result<Vec<CAHCardSet>> {
let data: String = fs::read_to_string(path).expect("Error reading file");
let jayson: Vec<CAHCardSet> = serde_json::from_str(&data)?;
Ok(jayson)
}
fn main() -> Result<()> {
2024-04-06 22:38:00 -04:00
// choose decks
2024-04-05 22:38:41 -04:00
let cards_input_path: &str = "data/cah-cards-full.json";
let cards_json: Vec<CAHCardSet> = load_json(cards_input_path)?;
// create game with/for player 0
2024-04-10 04:18:31 -04:00
let game = CAHGame::new(
CAHPlayer {
player_name: "Adam".to_string(),
role: PlayerRole::Host,
white: vec![],
black: vec![],
},
cards_json,
);
println!("{:#?}", game?.players[0]);
2024-04-05 22:38:41 -04:00
Ok(())
}