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
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?") {
break;
}
@ -163,7 +163,7 @@ fn multi(args: cli::MultiRun) -> Result<()> {
}
}
Msg::Output(_id, output) => {
if output.cleared == config.game.goal {
if output.did_complete() {
completed.insert(output.pieces);
}
@ -229,7 +229,7 @@ fn write_output_in_dir(dir_path: &Path, output: &output::Output) -> Result<()> {
let goal = output.config.goal;
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 file_name = format!("{goal}L-{incomplete}{pieces}p-{date}.json");

View File

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