add Output::did_complete() to clarfiy some comparisons

This commit is contained in:
tali 2023-04-15 17:18:57 -04:00
parent 60cde45eea
commit e439e1cb73
2 changed files with 10 additions and 4 deletions

View File

@ -97,7 +97,7 @@ fn single(args: cli::SingleRun) -> Result<()> {
// be sent so the ctrl-c handler will abort the program // be sent so the ctrl-c handler will abort the program
std::mem::drop(rx); std::mem::drop(rx);
if output.cleared < config.game.goal { if !output.did_complete() {
if !prompt_yn(&args.io, "run did not finish, keep it?") { if !prompt_yn(&args.io, "run did not finish, keep it?") {
break; break;
} }
@ -163,7 +163,7 @@ fn multi(args: cli::MultiRun) -> Result<()> {
} }
} }
Msg::Output(_id, output) => { Msg::Output(_id, output) => {
if output.cleared == config.game.goal { if output.did_complete() {
completed.insert(output.pieces); completed.insert(output.pieces);
} }
@ -229,8 +229,8 @@ fn write_output_in_dir(dir_path: &Path, output: &output::Output) -> Result<()> {
let goal = output.config.goal; let goal = output.config.goal;
let pieces = output.pieces; let pieces = output.pieces;
let incomplete = if output.cleared < goal { "I-" } else { "" }; let incomplete = if !output.did_complete() { "I-" } else { "" };
let date = date.format("%Y-%m-%d_%H-%M-%S");// "YYYYmmdd-HHMMSS"; let date = date.format("%Y-%m-%d_%H-%M-%S"); // "YYYYmmdd-HHMMSS";
let file_name = format!("{goal}L-{incomplete}{pieces}p-{date}.json"); let file_name = format!("{goal}L-{incomplete}{pieces}p-{date}.json");
let io_args = cli::IoArgs { let io_args = cli::IoArgs {

View File

@ -17,6 +17,12 @@ pub struct Output {
pub profile: Option<Profile>, pub profile: Option<Profile>,
} }
impl Output {
pub fn did_complete(&self) -> bool {
self.cleared == self.config.goal
}
}
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
pub struct Move { pub struct Move {
#[serde(flatten, serialize_with = "ser::placement")] #[serde(flatten, serialize_with = "ser::placement")]