/*
	This shows...

*/

/*

	main.rs
	
	
	elsewhere.rs
		use super::_furniture::likelihood::{ likelihood };
		likelihood ("Flop", 1, 10);
*/

use serde::{ Deserialize, Serialize };
use serde_json::Result;

fn round_to_two_decimal_places (float_1 : f64) -> String {
	format! ("{:.2}", float_1)
}

pub fn likelihood (name : &str, has : i64, realities : i64) -> [f64; 2] {

	
	/*
		For Example:
			Pocket 1/17 -> 17
	
	
		* found_realities (splits)
	*/
	let found_realities_f64 : f64 = 1 as f64 / (has as f64 / realities as f64);
	let found_realities_string : String = round_to_two_decimal_places (found_realities_f64);
	
	/*
	
	
	*/
	let percent_f64 : f64 = (has as f64 / realities as f64) * 100 as f64;
	let percent_string : String = round_to_two_decimal_places (percent_f64);
	
	/*
		Example:
			has/realities = 1/10 = 1:9
			(realities/has)/has = (10-1)/1 = 9
	
		let ratio : String = round_to_two_decimal_places ()
	*/
	let ratio_string : String = round_to_two_decimal_places (0 as f64);
	let odds_2_f64 : f64 = (realities as f64 - has as f64) / has as f64;
	let odds_2_string : String = round_to_two_decimal_places (odds_2_f64);

	
	/*
		Found:Didn't Find
		Win:Loss
		Victory:Defeat
	*/
	#[derive(Serialize, Deserialize)]
	struct Show_Results {
		every : String,
		VD_odds: String,
		percent: String,
		fraction_unreduced: String
	};
	
	let show_results = Show_Results {
		every: format! ("1 every {}", found_realities_string),
		VD_odds: format! ("1 : {}", odds_2_string),
		percent: format! ("{}%", percent_string),
		fraction_unreduced : format! ("{} / {}", has, realities)
	};
	
	let results_hull = serde_json::to_string_pretty (&show_results).unwrap ();
	println! ("{}: {}", name, results_hull);
	
	return [ 
		found_realities_f64, 
		percent_f64 
	]
}