day 13 task 2 UI fix
This commit is contained in:
@@ -81,20 +81,25 @@ impl Game {
|
||||
self.pc.clear_output();
|
||||
let done = self.pc.run_until_input_empty();
|
||||
let output = self.pc.get_output().into_iter().map(|it| *it).collect_vec();
|
||||
let mut score = 0;
|
||||
let mut score = None;
|
||||
output
|
||||
.iter()
|
||||
.tuples()
|
||||
.scan(&mut self.field, |map, (x, y, t)| {
|
||||
if *x == -1 && *y == 0 {
|
||||
score = *t;
|
||||
score = Some(*t);
|
||||
} else {
|
||||
map.insert((*x, *y), FieldType::from(*t));
|
||||
}
|
||||
Some(())
|
||||
})
|
||||
.any(|_| false);
|
||||
|
||||
// stupid workaround because I cannot access score from within the clojure,
|
||||
// due to then double-borrowing of mutable reference to self
|
||||
if let Some(score) = score {
|
||||
self.score = score;
|
||||
}
|
||||
if self.show_output {
|
||||
self.print();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user