mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-24 03:58:14 -08:00
rust port
wrote the intro, directions, and max players check
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::game::Game;
|
||||
use crate::{game::Game, util::PromptResult};
|
||||
|
||||
mod game;
|
||||
mod horses;
|
||||
@@ -6,6 +6,19 @@ mod players;
|
||||
mod util;
|
||||
|
||||
fn main() {
|
||||
println!("\n\n\t\tHORSERACE");
|
||||
println!("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
println!("WELCOME TO SOUTH PORTLAND HIGH RACETRACK\n\t\t...OWNED BY LAURIE CHEVALIER");
|
||||
|
||||
if let PromptResult::YesNo(yes) = util::prompt(Some(false), "DO YOU WANT DIRECTIONS?") {
|
||||
if yes {
|
||||
println!("UP TO 10 MAY PLAY. A TABLE OF ODDS WILL BE PRINTED. YOU");
|
||||
println!("MAY BET ANY AMOUNT UNDER $100,000 ON ONE HORSE.");
|
||||
println!("DURING THE RACE, A HORSE WILL BE SHOWN BY ITS");
|
||||
println!("NUMBER. THE HORSES RACE DOWN THE PAPER!\n");
|
||||
}
|
||||
}
|
||||
|
||||
let mut game = Game::new();
|
||||
let mut again = true;
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ impl Players {
|
||||
if let PromptResult::Numeric(n) = util::prompt(Some(true), "HOW MANY WANT TO BET?") {
|
||||
if n <= 0 {
|
||||
println!("THERE CAN'T BE (LESS THAN) ZERO PLAYERS!");
|
||||
} else if n > 10 {
|
||||
println!("THERE CAN'T BE MORE THAN TEN PLAYERS!");
|
||||
} else {
|
||||
println!("WHEN ? APPEARS, TYPE NAME");
|
||||
players = Players::generate_players(n);
|
||||
|
||||
Reference in New Issue
Block a user