aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 3c29ea3..f88fee5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,7 @@ mod parser;
use crate::game::*;
use crate::gui::*;
+use crate::parser::parse_start_type;
use argparse::*;
use chrono::Local;
@@ -23,6 +24,7 @@ fn main() {
let mut engine = String::new();
let mut name = String::new();
let mut size: u8 = 5;
+ let mut start_type_string = String::new();
{
let mut ap = ArgumentParser::new();
@@ -41,6 +43,15 @@ fn main() {
overridden by the arument ENGINE of --engine when applicable.",
);
+ ap.refer(&mut start_type_string)
+ .add_option(
+ &["-v", "--variant-start"],
+ Store,
+ "Select the rule variant for the start of play. Valid choices are CPSn, FCS, FES, TPS, and CZS.
+ The default starting type, which matches the original rules, is CPS2.",
+ )
+ .metavar("VRNT");
+
ap.refer(&mut engine).add_option(
&["-e", "--engine"],
Store,
@@ -71,6 +82,16 @@ fn main() {
ap.parse_args_or_exit();
}
+ let start_type;
+ if !start_type_string.is_empty() {
+ match parse_start_type(&start_type_string) {
+ Err(e) => panic!("Invalid start rule variant provided: {}", e),
+ Ok(st) => start_type = st,
+ }
+ } else {
+ start_type = StartType::CPS(2);
+ }
+
let call_proc;
if !engine.is_empty() {
p2_name = engine.clone();
@@ -87,7 +108,7 @@ fn main() {
p1_white = false;
} else {
panic!(
- "Player named as white ({}) is not a player in this game ({} and {}).",
+ "Player named as white ({}) is not a player in this game (only ``{}'' and ``{}'' are).",
name, p1_name, p2_name
);
}
@@ -101,9 +122,9 @@ fn main() {
let date_string = Local::now().to_string();
let (mut game, warning) = if p1_white {
- Game::new(size, &p1_name, &p2_name, &date_string)
+ Game::new(size, &p1_name, &p2_name, &date_string, start_type)
} else {
- Game::new(size, &p2_name, &p1_name, &date_string)
+ Game::new(size, &p2_name, &p1_name, &date_string, start_type)
};
let mut gui = GUI::new(&game, warning);