forked from jana/hanoigame
don't allow moving towers of the same color to empty spots
This commit is contained in:
parent
727a738fd4
commit
fc5872a5af
1 changed files with 7 additions and 0 deletions
|
|
@ -280,6 +280,13 @@ impl<const TOWER_HEIGHT: usize> Game<TOWER_HEIGHT> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let rings = self.towers[from_tower].rings;
|
||||
if rings[1..].iter().all(|i| i == &rings[0])
|
||||
&& self.towers[to_tower].rings[0].is_none()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let m = Move::new(from_tower, to_tower);
|
||||
if self.try_make_move(m, true).is_ok() {
|
||||
res.push(m);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue