use chironaut::{
game::Game,
rules::GameRules,
};
fn main() {
println!("=== ZERO CHIPS TEST ===\n");
let rules = GameRules::nlhe(10, 20);
let mut game = Game::new(rules);
println!("Setting up Player 1 with 1000 chips and Player 2 with 0 chips");
game.add_player_to_seat("Player 1".to_string(), 1000, 0).unwrap();
game.add_player_to_seat("Player 2".to_string(), 0, 1).unwrap();
println!("\nAttempting to start a hand with a player who has 0 chips...");
match game.start_hand() {
Ok(_) => {
println!("Hand started successfully (this shouldn't happen with the new checks)");
print_player_status(&game);
},
Err(e) => {
println!("Error starting hand: {}", e);
println!("\nThis is the expected behavior! The game correctly prevents starting a hand when a player in a blind position has 0 chips.");
}
}
println!("\n\n=== TEST WITH MINIMUM CHIPS ===");
let rules2 = GameRules::nlhe(10, 20);
let mut game = Game::new(rules2);
println!("Setting up Player 1 with 1000 chips and Player 2 with exactly 10 chips (small blind amount)");
game.add_player_to_seat("Player 1".to_string(), 1000, 0).unwrap();
game.add_player_to_seat("Player 2".to_string(), 10, 1).unwrap();
println!("\nAttempting to start a hand with a player who has just enough chips for the small blind...");
match game.start_hand() {
Ok(_) => {
println!("Hand started successfully");
print_player_status(&game);
println!("\nBlinds:");
let sb_pos = game.get_small_blind_position();
let bb_pos = game.get_big_blind_position();
println!("Small blind position: {} ({})", sb_pos, game.players[sb_pos].name);
println!("Big blind position: {} ({})", bb_pos, game.players[bb_pos].name);
println!("\nPot: {}", game.pot);
println!("Current bet: {}", game.current_bet);
println!("\nPlayer 2 all-in status: {}", game.players[1].is_all_in);
},
Err(e) => {
println!("Error starting hand: {}", e);
}
}
}
fn print_player_status(game: &Game) {
println!("\n--- PLAYER STATUS ---");
for (i, player) in game.players.iter().enumerate() {
println!("Player {} ({})", i, player.name);
println!(" Chips: {}", player.chips);
println!(" Bet amount: {}", player.bet_amount);
println!(" Folded: {}", player.is_folded);
println!(" All-in: {}", player.is_all_in);
println!(" Hand: {}", player.hand);
}
}