chironaut 0.3.5

A poker game library for Texas Hold'em and other poker variants
Documentation
use chironaut::{
    game::Game,
    rules::GameRules,
};

fn main() {
    println!("=== ZERO CHIPS TEST ===\n");
    
    // Create a No-Limit Hold'em game with 10/20 blinds
    let rules = GameRules::nlhe(10, 20);
    let mut game = Game::new(rules);

    // Setup players with uneven chip stacks
    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();
    
    // Start a hand
    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.");
        }
    }
    
    // Now let's test with Player 2 having just enough chips for the small blind
    println!("\n\n=== TEST WITH MINIMUM CHIPS ===");
    
    // Reset the game and add players with different chip amounts
    // Create a new GameRules instance to avoid ownership issues
    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();
    
    // Start a hand
    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);
            
            // Show blind information
            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);
            
            // Show pot and bets
            println!("\nPot: {}", game.pot);
            println!("Current bet: {}", game.current_bet);
            
            // Show if player went all-in with the blind
            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);
    }
}