// //
// use crate::database::db_type::{RIso2WDis, RWDist, WinDistType};
// use mysql::prelude::*;
// use mysql::*;

// use crate::featurizer::Featurizer;
// use crate::custom_games::royal231::Royal231;
// // use crate::game::builtin::standard2311::Standard2311;
// use crate::game::component::*;

// extern crate redis;
// use redis::Commands;

// const MYSQL_URL: &str = "mysql://root:root@localhost:3306/poker";

// pub trait DbConnect {
//     fn insert_iso_win_id(
//         &self,
//         batchs: Vec<RIso2WDis>,
//     ) -> std::result::Result<(), Box<dyn std::error::Error>>;
//     fn insert_winner_dist(
//         &self,
//         batchs: Vec<RWDist>,
//     ) -> std::result::Result<(), Box<dyn std::error::Error>>;

//     fn query_winner_id(&self, iso_id: i64) -> std::result::Result<i64, Box<dyn std::error::Error>>;
//     fn query_winner_dist(
//         &self,
//         win_dis_id: i64,
//     ) -> std::result::Result<WinDistType, Box<dyn std::error::Error>>;
// }

// impl DbConnect for Royal231 {
//     fn insert_iso_win_id(
//         &self,
//         batchs: Vec<RIso2WDis>,
//     ) -> std::result::Result<(), Box<dyn std::error::Error>> {
//         let url = MYSQL_URL;
//         let pool = Pool::new(url)?;
//         let mut conn = pool.get_conn()?;

//         conn.exec_batch(
//             r"INSERT INTO t_poker_231_map (iso_id, win_dist_id)
//             VALUES (:iso_id, :win_dist_id)",
//             batchs.iter().map(|p| {
//                 params! {
//                     "iso_id" => p.iso_id,
//                     "win_dist_id" => p.win_dist_id,
//                 }
//             }),
//         )?;
//         Ok(())
//     }

//     fn insert_winner_dist(
//         &self,
//         batchs: Vec<RWDist>,
//     ) -> std::result::Result<(), Box<dyn std::error::Error>> {
//         let url = MYSQL_URL;
//         let pool = Pool::new(url)?;
//         let mut conn = pool.get_conn()?;

//         #[cfg(feature = "test_print")]
//         {
//             println!("begin build");
//         }

//         conn.exec_batch(
//             r"INSERT INTO t_poker_231_win_dist(win_dist_id, lost, tie, win)
//             VALUES (:win_dist_id, :lost, :tie, :win)",
//             batchs.iter().map(|p| {
//                 params! {
//                     "win_dist_id" => p.win_dist_id,
//                     "lost" => p.win_dist[0],
//                     "tie" => p.win_dist[1],
//                     "win" => p.win_dist[2],
//                 }
//             }),
//         )?;
//         #[cfg(feature = "test_print")]
//         {
//             println!("build done");
//         }
//         Ok(())
//     }
//     //}

//     //impl DbConnect for Royal231{
//     fn query_winner_id(&self, iso_id: i64) -> std::result::Result<i64, Box<dyn std::error::Error>> {
//         let url = MYSQL_URL; //"mysql://root:root@localhost:3306/poker";
//         let pool = Pool::new(url)?;
//         let mut conn = pool.get_conn()?;

//         let query_sql = format!(
//             "select win_dist_id from t_poker_231_map where iso_id={}",
//             iso_id
//         );
//         let selected: Vec<i64> = conn.query(query_sql)?;

//         println!("{:?}", selected);
//         Ok(selected[0])
//     }

//     fn query_winner_dist(
//         &self,
//         win_dis_id: i64,
//     ) -> std::result::Result<WinDistType, Box<dyn std::error::Error>> {
//         let url = MYSQL_URL; //"mysql://root:root@localhost:3306/poker";
//         let pool = Pool::new(url)?;
//         let mut conn = pool.get_conn()?;

//         let query_sql = format!(
//             "select lost, tie, win from t_poker_231_win_dist where win_dist_id={}",
//             win_dis_id
//         );
//         let selected: Vec<WinDistType> =
//             conn.query_map(query_sql, |(lost, tie, win)| [lost, tie, win])?;

//         println!("{:?}", selected);
//         Ok(selected[0])
//     }
// }

// //Test func
// pub fn query_value(win_dis_id: i64) -> std::result::Result<(), Box<dyn std::error::Error>> {
//     //let game = Royal231::new();
//     let game: &'static Royal231 = Royal231::instance().as_ref();
//     println!("{:?}", game.query_winner_dist(win_dis_id));
//     Ok(())
// }
