rust-cli-arcade 0.1.0

A collection of classic CLI games: Tic-Tac-Toe, Connect Four, Hangman, and Rock Paper Scissors
use std::io;
use rand::Rng;

pub fn play() {
    println!("\nRock Paper Scissors (Best of 5)");
    
    let mut player_score = 0;
    let mut computer_score = 0;

    while player_score < 3 && computer_score < 3 {
        println!("\nScore - You: {} | Computer: {}", player_score, computer_score);
        println!("Choose: 1=Rock, 2=Paper, 3=Scissors");

        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();

        let player: u32 = match input.trim().parse() {
            Ok(n) if n >= 1 && n <= 3 => n,
            _ => continue,
        };

        let computer = rand::thread_rng().gen_range(1..=3);

        let choices = ["Rock", "Paper", "Scissors"];
        println!("You: {} | Computer: {}", choices[(player-1) as usize], choices[(computer-1) as usize]);

        if player == computer {
            println!("Tie!");
        } else if (player == 1 && computer == 3) || 
                  (player == 2 && computer == 1) || 
                  (player == 3 && computer == 2) {
            println!("You win!");
            player_score += 1;
        } else {
            println!("Computer wins!");
            computer_score += 1;
        }
    }

    println!("\nFinal - You: {} | Computer: {}", player_score, computer_score);
    if player_score > computer_score {
        println!("You won the match!");
    } else {
        println!("Computer won the match!");
    }
}