2024-04-05 22:38:41 -04:00
|
|
|
use serde_json::Result;
|
|
|
|
use std::fs;
|
|
|
|
|
2024-04-09 04:51:30 -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)?;
|
|
|
|
|
2024-04-09 04:51:30 -04:00
|
|
|
// player 0 (host)
|
|
|
|
let adam: CAHPlayer = CAHPlayer {
|
|
|
|
host: true,
|
2024-04-05 22:38:41 -04:00
|
|
|
..Default::default()
|
|
|
|
};
|
2024-04-06 21:28:25 -04:00
|
|
|
|
2024-04-09 04:51:30 -04:00
|
|
|
// 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()
|
|
|
|
// });
|
|
|
|
//
|
2024-04-06 22:38:00 -04:00
|
|
|
// sloppy ui stuff
|
2024-04-09 04:51:30 -04:00
|
|
|
// let div = "--------------------------";
|
2024-04-06 22:38:00 -04:00
|
|
|
|
|
|
|
// deal black
|
2024-04-09 04:51:30 -04:00
|
|
|
// if let Some(black_card) = cah_game.deal_black()? {
|
|
|
|
// println!(
|
|
|
|
// "{}\nPick {}\n {}\n{}",
|
|
|
|
// div,
|
|
|
|
// black_card.pick.to_string(),
|
|
|
|
// black_card.text,
|
|
|
|
// div,
|
|
|
|
// );
|
|
|
|
// }
|
2024-04-06 21:28:25 -04:00
|
|
|
|
|
|
|
// deal white
|
2024-04-09 04:51:30 -04:00
|
|
|
// for i in 1..11 {
|
|
|
|
// let card = cah_game.draw_one_white()?;
|
|
|
|
// println!("{} {}", i, card.text);
|
|
|
|
// }
|
|
|
|
// println!("{}", div);
|
|
|
|
//
|
|
|
|
// cah_game.deck_counts();
|
2024-04-06 22:38:00 -04:00
|
|
|
|
|
|
|
// fin
|
2024-04-05 22:38:41 -04:00
|
|
|
Ok(())
|
|
|
|
}
|